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's @Produces method will get called, instead of injecting Bar?
Found it - you can just specify the whole producer class as an alternative.
@Alternative
public class AltProducer { ... }
beans.xml:
<beans>
<alternatives>
<class>com.package.AltProducer</class>
</alternatives>
</beans>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With