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

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

Go to previous page
Previous
Go to next page
Next
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".