Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (

Part Number E13981-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

Looking Up an EJB 2.1 Enviornment Variable

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".

Using Initial Context

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".