| Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
You can create environment variables that your bean accesses through a JNDI lookup on the InitialContext. These variables are defined within an ejb-jar.xml file <env-entry> element and can be of the following types: String, Integer, Boolean, Double, Byte, Short, Long, and Float. The environment variable name is defined in the <env-entry-name> subelement, the type is defined in the <env-entry-type> subelement, and the value is defined in the <env-entry-value> subelement. The <env-entry-name> is relative to the "java:comp/env" context.
Example 19-17 shows how to define environment variables for java:comp/env/minBalance and java:comp/env/maxCreditBalance in the ejb-jar.xml file.
Example 19-17 ejb-jar.xml For Environment Variables
<env-entry>
<env-entry-name>minBalance</env-entry-name>
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>500</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>maxCreditBalance</env-entry-name>
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>10000</env-entry-value>
</env-entry>
You can override an environment variable value defined in the ejb-jar.xml file by defining an env-entry-mapping element in your orion-ejb-jar.xml file, whose name attribute matches the env-entry-name defined in the ejb-jar.xml file. The type specified in the ejb-jar.xml file stays the same.
Figure 19-7 shows how the minBalance environment variable value is overridden by the orion-ejb-jar.xml file and set to 500.
Figure 19-7 Overriding Environment Variables in ejb-jar.xml with orion-ejb-jar.xml

For more information on looking up environment variables, see the following: