CDI-1.0 _has_ a concept of vetoing. Simply annotate Foo with @Typed()
LieGrue, strub ----- Original Message ----- > From: John D. Ament <[email protected]> > To: [email protected] > Cc: > Sent: Sunday, 19 May 2013, 4:37 > Subject: Re: [OWB] CDI - how to realize default producer? > >T he easiest way is to actually put a qualifier on the class itself, and > then never inject based on that qualifier. CDI 1.0 has no concept of a > veto'd bean, but you could write an extension yourself that veto'd your > class. > > Extensions exist out there, I believe CODI has one and Seam3 has one. > Seam3 uses @Veto to mark these beans as veto'd. > > > On Sat, May 18, 2013 at 6:48 PM, Reinis Vicups <[email protected]> wrote: > >> Hi, >> >> I'd like to use a producer method in ALL CASES when @Injecting a >> particular bean. >> >> It looks like this: >> >> public class FooProducer { >> >> @Produces >> public Foo produceFoo() { >> Foo foo = new Foo(); >> return foo; >> } >> } >> >> public class Foo {} >> >> With this example I get: >> >> SEVERE - CDI Beans module deployment failed >> javax.enterprise.inject.**AmbiguousResolutionException: Ambiguous >> resolution >> found beans: >> Foo, Name:null, WebBeans Type:MANAGED, API > Types:[....Foo,java.lang.**Object], >> Qualifiers:[javax.enterprise.**inject.Any,javax.enterprise.** >> inject.Default] >> Foo, Name:null, WebBeans Type:PRODUCERMETHOD, API Types:[....Foo,java.lang. >> **Object], Qualifiers:[javax.enterprise.**inject.Any,javax.enterprise.** >> inject.Default] >> >> I tried applying @Default with no success. >> >> And I don't want to make specific @Qualifier annotation, because this > is >> unnecessary in my case and will cause errors in those cases when I forget >> to provide that @Qualifier at injection point. >> >> If anyone could help me with setting up a correct way to provide default >> producer, would be great. >> >> thanks and kind regards >> Reinis >> >
