Information Technology Reference
In-Depth Information
In contrast with the client EJB programming model which is concerned with Home
and EJB interfaces , the developer EJB programming model is concerned with inte-
grating EJB implementations into an EJB container. A stateless session bean method
implementation is analogous to a procedure call implementation. An entity bean
method implementation manipulates an abstract persistence schema to implement
the component's API. The notion of an abstract persistence schema is important
because it allows developers to delegate the management of a bean's state to the
container. Developers are concerned only with virtual persistence fields and rela-
tionships, so that container-supplied tools are free to implement this state indepen-
dently of the developer. EJB containers automatically provide EJBs with common
requirements of business applications such as persistence, concurrency, transac-
tional integrity, and security. Standardized life-cycle methods such as ejbCreate ,
ejbActivate , and ejbStore , are “hooks” for developers to interact with the
hosting container in well-defined ways. The distinction between “local” and “re-
mote” interfaces is another architected interaction between developers and a con-
tainer. Using a local interface allows beans that are deployed within a single container
to communicate efficiently by eliminating the overhead associated with a RMI call
(because the beans are instantiated in the same address space). The remote inter-
face is required only when remote (i.e., resident in a different address-space) clients
interact with the EJB. Bean developers can thus focus on the business logic of the
application; when deployed to an EJB container, the components are embedded in
an infrastructure that automatically supplies the business component requirements.
We implemented order entry using EJBs to facilitate a comparison to the SDO
client-side programming model.
Sample 8 shows how an Agent is created from its Home. In contrast to SDOs,
agent instances are not contained within an encapsulating “OrderEntry” graph, but
rather are contained within their own Home. Also, entity EJBs are required to define
a primary key, because it is needed in order to support single-level store (see Sec-
tion 4.3 ). For Agent, there is a UUID [42] defined by the abstract persistence schema
for use as the primary key. The UUID must be provided at entity creation time, and
is immutable. In contrast, although the Agent SDO defines an Id (see Sample 3 ), it
final javax.naming.Context context = new javax.naming.InitialContext();
final AgentHome agentHome = (AgentHome) context.lookup("Agent Home");
final String
uuid = UUID.generate();
final Agent
agent = agentHome.create(uuid);
S AMPLE 8. Creating an Agent EJB.
Search WWH ::




Custom Search