Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring an Environment Reference to an Environment Variable

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

Description of Figure 19-5  follows
Description of "Figure 19-5 Overriding Environment Variables in ejb-jar.xml with orion-ejb-jar.xml"

For more information on looking up environment variables, see:

"Looking Up an EJB 3.0 Environment Variable"

"Looking Up an EJB 2.1 Enviornment Variable"