smartics-properties-integration-cdi is an extension of smartics-properties to support cdi injection. Right now only weld is supported.
If you want to define properties, please refer to smartics-properties-config .
Having the properties declared and defined you can - using this extension - inject them using cdi.
<dependency> <groupId>de.smartics.properties</groupId> <artifactId>smartics-properties-integration-cdi</artifactId> <version>${project.version}</version> </dependency>
Implementation-Vendor-Id: ${project.groupId} Implementation-Title: ${project.artifactId} Implementation-Version: ${project.version}
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.3.2</version> <configuration> ... ... <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> </manifest> </archive> </configuration> </plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.3.2</version> <configuration> ... ... <archive> <manifestEntries> <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id> <Implementation-Title>${project.artifactId}</Implementation-Title> <Implementation-Version>${project.version}</Implementation-Version> </manifestEntries> </archive> </configuration> </plugin>
e.g. (windows): set "JAVA_OPTS=%JAVA_OPTS% -Dproperties.environment.node=node1 -Dproperties.environment.name=production"
e.g. (linux): JAVA_OPTS="$JAVA_OPTS -Dproperties.environment.node=node2 -Dproperties.environment.name=preproduction"
package de.smartics.sandbox; import javax.ejb.Stateless; import javax.inject.Inject; import de.smartics.sandbox.ApplicationProperties; @Stateless public class SimplePropertiesService { @Inject private ApplicationProperties appProperties; /** * Do something. */ public void doSomething() { final String url = appProperties.url(); ... } }