How to specify @Alternative producer method in beans.xml?

Say I have:

public interface Foo {...} public class AltProducer { private Foo altFoo; @Produces @Alternative public Foo getAltFoo() { return altFoo; } } 

What do I need to put in beans.xml so that my AltProducer @Produces method is called, instead of typing Bar?

+6
source share
1 answer

Found - you can simply specify the entire manufacturer class as an alternative.

 @Alternative public class AltProducer { ... } 

beans.xml:

 <beans> <alternatives> <class>com.package.AltProducer</class> </alternatives> </beans> 
+12
source

All Articles