This chapter is for the Enterprise Bean provider; that is, the person in charge of developing the soft-
ware components on the server side.
12.1. Introduction
The Enterprise Bean environment is a mechanism that allows customization of the Enterprise Bean's
business logic during assembly or deployment. The environment is a way for a bean to refer to a
value, to a resource, or to another component so that the code will be independent of the actual
referred object. The actual value of such environment references (or variables) is set at deployment
time, according to what is contained in the deployment descriptor. The Enterprise Bean's environment
allows the Enterprise Bean to be customized without the need to access or change the Enterprise
Bean's source code.
The Enterprise Bean environment is provided by the container (that is, the JOnAS server) to the bean
through the JNDI interface as a JNDI context. The bean code accesses the environment using JNDI
with names starting with
12.2. Environment Entries
The bean provider declares all the bean environment entries in the deployment descriptor via the
element. The deployer can set or modify the values of the environment entries.
env-entry
A bean accesses its environment entries with a code similar to the following:
InitialContext ictx = new InitialContext();
Context myenv = ictx.lookup("java:comp/env");
Integer min = (Integer) myenv.lookup("minvalue");
Integer max = (Integer) myenv.lookup("maxvalue");
In the standard deployment descriptor, the declaration of these variables are as follows:
env-entry
env-entry-name minvalue /env-entry-name
env-entry-type java.lang.Integer /env-entry-type
env-entry-value 12 /env-entry-value
/env-entry
env-entry
env-entry-name maxvalue /env-entry-name
env-entry-type java.lang.Integer /env-entry-type
env-entry-value 120 /env-entry-value
/env-entry
12.3. Resource References
The resource references are another examples of environment entries. For such entries, using subcon-
texts is recommended:
•
java:comp/env/jdbc
•
java:comp/env/jms
Enterprise Bean Environment
.
java:comp/env/
for references to DataSources objects.
for references to JMS connection factories.
Chapter 12.
Need help?
Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?
Questions and answers