Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
Using EJB 2.1, you can look up an environment variable using the InitialContext
(see "Using Initial Context").
For more information on configuring enviornment variables, see "Configuring an Environment Reference to an Environment Variable".
Example 19-29 shows how you look up these environment variables within the bean's code using the InitialContext
.
Example 19-31 Looking Up Environment Variables
InitialContext ic = new InitialContext(); Integer min = (Integer) ic.lookup("java:comp/env/minBalance"); Integer max = (Integer) ic.lookup("java:comp/env/maxCreditBalance"));
Notice that to retrieve the values of the environment variables, you prefix each environment element with java:comp/env/
, which is the location that the container stored the environment variable.
For more information, see "Configuring the Initial Context Factory".