<div dir="ltr"><div><div><div><div><div>Thank you Tom and Matej for your response!<br></div>The alternative was enabled in the archive beans-xml-modified.jar, but it is not enabled in the archive beans-xml-modified2.jar. The issue is not with alternative but with Specialized. <br><br></div>At the moment, Weld specialized is effective even if itself is not enabled, which is not desirable because it disables other bean but itself is not enabled. As a consequence, this causes deployment error. <br><br></div>The CDI 1.2 section 4.3  spec says:<br>When an enabled bean, as defined in Section 5.1.2, “Enabled and disabled beans”, specializes<br>a second bean, we can be certain that the second bean is never instantiated or called by the<br>container. Even if the second bean defines a producer or observer method, the method will never<br>be called.<br><br></div>It is true the above sentence comments about an enabled bean. It hits an disabled bean should not specialize a second bean. If you guys think it is unclear, can we update the spec to clarify this scenario?<br><br></div>By the way, OWB and Weld behave differently (Weld thinks a disabled bean still specializes a second bean while OWB thinks a disabled bean does NOT specialize a second bean). This is something we can leave to implementation. We should spec it!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 23, 2015 at 8:45 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">Hello Emily<br>
<br>
I agree with Tom. In your case, specialized producer is enabled (via beans.xml) although only per bean archive.<br>
<br>
<br>
And about this:<br>
<span class="">&gt;&gt;From Weld&#39;s perspective, any bean annotated with @Specialized disables a second bean regardless whether itself is active or not.<br>
<br>
</span>It is true, however the spec doesn&#39;t define how does a @Specialized bean behave when it is disabled (or at least I haven&#39;t found that bit).<br>
So this leaves it up to implementation and I can&#39;t really see a problem with it. Why would you create a @Specialized bean and disable it afterwards (with no other @Specialized and/or @Alternative active)?<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Matej<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
From: &quot;Tomas Remes&quot; &lt;<a href="mailto:tremes@redhat.com">tremes@redhat.com</a>&gt;<br>
To: &quot;Emily Jiang&quot; &lt;<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt;<br>
Cc: &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 8:33:44 AM<br>
Subject: Re: [cdi-dev] Clarification on 4.3 Specialization<br>
<br>
<br>
Hi Emily,<br>
<br>
I am not sure I follow. What is disabled? AlternativeCounterProducerModified? I can see AlternativeCounterProducerModified is enabled in beans.xml of the given bean archive and it means it is selected alternative only per the bean archive. So I can&#39;t see any problem (or maybe I don&#39;t fully understand).<br>
<br>
Tom<br>
<br>
----- Original Message -----<br>
From: &quot;Emily Jiang&quot; &lt;<a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a>&gt;<br>
To: &quot;cdi-dev&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Sent: Sunday, November 22, 2015 10:42:29 PM<br>
Subject: Re: [cdi-dev] Clarification on 4.3 Specialization<br>
<br>
any thoughts?<br>
<br>
Should a bean with @Specialize disable a bean even if it is disabled itself?<br>
<br>
On Thu, Nov 19, 2015 at 10:09 AM, Emily Jiang &lt; <a href="mailto:emijiang6@googlemail.com">emijiang6@googlemail.com</a> &gt; wrote:<br>
<br>
<br>
<br>
<br>
I have an application containing two wars.<br>
<br>
testDiffBDA.war<br>
testDiffBDA.war/WEB-INF/classes/test/diff/web/FrontEndServlet.class<br>
<br>
@Inject CounterProducerConsumerModified2 bean;<br>
<br>
<br>
beans-xml-modified2.jar<br>
containing one bean and an empty-ish beans.xml :<br>
@Inject@CounterModifiedQualifier String modifiedProducer;<br>
<br>
beans-xml-modified.jar.jar<br>
CounterModifiedQualifier (the interface)<br>
CounterProducerModified (the bean implementing that interface)<br>
AlternativeCounterProducerModified (an alternative specialized bean)<br>
beans.xml<br>
&lt;alternatives&gt;<br>
&lt;class&gt;com.ibm.jcdi.test.beansxml.AlternativeCounterProducerModified&lt;/class&gt;<br>
&lt;/alternatives&gt;<br>
<br>
My application failed deployment with the error on Weld but worked on OpenWebBeans<br>
<br>
[ERROR ] CWWKZ0004E: An exception occurred while starting the application testDiffBDA. The exception message was: com.ibm.ws.container.service.state.StateChangeException: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @CounterModifiedQualifier<br>
at injection point [BackedAnnotatedField] @Inject @CounterModifiedQualifier com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer<br>
at com.ibm.jcdi.test.beansxml.CounterProducerConsumerModified2.modifiedProducer(CounterProducerConsumerModified2.java:0)<br>
--<br>
<br>
<br>
After further investigation and talking to Martin from Weld, the error was caused due to the fact of AlternativeCounterProducerModified disabling the CounterProducerModified bean but itself is not enabled in the jar of beans-xml-modified2.jar. Therefore, no producer is active to produce a bean with the qualifier CounterModifiedQualifier.<br>
<br>
>From Weld&#39;s perspective, any bean annotated with @Specialized disables a second bean regardless whether itself is active or not.<br>
<br>
My understanding is that the specialized should only take effect if itself is enabled. Otherwise, we run into the situation of where the specialized bean is not enabled but it disabled another bean. To me, it is wrong.<br>
<br>
<br>
I also checked the spec:<br>
@Alternative @Specializes<br>
public class MockAsynchronousService extends AsynchronousService {<br>
...<br>
}<br>
When an enabled bean, as defined in Section 5.1.2, “Enabled and disabled beans”, specializes<br>
a second bean, we can be certain that the second bean is never instantiated or called by the<br>
container. Even if the second bean defines a producer or observer method, the method will never<br>
be called.<br>
<br>
The spec says only an enabled bean can specialize a second bean. I would like to know what other people think.<br>
<br>
<br>
Thanks<br>
Emily<br>
=================<br>
Emily Jiang<br>
<a href="mailto:ejiang@apache.org">ejiang@apache.org</a><br>
<br>
<br>
<br>
--<br>
Thanks<br>
Emily<br>
=================<br>
Emily Jiang<br>
<a href="mailto:ejiang@apache.org">ejiang@apache.org</a><br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<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 provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
--<br>
Tomas Remes<br>
<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<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 provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<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>