my project builds a war. In the war there is a jar A which provides the implementation I1 of interface I. I1 is injected in a JSF controller. There is an optional jar B which provides another implementation I2 of interface I. I2 has an higher priority than I1. Is there a possibilty to achieve when jar B is present in the war I2 is injected. I tried it with @Alternative on I2 with an entry in beans.xml as alternative in jar B without success. I1 is injected. Something like a priority would be necessary. Or probably I am on a wrong way and there's another one that fits for my use case?
Unfortunately it does not working. I am using jboss AS 7.
- ear contains war
- the war contains the beans.xml (with alternative entry) in WEB-INF
- jar B is located in war in WEB-INF/lib (jar B contains also beans.xml in META-INF)
- injection point is in a JSF controller (jar in WEB-INF/lib in war)
Always I1 is injected. But I do not know if I explained it clearly. I1 is always present. I2 is optional but shall have a higher priority.
Did you fix it? If not can you explain more about how the deployment is done. How do you decide to include the alternative or not not? Did you confirm that all your beans in the alternative jar have @Alternative annotations?