Search code examples
jakarta-eejbosscdi

Enabling CDI Alternative based on environmental properties


I know that it is possible to configure Alternatives in the "beans.xml" file that is embedded in the EAR to be deployed.

The problem is that I use the same EAR for all the environments, and the set of properties or specific configurations are stored in some folder outside the package.

I need to configure the Alternative that I will use based on an "external beans.xml" or some similar mechanism (something that is outside the EAR).

Any ideas?

Thank you very much.


Solution

  • You can't use alternatives if properties are outside the package. You can write a CDI producer that read the properties and with BeanManager return the write implementation.