<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>
<br>
<br>
<br><font size=3>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>
<p><font size=3>To help prevent developer error, the first bean may:</font>
<ul>
<li><font size=3>directly extend the bean class of the second bean, or</font>
<li><font size=3><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>explicitly
declare that it <i>specializes</i> the second bean.</font>
<p>
<p><font size=2 face="sans-serif">After this suggestion, the above sentence
is not true any more.</font>
<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">&nbsp;<br>
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
Phone: &nbsp;+44 (0)1962 816278 &nbsp;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: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">John Ament &lt;john.ament@spartasystems.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Matej Novotny &lt;manovotn@redhat.com&gt;,
Mark Struberg &lt;struberg@yahoo.de&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Emily Jiang/UK/IBM@IBMGB,
cdi-dev &lt;cdi-dev@lists.jboss.org&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">12/09/2016 13:31</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</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: &nbsp; &nbsp;
&nbsp; &nbsp;</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">@Matej - Yes, that would be consistent
with what I was seeing as well.</font>
<br>
<br><font size=3 face="Calibri">@Mark - Are you thinking about decorators
and not alternatives? &nbsp;See also [1]</font>
<br><font size=3 face="Calibri">Really the goal here is to substitute the
bean, but not just the provided bean the producer method that it exposes.
&nbsp;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.
&nbsp;No ambiguous resolutions, it just works properly.</font>
<br>
<br><font size=3 face="Calibri">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.</font>
<br>
<br>
<br><font size=3 face="Calibri">[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>
<p><font size=3 face="Calibri"><br>
</font>
<br>
<hr>
<br><font size=2 face="Calibri"><b>From:</b> Matej Novotny &lt;manovotn@redhat.com&gt;<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">
</font>
<br><font size=3 face="Calibri">&nbsp;</font>
<br><font size=2 face="Calibri">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>
&gt; From: &quot;Mark Struberg&quot; &lt;struberg@yahoo.de&gt;<br>
&gt; To: &quot;John Ament&quot; &lt;john.ament@spartasystems.com&gt;, &quot;Emily
Jiang&quot; &lt;EMIJIANG@uk.ibm.com&gt;<br>
&gt; Cc: &quot;cdi-dev&quot; &lt;cdi-dev@lists.jboss.org&gt;<br>
&gt; Sent: Monday, September 12, 2016 8:00:55 AM<br>
&gt; Subject: Re: [cdi-dev] Should javax.enterprise.inject.Produces be
inherited?<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &gt; Right now inheritance of managed beans is itself problematic,
as<br>
&gt; <br>
&gt; &gt; injecting the base class can cause these ambiguous resolutions.<br>
&gt; <br>
&gt; Yes, that's why we originally introduced @Typed.<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Your sample wont work as an Alternative as it extends a concrete class
and<br>
&gt; doesn't implement any interface.<br>
&gt; Did you mean @Specializes?<br>
&gt; Note that with @Alternative you won't make the original producer go
away.You<br>
&gt; would also need to add @Alternative to the producer method imo. The
rules<br>
&gt; for making an alternative producer method are really a bit confusing
;) I<br>
&gt; think the most portable way is to annotate both the class and the
producer<br>
&gt; method with @Alternative.<br>
&gt; <br>
&gt; <br>
&gt; LieGrue,<br>
&gt; strub<br>
&gt; <br>
&gt; <br>
&gt; On Monday, 12 September 2016, 0:57, John Ament &lt;john.ament@spartasystems.com&gt;<br>
&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;Hi Emily,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;I disagree, at least it doesn't add any new ambiguous injections.
&nbsp;The<br>
&gt; &gt;use-case is specifically to Specialized/Alternative beans. &nbsp;Right
now<br>
&gt; &gt;inheritance of managed beans is itself problematic, as injecting
the base<br>
&gt; &gt;class can cause these ambiguous resolutions.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;The example I sent out actually works correctly (in weld at least),
really<br>
&gt; &gt;my propose is to remove the need to have Produces a second time
and update<br>
&gt; &gt;the spec to clarify what happens here (FWIW, I don't believe the
case is<br>
&gt; &gt;currently described in the spec), hopefully to say that qualifiers
and<br>
&gt; &gt;scopes from the base method remain in effect, unless explicitly
overridden.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;John<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;________________________________<br>
&gt; &gt; <br>
&gt; &gt;From: Emily Jiang &lt;EMIJIANG@uk.ibm.com&gt;<br>
&gt; &gt;Sent: Sunday, September 11, 2016 5:59 PM<br>
&gt; &gt;To: John Ament<br>
&gt; &gt;Cc: cdi-dev<br>
&gt; &gt;Subject: Re: [cdi-dev] Should javax.enterprise.inject.Produces
be inherited?<br>
&gt; &gt; <br>
&gt; &gt;I think this is very problematic as you will get<br>
&gt; &gt;AmbiguousResolutionException all the time once we introduce this<br>
&gt; &gt;inheritance.<br>
&gt; &gt;<br>
&gt; &gt;Many thanks,<br>
&gt; &gt;Emily<br>
&gt; &gt;===========================<br>
&gt; &gt;Emily Jiang<br>
&gt; &gt;WebSphere Application Server, CDI Development Lead<br>
&gt; &gt; <br>
&gt; &gt;MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
&gt; &gt;Phone: &nbsp;+44 (0)1962 816278 &nbsp;Internal: 246278<br>
&gt; &gt;<br>
&gt; &gt;Email: emijiang@uk.ibm.com<br>
&gt; &gt;Lotus Notes: Emily Jiang/UK/IBM@IBMGB<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;From: &nbsp; &nbsp; &nbsp; &nbsp;John Ament &lt;john.ament@spartasystems.com&gt;<br>
&gt; &gt;To: &nbsp; &nbsp; &nbsp; &nbsp;cdi-dev &lt;cdi-dev@lists.jboss.org&gt;<br>
&gt; &gt;Date: &nbsp; &nbsp; &nbsp; &nbsp;11/09/2016 20:04<br>
&gt; &gt;Subject: &nbsp; &nbsp; &nbsp; &nbsp;[cdi-dev] Should javax.enterprise.inject.Produces
be<br>
&gt; &gt;inherited?<br>
&gt; &gt;Sent by: &nbsp; &nbsp; &nbsp; &nbsp;cdi-dev-bounces@lists.jboss.org<br>
&gt; &gt;&gt;________________________________<br>
&gt; &gt; <br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;All,<br>
&gt; &gt;<br>
&gt; &gt;I was just thinking about alternatives and producer methods. &nbsp;Suppose
I have<br>
&gt; &gt;the following bean:<br>
&gt; &gt;<br>
&gt; &gt;@ApplicationScoped<br>
&gt; &gt;public class Boop {<br>
&gt; &gt;<br>
&gt; &gt; &nbsp; &nbsp;@Produces<br>
&gt; &gt; &nbsp; &nbsp;@ApplicationScoped<br>
&gt; &gt; &nbsp; &nbsp;public Simpler makeSimpler() {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;return new Simpler(&quot;Boop&quot;);<br>
&gt; &gt; &nbsp; &nbsp;}<br>
&gt; &gt;}<br>
&gt; &gt;<br>
&gt; &gt;If I want to override the producer method, I need to declare fully:<br>
&gt; &gt;<br>
&gt; &gt;@Alternative<br>
&gt; &gt;@Priority(100)<br>
&gt; &gt;@ApplicationScoped<br>
&gt; &gt;public class BoopAlternative extends Boop{<br>
&gt; &gt; &nbsp; &nbsp;@Override<br>
&gt; &gt; &nbsp; &nbsp;@Produces<br>
&gt; &gt; &nbsp; &nbsp;public Simpler makeSimpler() {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp;return new Simpler(&quot;Boop2&quot;);<br>
&gt; &gt; &nbsp; &nbsp;}<br>
&gt; &gt;}<br>
&gt; &gt;<br>
&gt; &gt;For some reason, scopes are inherited, but the produces annotation
is not.<br>
&gt; &gt;At least in the case of a producer method, it seems like it would
be<br>
&gt; &gt;useful for @Produces to be inherited as well.<br>
&gt; &gt;<br>
&gt; &gt;John<br>
&gt; &gt;<br>
&gt; &gt;________________________________<br>
&gt; &gt; NOTICE: This e-mail message and any attachments may contain confidential,<br>
&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt; &gt; accordingly. If you are not the intended recipient, please notify
the<br>
&gt; &gt; sender immediately by return e-mail, delete this message, and
destroy all<br>
&gt; &gt; physical and electronic copies. Thank you.<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt;cdi-dev mailing list<br>
&gt; &gt;cdi-dev@lists.jboss.org<br>
&gt; &gt;</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">cdi-dev
Info Page - JBoss Developer</font></a>
<br><font size=1 color=#5f5f5f face="Segoe UI">lists.jboss.org</font>
<br><font size=1 color=#5f5f5f face="Segoe UI">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>
&gt; &gt;<br>
&gt; &gt;Note that for all code provided on this list, the provider licenses
the code<br>
&gt; &gt;under the Apache License, Version 2<br>
&gt; &gt;(</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>
&gt; &gt;provided on this list, the provider waives all patent and other<br>
&gt; &gt;intellectual property rights inherent in such information.<br>
&gt; &gt;cdi-dev Info Page - JBoss Developer<br>
&gt; &gt;lists.jboss.org<br>
&gt; &gt;List to discuss the development of CDI (the specification) To
see the<br>
&gt; &gt;collection of prior postings to the list, visit the cdi-dev Archives.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;Unless stated otherwise above:<br>
&gt; &gt;IBM United Kingdom Limited - Registered in England and Wales with
number<br>
&gt; &gt;741598.<br>
&gt; &gt;Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;________________________________<br>
&gt; &gt; NOTICE: This e-mail message and any attachments may contain confidential,<br>
&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt; &gt; accordingly. If you are not the intended recipient, please notify
the<br>
&gt; &gt; sender immediately by return e-mail, delete this message, and
destroy all<br>
&gt; &gt; physical and electronic copies. Thank you.<br>
&gt; &gt;<br>
&gt; &gt;_______________________________________________<br>
&gt; &gt;cdi-dev mailing list<br>
&gt; &gt;cdi-dev@lists.jboss.org<br>
&gt; &gt;</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>
&gt; &gt;<br>
&gt; &gt;Note that for all code provided on this list, the provider licenses
the code<br>
&gt; &gt;under the Apache License, Version 2<br>
&gt; &gt;(</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>
&gt; &gt;provided on this list, the provider waives all patent and other<br>
&gt; &gt;intellectual property rights inherent in such information.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; cdi-dev@lists.jboss.org<br>
&gt; </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>
&gt; <br>
&gt; Note that for all code provided on this list, the provider licenses
the code<br>
&gt; under the Apache License, Version 2<br>
&gt; (</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>
&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt; property rights inherent in such information.<br>
&gt; </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>