|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
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> sub-element, the type is defined in the <env-entry-type> sub-element, and the value is defined in the <env-entry-value> sub-element. The <env-entry-name> is relative to the "java:comp/env" context.
Example 19-13 shows how to define environment variables for java:comp/env/minBalance and java:comp/env/maxCreditBalance in the ejb-jar.xml file.
Example 19-13 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-5 shows how the minBalance environment variable value is overridden by the orion-ejb-jar.xml file and set to 500.
Figure 19-5 Overriding Environment Variables in ejb-jar.xml with orion-ejb-jar.xml
For more information on looking up environment variables, see: