<font size=2 face="sans-serif">Thank you Martin! </font>
<br><font size=2 face="sans-serif">I think the ticket you referred is clearer
spelt out that all beans are included included disabled ones. From what
you mentioned here, OWB based on Ben's experiment is incorrect by filtering
out the disabled beans when calling beanmanager.getBeans().</font>
<br>
<br><font size=2 face="sans-serif">Many thanks,<br>
Emily<br>
===========================<br>
Emily Jiang<br>
WebSphere Application Server, Liberty Architect for MicroProfile and CDI</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">Martin Kouba &lt;mkouba@redhat.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Emily Jiang &lt;EMIJIANG@uk.ibm.com&gt;,
Matej Novotny &lt;manovotn@redhat.com&gt;, cdi-dev &lt;cdi-dev@lists.jboss.org&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Benjamin Confino &lt;BENJAMIC@uk.ibm.com&gt;,
weld-dev@lists.jboss.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">27/08/2018 08:51</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]
[weld-dev] Question about the spec for BeanManager.getBeans</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>Hi all,<br>
<br>
BeanManager#getBeans() should not apply ambiguous dependency resolution
<br>
rules - see also CDI-231 [1] and related changes. These rules should <br>
only be applied by BeanManager#resolve().<br>
<br>
BeanManager#getBeans() and BeanManager#resolve() are in fact even more
<br>
complicated because they should honor the inter-module injection rules.
<br>
In other words, it also depends where you request the beans from. And <br>
this is where Weld and OWB differ a lot.<br>
<br>
Martin<br>
<br>
[1]<br>
</font></tt><a href="https://issues.jboss.org/browse/CDI-231"><tt><font size=2>https://issues.jboss.org/browse/CDI-231</font></tt></a><tt><font size=2><br>
<br>
<br>
Dne 24.8.2018 v 23:08 Emily Jiang napsal(a):<br>
&gt; Matej,<br>
&gt; <br>
&gt; Thanks for your quick reply!<br>
&gt; I think the spec is quite clear by saying the candidates of typesafe
<br>
&gt; resolutions defined in Performing typesafe resolutions... surely a
<br>
&gt; disabled bean cannot be a candidate. it is simply disquailified.<br>
&gt; <br>
&gt; It did not say eliminate all beans but one though. I think it should
be <br>
&gt; eliminate disqualified ones and leave all qualified at least.<br>
&gt; <br>
&gt; I am sending to cdi-dev for clarification. Antoine, please comment.<br>
&gt; <br>
&gt; Many thanks,<br>
&gt; Emily<br>
&gt; ===========================<br>
&gt; Emily Jiang<br>
&gt; WebSphere Application Server, Liberty Architect for MicroProfile and
CDI<br>
&gt; <br>
&gt; MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
&gt; Phone: &nbsp;+44 (0)1962 816278 &nbsp;Internal: 246278<br>
&gt; <br>
&gt; Email: emijiang@uk.ibm.com<br>
&gt; Lotus Notes: Emily Jiang/UK/IBM@IBMGB<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; From: Matej Novotny &lt;manovotn@redhat.com&gt;<br>
&gt; To: Benjamin Confino &lt;BENJAMIC@uk.ibm.com&gt;<br>
&gt; Cc: weld-dev@lists.jboss.org, Emily Jiang &lt;EMIJIANG@uk.ibm.com&gt;<br>
&gt; Date: 24/08/2018 16:17<br>
&gt; Subject: Re: [weld-dev] Question about the spec for BeanManager.getBeans<br>
&gt; ------------------------------------------------------------------------<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Hi<br>
&gt; <br>
&gt; Looking at spec 11.3.6. Obtaining a Bean by type[1] I can see that
the <br>
&gt; paragraph ends with &quot;according to the rules for candidates of
typesafe <br>
&gt; resolution defined in Performing typesafe resolution.&quot;.<br>
&gt; The important word here is *candidates* IMO.<br>
&gt; The way typesafe resolution is defined, both the original bean and
the <br>
&gt; alternatives are candidates. According to spec, the original bean
is <br>
&gt; still considered enabled[2]<br>
&gt; Note that CDI spec doesn't say that @Alternative would completely
<br>
&gt; eliminate the original bean, it just takes precedence during resolution
<br>
&gt; (as opposed to what specialization does[3]).<br>
&gt; <br>
&gt; Last but not least, one thought - if the getBeans() method was to
<br>
&gt; perform a typesafe resolution and eliminate all but one bean - why
would <br>
&gt; it return a Set (and not throw unsatisfied/ambiguous exceptions)?
:)<br>
&gt; <br>
&gt; Matej<br>
&gt; ______________________________________________________________________________<br>
&gt; [1] </font></tt><a href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#bm_obtain_bean_by_type"><tt><font size=2>http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#bm_obtain_bean_by_type</font></tt></a><tt><font size=2><br>
&gt; [2] </font></tt><a href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#enablement"><tt><font size=2>http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#enablement</font></tt></a><tt><font size=2><br>
&gt; [3] </font></tt><a href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#specialization"><tt><font size=2>http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#specialization</font></tt></a><tt><font size=2><br>
&gt; <br>
&gt; <br>
&gt; ----- Original Message -----<br>
&gt; &nbsp;&gt; From: &quot;Benjamin Confino&quot; &lt;BENJAMIC@uk.ibm.com&gt;<br>
&gt; &nbsp;&gt; To: weld-dev@lists.jboss.org<br>
&gt; &nbsp;&gt; Cc: &quot;Emily Jiang&quot; &lt;EMIJIANG@uk.ibm.com&gt;<br>
&gt; &nbsp;&gt; Sent: Friday, August 24, 2018 3:10:05 PM<br>
&gt; &nbsp;&gt; Subject: [weld-dev] Question about the spec for BeanManager.getBeans<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Hello<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; I was made aware of the difference on the return of<br>
&gt; &nbsp;&gt; beanManager.getBeans(Object.class) between OWB and Weld<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; In OWB, it returns all beans, unless there is an enabled
@alternative <br>
&gt; within<br>
&gt; &nbsp;&gt; the application. If there is an enabled @alternative getBeans()
only <br>
&gt; returns<br>
&gt; &nbsp;&gt; beans annotated @alternative.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; However, in Weld, it returns all beans even with an enabled
@alternative.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; The JavaDoc for BeanMnanager says &quot;according to the
rules of typesafe<br>
&gt; &nbsp;&gt; resolution&quot; and in the CDI 1.0 spec under typesafe
resolution I find one<br>
&gt; &nbsp;&gt; mention of alternatives: “When an ambiguous dependency
exists, the <br>
&gt; container<br>
&gt; &nbsp;&gt; attempts to resolve the ambiguity. The container eliminates
all eligible<br>
&gt; &nbsp;&gt; beans that are not alternatives, except for producer methods
and <br>
&gt; fields of<br>
&gt; &nbsp;&gt; beans that are alternatives.” (This text is also in the
CDI 1.2 spec)<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; However this would imply that if there are no enabled @Alternatives
an<br>
&gt; &nbsp;&gt; ambiguous resolution like beanManager.getBeans(Object.class)
should <br>
&gt; discard<br>
&gt; &nbsp;&gt; everything. In this case, the Weld behaviour is incorrect.<br>
&gt; &nbsp;&gt; beanManager.getBeans() should only return the resolved
or enabled beans.<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Regards<br>
&gt; &nbsp;&gt; Benjamin<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; Can someone verify this?<br>
&gt; &nbsp;&gt; Unless stated otherwise above:<br>
&gt; &nbsp;&gt; IBM United Kingdom Limited - Registered in England and
Wales with number<br>
&gt; &nbsp;&gt; 741598.<br>
&gt; &nbsp;&gt; Registered office: PO Box 41, North Harbour, Portsmouth,
Hampshire <br>
&gt; PO6 3AU<br>
&gt; &nbsp;&gt;<br>
&gt; &nbsp;&gt; _______________________________________________<br>
&gt; &nbsp;&gt; weld-dev mailing list<br>
&gt; &nbsp;&gt; weld-dev@lists.jboss.org<br>
&gt; &nbsp;&gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/weld-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/weld-dev</font></tt></a><tt><font size=2><br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; Unless stated otherwise above:<br>
&gt; IBM United Kingdom Limited - Registered in England and Wales with
number <br>
&gt; 741598.<br>
&gt; Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU<br>
&gt; <br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; cdi-dev@lists.jboss.org<br>
&gt; </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>
&gt; <br>
&gt; 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.<br>
&gt; <br>
<br>
-- <br>
Martin Kouba<br>
Senior Software Engineer<br>
Red Hat, Czech Republic<br>
<br>
</font></tt>
<br>
<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>