Use Property Substitution to Specify the Target Deployment Environment
1. Enable Property Substitution in the Server Configuration File
The <spec-descriptor-property-replacement> element in the ee subsystem of the server configuration file is used to enable or disable property substitution in the ejb-jar.xml and persistence.xml descriptor files. The <jboss-descriptor-property-replacement> element in the ee subsystem of the server configuration file is used to enable or disable property substitution in the jboss-ejb3.xml, jboss-app.xml, jboss-web.xml, *-jms.xml, and *-ds.xml descriptor files. To enable property substitution it must be set to true. This is the default value. The following is an example of the ee subsystem element configured to enable property substitution.
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>
For more information about property substitution, see the
Administration and Configuration Guide for JBoss Enterprise Application Platform located on the Customer Portal.
2. Bind Strings for JNDI Runtime Mapping
For values outside deployment descriptors that change depending on the target environment, you can bind string values into JNDI and them map them into the application.
Assume the application's web.xml file contains the following resource reference:
<resource-env-ref>
<description>IP address of the destination</description>
<resource-env-ref-name>destination/ip-address</resource-env-ref-name>
<resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>
To bind simple strings into JNDI, create a <simple> element in the naming subsystem of the server configuration file. The following is an example of the naming subsystem element configured for JNDI substitution.
<subsystem xmlns="urn:jboss:domain:naming:1.1">
<bindings>
<simple name="java:/my/jndi/key" value="MyJndiValue"/>
</bindings>
</subsystem>
Add an entry to the application's jboss-web.xml to map the global JNDI entry to the application's java:comp/env/ Environment Naming Context (ENC). The <resource-env-ref-name> element value must match the value specified in the web.xml and the <jndi-name> element must match the <simple> element name in the server configuration file.
<jboss-web>
<resource-env-ref>
<resource-env-ref-name>destination/ip-address</resource-env-ref-name>
<jndi-name>java:/my/jndi/key</jndi-name>
</resource-env-ref>
</jboss-web>
Follow the same procedure to implement property substitution for other descriptor files.
For more information about how to manage the server configuration files, see the Administration and Configuration Guide for JBoss Enterprise Application Platform located on the Customer Portal.