-
1. Re: Changes in Weld 1.1.6
luksa Apr 2, 2012 10:59 AM (in response to s.hostettler)Yes, this is expected behavior. Please see https://issues.jboss.org/browse/WELD-930
-
2. Re: Changes in Weld 1.1.6
luksa Apr 2, 2012 2:08 PM (in response to luksa)Oh yes, the spec is a little inconsistent about alternatives and producer methods. I think this is being addressed in CDI 1.1. For now, you have to annotate both the producer method and the declaring bean with @Alternative.
-
3. Re: Changes in Weld 1.1.6
s.hostettler Apr 2, 2012 1:14 PM (in response to luksa)Hello Marko,
thanks for the answer, I do not really understand how the issue you mentionned relates to the problem.
Do you know, what did cost this new check to be implemented?
As there is a simple workaround it is not a big deal, just want to make sure that the issue does not get lost.
-
4. Re: Changes in Weld 1.1.6
luksa Apr 2, 2012 6:06 PM (in response to s.hostettler)Note Pete's comment in that jira issue:
This looks to me like a bug in Weld (one that crept in from a pre-final spec revision) - that it checks if the declaring bean class is an alternative, and if it is, makes the producer an alternative. Can you file a WELD issue for this? I'll update the quickstart to explicitly make the producer an alternative.
So, in 1.1.6, producer methods and fields are no longer treated as alternatives just because the bean they are declared in is annotated @Alternative. You have to explicitly mark the producer method/field with @Alternative for it to actually be an alternative.
However, in order to enable the alternative producer method, you have to list the method's *declaring bean* in beans.xml (you can't list the producer method itself). And as you've already pointed out, you can't declare a bean as an <alternative> in beans.xml unless the bean is annotated with @Alternative. Therefore, there is no other way than to annotate both the producer method and the declaring bean with @Alternative and then enabling the bean through <alternative> in beans.xml.
-
5. Re: Changes in Weld 1.1.6
s.hostettler Apr 3, 2012 3:49 AM (in response to luksa)Hello,
sorry I did not read the issue carefully enough. Thanks for the answer