Chapter 12.
Enterprise Bean Environment
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
java:comp/env/
.
12.2. Environment Entries
The bean provider declares all the bean environment entries in the deployment descriptor via the
env-entry
element. The deployer can set or modify the values of the environment entries.
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
for references to DataSources objects.
•
java:comp/env/jms
for references to JMS connection factories.
Summary of Contents for Application Server
Page 1: ...Red Hat Application Server JOnAS User Guide ...
Page 8: ......
Page 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Page 58: ...50 Chapter 3 JOnAS Configuration ...
Page 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Page 78: ...70 Chapter 6 JOnAS Command Reference ...
Page 80: ......
Page 86: ...78 Chapter 7 Developing Session Beans ...
Page 136: ...128 Chapter 9 Developing Message Driven Beans ...
Page 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Page 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Page 158: ...150 Chapter 14 EJB Packaging ...
Page 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Page 164: ......
Page 176: ...168 Chapter 18 WAR Packaging ...
Page 178: ......
Page 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Page 186: ...178 Chapter 21 Client Packaging ...
Page 188: ......
Page 192: ...184 Chapter 23 EAR Packaging ...
Page 194: ......
Page 200: ...192 Chapter 24 JOnAS Services ...
Page 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Page 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Page 234: ...226 Chapter 29 Web Services with JOnAS ...
Page 236: ......
Page 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Page 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Page 296: ......