[cdi-dev] Question regarding producer methods and default no-arg constructor
Romain Manni-Bucau
rmannibucau at gmail.com
Fri Jan 2 12:17:26 EST 2015
Hi Michael,
1) yes if the bean is scanned as well
2) you can use @Alternative but using <scan />, @Vetoed, or @Typed()
for CDI 1.0 should work as well and are maybe less hacky since you'll
never activate this alternative right?
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2015-01-02 17:02 GMT+01:00 Michael Remijan <mjremijan at yahoo.com>:
> Greetings,
>
> I recently ran into a situation where I had created a producer method for an
> object but when Weld was starting up I got errors about something being
> ambiguous. I finally tracked the issue to the fact that the bean my
> producer method was responsible for producing only had a default no-arg
> constructor. I was able to "work around" this problem by annotating the
> bean as an @Alternative. So I have a few questions.
>
> (1)
> Is this expected behavior from CDI? If a bean only has the default no-arg
> constructor should you get an ambiguous error if you also have a producer
> method for the bean?
>
> (2)
> Is annotating the bean as an @Alternative an acceptable "work around"?
> Seems hackish to me. If not, what is the appropriate solution.
>
> Thanks!
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code
> under the Apache License, Version 2
> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other intellectual
> property rights inherent in such information.
More information about the cdi-dev
mailing list