<font size=2 face="sans-serif">John,</font>
<br>
<br><font size=2 face="sans-serif">Basically what you suggested is to omit
the @Produces on overriding the producer methods. </font>
<br>
<br><font size=2 face="sans-serif">I am trying to spell out the gap: I
am not sure whether the user scenario, where you would override the method
but not adding @Produces, is useful. Is this potentially used by any testing
apps? If you don't add @Produces on overriding a producer method, when
the container calls the producer method, which one will be invoked?</font>
<br>
<br><font size=2 face="sans-serif">Something related to this area, for
the following two code snippets, the first producer is a kind of alternative
even though not annotating with @Alternative. They are the same, right?</font>
<br>
<p><font size=2 face="Calibri">@Alternative<br>
@Priority(100)<br>
@ApplicationScoped<br>
public class BoopAlternative extends Boop{<br>
@Override<br>
@Produces<br>
public Simpler makeSimpler() {<br>
return new Simpler("Boop2");<br>
}</font>
<p>
<p><font size=2 face="Calibri">@Alternative<br>
@Priority(100)<br>
@ApplicationScoped<br>
public class BoopAlternative extends Boop{<br>
@Override<br>
@Produces</font>
<p><font size=2 face="Calibri"> <b> @Alternative</b><br>
public Simpler makeSimpler() {<br>
return new Simpler("Boop2");<br>
}</font>
<p>
<br>
<br><font size=2 face="sans-serif">Many thanks,<br>
Emily<br>
===========================<br>
Emily Jiang<br>
WebSphere Application Server, CDI Development Lead</font>
<br><font size=2 face="sans-serif"> <br>
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
Phone: +44 (0)1962 816278 Internal: 246278<br>
<br>
Email: emijiang@uk.ibm.com <br>
Lotus Notes: Emily Jiang/UK/IBM@IBMGB<br>
</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">John Ament <john.ament@spartasystems.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Emily Jiang/UK/IBM@IBMGB</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">cdi-dev <cdi-dev@lists.jboss.org></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">13/09/2016 11:38</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [cdi-dev]
Should javax.enterprise.inject.Produces be inherited?</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by:
</font><font size=1 face="sans-serif">cdi-dev-bounces@lists.jboss.org</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3 face="Calibri">Emily,</font>
<br>
<br><font size=3 face="Calibri">Just want to make sure I follow. Are
you saying this because right now it is required that you add @Produces
to the overridden method?</font>
<br>
<br><font size=3 face="Calibri">I don't realistically see a scenario where
you would override the method and not add produces. This method is
intended to be called by the container.</font>
<br>
<br><font size=3 face="Calibri">John</font>
<p><font size=3 face="Calibri"><br>
</font>
<br>
<hr>
<br><font size=2 face="Calibri"><b>From:</b> Emily Jiang <EMIJIANG@uk.ibm.com><b><br>
Sent:</b> Tuesday, September 13, 2016 4:37 AM<b><br>
To:</b> John Ament<b><br>
Cc:</b> Matej Novotny; Mark Struberg; cdi-dev<b><br>
Subject:</b> Re: [cdi-dev] Should javax.enterprise.inject.Produces be inherited?</font><font size=3 face="Calibri">
</font>
<br><font size=3 face="Calibri"> </font>
<br><font size=2 face="sans-serif">First of all, the subject line suggests
the produces should be inherited under all conditions. Anyway, after your
explanation, I think this suggestion contradicts with spec and breaks backward
compatibility. In the cdi 1.2/cdi 2.0 spec,</font><font size=3 face="Calibri">
<br>
<br>
<br>
The only way one bean can completely override a second bean at all injection
points is if it implements all the bean types and declares all the qualifiers
of the second bean. <b>However, if the second bean declares a producer
method or observer method, then even this is not enough to ensure that
the second bean is never called!</b> </font>
<br><font size=3 face="Calibri">To help prevent developer error, the first
bean may: </font>
<ul>
<li><font size=3 face="Calibri">directly extend the bean class of the second
bean, or </font>
<li><font size=3 face="Calibri"><b>directly override the producer method,
in the case that the second bean is a producer method, and then</b></font></ul><font size=3 face="Calibri">explicitly
declare that it <i>specializes</i> the second bean. </font>
<br><font size=2 face="sans-serif">After this suggestion, the above sentence
is not true any more.</font><font size=3 face="Calibri"> <br>
</font><font size=2 face="sans-serif"><br>
Many thanks,<br>
Emily<br>
===========================<br>
Emily Jiang<br>
WebSphere Application Server, CDI Development Lead</font><font size=3 face="Calibri">
</font><font size=2 face="sans-serif"><br>
<br>
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
Phone: +44 (0)1962 816278 Internal: 246278<br>
<br>
Email: emijiang@uk.ibm.com <br>
Lotus Notes: Emily Jiang/UK/IBM@IBMGB</font><font size=3 face="Calibri"><br>
<br>
<br>
<br>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
From: </font><font size=1 face="sans-serif">John
Ament <john.ament@spartasystems.com></font><font size=3 face="Calibri">
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
To: </font><font size=1 face="sans-serif">Matej
Novotny <manovotn@redhat.com>, Mark Struberg <struberg@yahoo.de></font><font size=3 face="Calibri">
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Cc: </font><font size=1 face="sans-serif">Emily
Jiang/UK/IBM@IBMGB, cdi-dev <cdi-dev@lists.jboss.org></font><font size=3 face="Calibri">
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Date: </font><font size=1 face="sans-serif">12/09/2016
13:31</font><font size=3 face="Calibri"> </font><font size=1 color=#5f5f5f face="sans-serif"><br>
Subject: </font><font size=1 face="sans-serif">Re:
[cdi-dev] Should javax.enterprise.inject.Produces be inherited?</font><font size=3 face="Calibri">
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Sent by: </font><font size=1 face="sans-serif">cdi-dev-bounces@lists.jboss.org</font><font size=3 face="Calibri">
</font>
<p>
<hr noshade><font size=3 face="Calibri"><br>
<br>
<br>
@Matej - Yes, that would be consistent with what I was seeing as well.
<br>
<br>
@Mark - Are you thinking about decorators and not alternatives? See
also [1] <br>
Really the goal here is to substitute the bean, but not just the provided
bean the producer method that it exposes. It seems to work as I would
expect it in weld (as mentioned), when I add @Produces to the method, it
overrides the base class's producer method. No ambiguous resolutions,
it just works properly. <br>
<br>
Realistically, this is all an experiment to see if I can provide spring
boot like default configurations (beans, config values, etc) in a framework,
and override them as an application developer. <br>
<br>
<br>
[1]: </font><a href="http://docs.jboss.org/cdi/spec/2.0.EDR2/cdi-spec.html#alternatives"><font size=3 color=blue face="Calibri"><u>http://docs.jboss.org/cdi/spec/2.0.EDR2/cdi-spec.html#alternatives</u></font></a><font size=3 face="Calibri">
</font>
<br><font size=3 face="Calibri"><br>
</font>
<p>
<hr><font size=2 face="Calibri"><b><br>
From:</b> Matej Novotny <manovotn@redhat.com><b><br>
Sent:</b> Monday, September 12, 2016 3:28 AM<b><br>
To:</b> Mark Struberg<b><br>
Cc:</b> John Ament; Emily Jiang; cdi-dev<b><br>
Subject:</b> Re: [cdi-dev] Should javax.enterprise.inject.Produces be inherited?</font><font size=3 face="Calibri">
<br>
</font><font size=2 face="Calibri"><br>
Hi all,<br>
<br>
I did some testing (with Weld) and it seems the scope IS inherited when
you use @Alternative.<br>
However it IS NOT inherited when you use @Specialized.<br>
<br>
Not yet sure if this is intended or anyhow spec-defined, just stating facts.<br>
<br>
Matej<br>
<br>
----- Original Message -----<br>
> From: "Mark Struberg" <struberg@yahoo.de><br>
> To: "John Ament" <john.ament@spartasystems.com>, "Emily
Jiang" <EMIJIANG@uk.ibm.com><br>
> Cc: "cdi-dev" <cdi-dev@lists.jboss.org><br>
> Sent: Monday, September 12, 2016 8:00:55 AM<br>
> Subject: Re: [cdi-dev] Should javax.enterprise.inject.Produces be
inherited?<br>
> <br>
> <br>
> <br>
> > Right now inheritance of managed beans is itself problematic,
as<br>
> <br>
> > injecting the base class can cause these ambiguous resolutions.<br>
> <br>
> Yes, that's why we originally introduced @Typed.<br>
> <br>
> <br>
> <br>
> Your sample wont work as an Alternative as it extends a concrete class
and<br>
> doesn't implement any interface.<br>
> Did you mean @Specializes?<br>
> Note that with @Alternative you won't make the original producer go
away.You<br>
> would also need to add @Alternative to the producer method imo. The
rules<br>
> for making an alternative producer method are really a bit confusing
;) I<br>
> think the most portable way is to annotate both the class and the
producer<br>
> method with @Alternative.<br>
> <br>
> <br>
> LieGrue,<br>
> strub<br>
> <br>
> <br>
> On Monday, 12 September 2016, 0:57, John Ament <john.ament@spartasystems.com><br>
> wrote:<br>
> ><br>
> >Hi Emily,<br>
> ><br>
> ><br>
> >I disagree, at least it doesn't add any new ambiguous injections.
The<br>
> >use-case is specifically to Specialized/Alternative beans. Right
now<br>
> >inheritance of managed beans is itself problematic, as injecting
the base<br>
> >class can cause these ambiguous resolutions.<br>
> ><br>
> ><br>
> >The example I sent out actually works correctly (in weld at least),
really<br>
> >my propose is to remove the need to have Produces a second time
and update<br>
> >the spec to clarify what happens here (FWIW, I don't believe the
case is<br>
> >currently described in the spec), hopefully to say that qualifiers
and<br>
> >scopes from the base method remain in effect, unless explicitly
overridden.<br>
> ><br>
> ><br>
> >John<br>
> ><br>
> ><br>
> ><br>
> >________________________________<br>
> > <br>
> >From: Emily Jiang <EMIJIANG@uk.ibm.com><br>
> >Sent: Sunday, September 11, 2016 5:59 PM<br>
> >To: John Ament<br>
> >Cc: cdi-dev<br>
> >Subject: Re: [cdi-dev] Should javax.enterprise.inject.Produces
be inherited?<br>
> > <br>
> >I think this is very problematic as you will get<br>
> >AmbiguousResolutionException all the time once we introduce this<br>
> >inheritance.<br>
> ><br>
> >Many thanks,<br>
> >Emily<br>
> >===========================<br>
> >Emily Jiang<br>
> >WebSphere Application Server, CDI Development Lead<br>
> > <br>
> >MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
> >Phone: +44 (0)1962 816278 Internal: 246278<br>
> ><br>
> >Email: emijiang@uk.ibm.com<br>
> >Lotus Notes: Emily Jiang/UK/IBM@IBMGB<br>
> ><br>
> ><br>
> ><br>
> ><br>
> >From: John Ament <john.ament@spartasystems.com><br>
> >To: cdi-dev <cdi-dev@lists.jboss.org><br>
> >Date: 11/09/2016 20:04<br>
> >Subject: [cdi-dev] Should javax.enterprise.inject.Produces
be<br>
> >inherited?<br>
> >Sent by: cdi-dev-bounces@lists.jboss.org<br>
> >>________________________________<br>
> > <br>
> ><br>
> ><br>
> >All,<br>
> ><br>
> >I was just thinking about alternatives and producer methods. Suppose
I have<br>
> >the following bean:<br>
> ><br>
> >@ApplicationScoped<br>
> >public class Boop {<br>
> ><br>
> > @Produces<br>
> > @ApplicationScoped<br>
> > public Simpler makeSimpler() {<br>
> > return new Simpler("Boop");<br>
> > }<br>
> >}<br>
> ><br>
> >If I want to override the producer method, I need to declare fully:<br>
> ><br>
> >@Alternative<br>
> >@Priority(100)<br>
> >@ApplicationScoped<br>
> >public class BoopAlternative extends Boop{<br>
> > @Override<br>
> > @Produces<br>
> > public Simpler makeSimpler() {<br>
> > return new Simpler("Boop2");<br>
> > }<br>
> >}<br>
> ><br>
> >For some reason, scopes are inherited, but the produces annotation
is not.<br>
> >At least in the case of a producer method, it seems like it would
be<br>
> >useful for @Produces to be inherited as well.<br>
> ><br>
> >John<br>
> ><br>
> >________________________________<br>
> > NOTICE: This e-mail message and any attachments may contain confidential,<br>
> > proprietary, and/or privileged information which should be treated<br>
> > accordingly. If you are not the intended recipient, please notify
the<br>
> > sender immediately by return e-mail, delete this message, and
destroy all<br>
> > physical and electronic copies. Thank you.<br>
> > _______________________________________________<br>
> >cdi-dev mailing list<br>
> >cdi-dev@lists.jboss.org<br>
> ></font><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><font size=2 color=blue face="Calibri"><u>https://lists.jboss.org/mailman/listinfo/cdi-dev</u></font></a><font size=2 face="Calibri">
</font>
<table width=100% style="border-collapse:collapse;">
<tr valign=top height=8>
<td width=100% bgcolor=white style="border-style:solid none solid none;border-color:#C8C8C8;border-width:1px 0px 1px 0px;padding:1px 1px;"><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target=_blank><font size=3 color=blue face="Segoe UI Light"><u>cdi-dev
Info Page - JBoss Developer</u></font></a><font size=3> </font><font size=1 color=#5f5f5f face="Segoe UI"><br>
lists.jboss.org</font><font size=3> </font><font size=1 color=#5f5f5f face="Segoe UI"><br>
List to discuss the development of CDI (the specification) To see the collection
of prior postings to the list, visit the cdi-dev Archives.</font></table>
<br><font size=2 face="Calibri"><br>
<br>
<br>
> ><br>
> >Note that for all code provided on this list, the provider licenses
the code<br>
> >under the Apache License, Version 2<br>
> >(</font><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><font size=2 color=blue face="Calibri"><u>http://www.apache.org/licenses/LICENSE-2.0.html</u></font></a><font size=2 face="Calibri">).
For all other ideas<br>
> >provided on this list, the provider waives all patent and other<br>
> >intellectual property rights inherent in such information.<br>
> >cdi-dev Info Page - JBoss Developer<br>
> >lists.jboss.org<br>
> >List to discuss the development of CDI (the specification) To
see the<br>
> >collection of prior postings to the list, visit the cdi-dev Archives.<br>
> ><br>
> ><br>
> >Unless stated otherwise above:<br>
> >IBM United Kingdom Limited - Registered in England and Wales with
number<br>
> >741598.<br>
> >Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU<br>
> ><br>
> ><br>
> ><br>
> >________________________________<br>
> > NOTICE: This e-mail message and any attachments may contain confidential,<br>
> > proprietary, and/or privileged information which should be treated<br>
> > accordingly. If you are not the intended recipient, please notify
the<br>
> > sender immediately by return e-mail, delete this message, and
destroy all<br>
> > physical and electronic copies. Thank you.<br>
> ><br>
> >_______________________________________________<br>
> >cdi-dev mailing list<br>
> >cdi-dev@lists.jboss.org<br>
> ></font><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><font size=2 color=blue face="Calibri"><u>https://lists.jboss.org/mailman/listinfo/cdi-dev</u></font></a><font size=2 face="Calibri"><br>
> ><br>
> >Note that for all code provided on this list, the provider licenses
the code<br>
> >under the Apache License, Version 2<br>
> >(</font><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><font size=2 color=blue face="Calibri"><u>http://www.apache.org/licenses/LICENSE-2.0.html</u></font></a><font size=2 face="Calibri">).
For all other ideas<br>
> >provided on this list, the provider waives all patent and other<br>
> >intellectual property rights inherent in such information.<br>
> ><br>
> ><br>
> _______________________________________________<br>
> cdi-dev mailing list<br>
> cdi-dev@lists.jboss.org<br>
> </font><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><font size=2 color=blue face="Calibri"><u>https://lists.jboss.org/mailman/listinfo/cdi-dev</u></font></a><font size=2 face="Calibri"><br>
> <br>
> Note that for all code provided on this list, the provider licenses
the code<br>
> under the Apache License, Version 2<br>
> (</font><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><font size=2 color=blue face="Calibri"><u>http://www.apache.org/licenses/LICENSE-2.0.html</u></font></a><font size=2 face="Calibri">).
For all other ideas<br>
> provided on this list, the provider waives all patent and other intellectual<br>
> property rights inherent in such information.<br>
> </font><font size=3 face="Calibri"><br>
</font>
<hr><font size=3 face="Calibri">NOTICE: This e-mail message and any attachments
may contain confidential, proprietary, and/or privileged information which
should be treated accordingly. If you are not the intended recipient, please
notify the sender immediately by return e-mail, delete this message, and
destroy all physical and electronic copies. Thank you. </font><font size=2 face="Calibri">_______________________________________________<br>
cdi-dev mailing list<br>
cdi-dev@lists.jboss.org</font><font size=3 color=blue face="Calibri"><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><font size=2 color=blue face="Calibri"><u>https://lists.jboss.org/mailman/listinfo/cdi-dev</u></font></a><font size=2 face="Calibri"><br>
<br>
Note that for all code provided on this list, the provider licenses the
code under the Apache License, Version 2 (</font><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><font size=2 color=blue face="Calibri"><u>http://www.apache.org/licenses/LICENSE-2.0.html</u></font></a><font size=2 face="Calibri">).
For all other ideas provided on this list, the provider waives all patent
and other intellectual property rights inherent in such information.</font><font size=3 face="Calibri">
</font><font size=2 face="sans-serif"><br>
<br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU</font>
<br>
<hr><font size=3>NOTICE: This e-mail message and any attachments may contain
confidential, proprietary, and/or privileged information which should be
treated accordingly. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this message, and destroy
all physical and electronic copies. Thank you. </font><tt><font size=2>_______________________________________________<br>
cdi-dev mailing list<br>
cdi-dev@lists.jboss.org<br>
</font></tt><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/cdi-dev</font></tt></a><tt><font size=2><br>
<br>
Note that for all code provided on this list, the provider licenses the
code under the Apache License, Version 2 (</font></tt><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><tt><font size=2>http://www.apache.org/licenses/LICENSE-2.0.html</font></tt></a><tt><font size=2>).
For all other ideas provided on this list, the provider waives all patent
and other intellectual property rights inherent in such information.</font></tt>
<br><font size=2 face="sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU<br>
</font>