Sunday, April 14, 2013

Environment configuration property injection using Java CDI

In Spring Framework, injecting environment properties is made simple using the context:property-placeholder to configure property file locations and the @Value("#{propKey}") annotation to specify the key of the property.

Java CDI does not have an equivalent out-of-the-box, but it's flexible and rolling your own is easy using a single qualifier and a producer method.