<div dir="ltr"><div><div><div></div>This is a test application and test this spec section 4.3. I would like to see the application behaves the same on both Weld and OWB.<br></div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 23, 2015 at 11:13 AM, Matej Novotny <span dir="ltr">&lt;<a href="mailto:manovotn@redhat.com" target="_blank">manovotn@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, Emily<br>
<br>
before we delve into questions regarding spec clarification, I have two questions for you :)<br>
<br>
1) What is the point of disabling @Specialized bean(be it with @Veto or @Alternative) when you have no other @Specialized bean to take its place?<br>
 - this use case just feels....weird at best?<br>
 - to me it seems rather unusual, I guess you need to achieve different behavior in two cases - that&#39;s what you can do with 2 @Spec beans<br>
<br>
2) Isn&#39;t there always a way around to achieve what you are aiming for?<br>
 - enabling it app-wise with @Priority or using two @Specialized beans with additional qualifiers?<br>
 - this way you are still moving within boundaries of current spec and can achieve the same goal<br>
 - could you, please, give me a use-case where your scenario is absolutely necessary?<br>
<span class="im HOEnZb"><br>
Matej<br>
<br>
----- Original Message -----<br>
</span><div class="HOEnZb"><div class="h5">From: &quot;Emily Jiang&quot; &lt;<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt;<br>
To: &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>&gt;<br>
Cc: &quot;Matej Novotny&quot; &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt;, &quot;cdi-dev&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Sent: Monday, November 23, 2015 11:30:54 AM<br>
Subject: Re: [cdi-dev] Clarification on 4.3 Specialization<br>
<br>
Hi Martin,<br>
Although the spec does not enforce that @Specialized must be used in<br>
conjunction with @Alternative , I would like to unify the understanding of<br>
what the spec behavior of @Specialized on an disabled bean is.<br>
<br>
Thanks<br>
Emily<br>
<br>
On Mon, Nov 23, 2015 at 10:06 AM, Martin Kouba &lt;<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>&gt; wrote:<br>
<br>
&gt; Hi Emily,<br>
&gt;<br>
&gt; the problem is Specialization is not defined per bean archive but per<br>
&gt; application. A bean is either specialized or not. Note that specialization<br>
&gt; is not tied to alternatives.<br>
&gt;<br>
&gt; WRT your use-case: the specializing bean should be enabled globally or in<br>
&gt; each bean archive which is using the specialized bean.<br>
&gt;<br>
&gt; Martin<br>
&gt;<br>
&gt; Dne 23.11.2015 v 10:54 Emily Jiang napsal(a):<br>
&gt;<br>
&gt;&gt; Thank you Tom and Matej for your response!<br>
&gt;&gt; The alternative was enabled in the archive beans-xml-modified.jar, but<br>
&gt;&gt; it is not enabled in the archive beans-xml-modified2.jar. The issue is<br>
&gt;&gt; not with alternative but with Specialized.<br>
&gt;&gt;<br>
&gt;&gt; At the moment, Weld specialized is effective even if itself is not<br>
&gt;&gt; enabled, which is not desirable because it disables other bean but<br>
&gt;&gt; itself is not enabled. As a consequence, this causes deployment error.<br>
&gt;&gt;<br>
&gt;&gt; The CDI 1.2 section 4.3  spec says:<br>
&gt;&gt; When an enabled bean, as defined in Section 5.1.2, “Enabled and disabled<br>
&gt;&gt; beans”, specializes<br>
&gt;&gt; a second bean, we can be certain that the second bean is never<br>
&gt;&gt; instantiated or called by the<br>
&gt;&gt; container. Even if the second bean defines a producer or observer<br>
&gt;&gt; method, the method will never<br>
&gt;&gt; be called.<br>
&gt;&gt;<br>
&gt;&gt; It is true the above sentence comments about an enabled bean. It hits an<br>
&gt;&gt; disabled bean should not specialize a second bean. If you guys think it<br>
&gt;&gt; is unclear, can we update the spec to clarify this scenario?<br>
&gt;&gt;<br>
&gt;&gt; By the way, OWB and Weld behave differently (Weld thinks a disabled bean<br>
&gt;&gt; still specializes a second bean while OWB thinks a disabled bean does<br>
&gt;&gt; NOT specialize a second bean). This is something we can leave to<br>
&gt;&gt; implementation. We should spec it!<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Nov 23, 2015 at 8:45 AM, Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a><br>
&gt;&gt; &lt;mailto:<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;     Hello Emily<br>
&gt;&gt;<br>
&gt;&gt;     I agree with Tom. In your case, specialized producer is enabled (via<br>
&gt;&gt;     beans.xml) although only per bean archive.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     And about this:<br>
&gt;&gt;     &gt;&gt;From Weld&#39;s perspective, any bean annotated with @Specialized<br>
&gt;&gt; disables a second bean regardless whether itself is active or not.<br>
&gt;&gt;<br>
&gt;&gt;     It is true, however the spec doesn&#39;t define how does a @Specialized<br>
&gt;&gt;     bean behave when it is disabled (or at least I haven&#39;t found that<br>
&gt;&gt; bit).<br>
&gt;&gt;     So this leaves it up to implementation and I can&#39;t really see a<br>
&gt;&gt;     problem with it. Why would you create a @Specialized bean and<br>
&gt;&gt;     disable it afterwards (with no other @Specialized and/or<br>
&gt;&gt;     @Alternative active)?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     Matej<br>
&gt;&gt;<br>
&gt;&gt;     ----- Original Message -----<br>
&gt;&gt;     From: &quot;Tomas Remes&quot; &lt;<a href="mailto:tremes@redhat.com">tremes@redhat.com</a> &lt;mailto:<a href="mailto:tremes@redhat.com">tremes@redhat.com</a>&gt;&gt;<br>
&gt;&gt;     To: &quot;Emily Jiang&quot; &lt;<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a><br>
&gt;&gt;     &lt;mailto:<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt;&gt;<br>
&gt;&gt;     Cc: &quot;cdi-dev&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a> &lt;mailto:<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;&gt;<br>
&gt;&gt;     Sent: Monday, November 23, 2015 8:33:44 AM<br>
&gt;&gt;     Subject: Re: [cdi-dev] Clarification on 4.3 Specialization<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     Hi Emily,<br>
&gt;&gt;<br>
&gt;&gt;     I am not sure I follow. What is disabled?<br>
&gt;&gt;     AlternativeCounterProducerModified? I can see<br>
&gt;&gt;     AlternativeCounterProducerModified is enabled in beans.xml of the<br>
&gt;&gt;     given bean archive and it means it is selected alternative only per<br>
&gt;&gt;     the bean archive. So I can&#39;t see any problem (or maybe I don&#39;t fully<br>
&gt;&gt;     understand).<br>
&gt;&gt;<br>
&gt;&gt;     Tom<br>
&gt;&gt;<br>
&gt;&gt;     ----- Original Message -----<br>
&gt;&gt;     From: &quot;Emily Jiang&quot; &lt;<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a><br>
&gt;&gt;     &lt;mailto:<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt;&gt;<br>
&gt;&gt;     To: &quot;cdi-dev&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a> &lt;mailto:<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;&gt;<br>
&gt;&gt;     Sent: Sunday, November 22, 2015 10:42:29 PM<br>
&gt;&gt;     Subject: Re: [cdi-dev] Clarification on 4.3 Specialization<br>
&gt;&gt;<br>
&gt;&gt;     any thoughts?<br>
&gt;&gt;<br>
&gt;&gt;     Should a bean with @Specialize disable a bean even if it is disabled<br>
&gt;&gt;     itself?<br>
&gt;&gt;<br>
&gt;&gt;     On Thu, Nov 19, 2015 at 10:09 AM, Emily Jiang &lt;<br>
&gt;&gt;     <a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a> &lt;mailto:<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt; &gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     I have an application containing two wars.<br>
&gt;&gt;<br>
&gt;&gt;     testDiffBDA.war<br>
&gt;&gt;     testDiffBDA.war/WEB-INF/classes/test/diff/web/FrontEndServlet.class<br>
&gt;&gt;<br>
&gt;&gt;     @Inject CounterProducerConsumerModified2 bean;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     beans-xml-modified2.jar<br>
&gt;&gt;     containing one bean and an empty-ish beans.xml :<br>
&gt;&gt;     @Inject@CounterModifiedQualifier String modifiedProducer;<br>
&gt;&gt;<br>
&gt;&gt;     beans-xml-modified.jar.jar<br>
&gt;&gt;     CounterModifiedQualifier (the interface)<br>
&gt;&gt;     CounterProducerModified (the bean implementing that interface)<br>
&gt;&gt;     AlternativeCounterProducerModified (an alternative specialized bean)<br>
&gt;&gt;     beans.xml<br>
&gt;&gt;     &lt;alternatives&gt;<br>
&gt;&gt;<br>
&gt;&gt; &lt;class&gt;com.ibm.jcdi.test.beansxml.AlternativeCounterProducerModified&lt;/class&gt;<br>
&gt;&gt;     &lt;/alternatives&gt;<br>
&gt;&gt;<br>
&gt;&gt;     My application failed deployment with the error on Weld but worked<br>
&gt;&gt;     on OpenWebBeans<br>
&gt;&gt;<br>
&gt;&gt;     [ERROR ] CWWKZ0004E: An exception occurred while starting the<br>
&gt;&gt;     application testDiffBDA. The exception message was:<br>
&gt;&gt;     com.ibm.ws.container.service.state.StateChangeException:<br>
&gt;&gt;     org.jboss.weld.exceptions.DeploymentException: WELD-001408:<br>
&gt;&gt;     Unsatisfied dependencies for type String with qualifiers<br>
&gt;&gt;     @CounterModifiedQualifier<br>
&gt;&gt;     at injection point [BackedAnnotatedField] @Inject<br>
&gt;&gt;     @CounterModifiedQualifier<br>
&gt;&gt;<br>
&gt;&gt; com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer<br>
&gt;&gt;     at<br>
&gt;&gt;<br>
&gt;&gt; com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer(CounterProducerConsumerModified2.java:0)<br>
&gt;&gt;     --<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     After further investigation and talking to Martin from Weld, the<br>
&gt;&gt;     error was caused due to the fact of<br>
&gt;&gt;     AlternativeCounterProducerModified disabling the<br>
&gt;&gt;     CounterProducerModified bean but itself is not enabled in the jar of<br>
&gt;&gt;     beans-xml-modified2.jar. Therefore, no producer is active to produce<br>
&gt;&gt;     a bean with the qualifier CounterModifiedQualifier.<br>
&gt;&gt;<br>
&gt;&gt;      &gt;From Weld&#39;s perspective, any bean annotated with @Specialized<br>
&gt;&gt;     disables a second bean regardless whether itself is active or not.<br>
&gt;&gt;<br>
&gt;&gt;     My understanding is that the specialized should only take effect if<br>
&gt;&gt;     itself is enabled. Otherwise, we run into the situation of where the<br>
&gt;&gt;     specialized bean is not enabled but it disabled another bean. To me,<br>
&gt;&gt;     it is wrong.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     I also checked the spec:<br>
&gt;&gt;     @Alternative @Specializes<br>
&gt;&gt;     public class MockAsynchronousService extends AsynchronousService {<br>
&gt;&gt;     ...<br>
&gt;&gt;     }<br>
&gt;&gt;     When an enabled bean, as defined in Section 5.1.2, “Enabled and<br>
&gt;&gt;     disabled beans”, specializes<br>
&gt;&gt;     a second bean, we can be certain that the second bean is never<br>
&gt;&gt;     instantiated or called by the<br>
&gt;&gt;     container. Even if the second bean defines a producer or observer<br>
&gt;&gt;     method, the method will never<br>
&gt;&gt;     be called.<br>
&gt;&gt;<br>
&gt;&gt;     The spec says only an enabled bean can specialize a second bean. I<br>
&gt;&gt;     would like to know what other people think.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     Thanks<br>
&gt;&gt;     Emily<br>
&gt;&gt;     =================<br>
&gt;&gt;     Emily Jiang<br>
&gt;&gt;     <a href="mailto:ejiang@apache.org">ejiang@apache.org</a> &lt;mailto:<a href="mailto:ejiang@apache.org">ejiang@apache.org</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     --<br>
&gt;&gt;     Thanks<br>
&gt;&gt;     Emily<br>
&gt;&gt;     =================<br>
&gt;&gt;     Emily Jiang<br>
&gt;&gt;     <a href="mailto:ejiang@apache.org">ejiang@apache.org</a> &lt;mailto:<a href="mailto:ejiang@apache.org">ejiang@apache.org</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;     _______________________________________________<br>
&gt;&gt;     cdi-dev mailing list<br>
&gt;&gt;     <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;     <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt;     Note that for all code provided on this list, the provider licenses<br>
&gt;&gt;     the code under the Apache License, Version 2<br>
&gt;&gt;     (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other<br>
&gt;&gt;     ideas provided on this list, the provider waives all patent and<br>
&gt;&gt;     other intellectual property rights inherent in such information.<br>
&gt;&gt;<br>
&gt;&gt;     --<br>
&gt;&gt;     Tomas Remes<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;     _______________________________________________<br>
&gt;&gt;     cdi-dev mailing list<br>
&gt;&gt;     <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;     <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt;     Note that for all code provided on this list, the provider licenses<br>
&gt;&gt;     the code under the Apache License, Version 2<br>
&gt;&gt;     (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other<br>
&gt;&gt;     ideas provided on this list, the provider waives all patent and<br>
&gt;&gt;     other intellectual property rights inherent in such information.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Thanks<br>
&gt;&gt; Emily<br>
&gt;&gt; =================<br>
&gt;&gt; Emily Jiang<br>
&gt;&gt; <a href="mailto:ejiang@apache.org">ejiang@apache.org</a> &lt;mailto:<a href="mailto:ejiang@apache.org">ejiang@apache.org</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt; code under the Apache License, Version 2 (<br>
&gt;&gt; <a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). 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; Martin Kouba<br>
&gt; Software Engineer<br>
&gt; Red Hat, Czech Republic<br>
&gt;<br>
<br>
<br>
<br>
--<br>
Thanks<br>
Emily<br>
=================<br>
Emily Jiang<br>
<a href="mailto:ejiang@apache.org">ejiang@apache.org</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Thanks<br>Emily<br>=================<br>Emily Jiang<br><a href="mailto:ejiang@apache.org" target="_blank">ejiang@apache.org</a><br></div>
</div>