Information Technology Reference
In-Depth Information
EJBs are container-managed components; that is, the container manages
their life cycle and, based on the configuration specified in the deployment
descriptor, interacts on behalf of the EJBs with various J2EE services.
The success of EJBs is based on a set of key concepts. First, EJBs are deployed
within a container hosted by an application server, rather than deploying
directly onto the application server. A container provides the environment
for execution of EJBs, management of their life cycle, and provisioning of
additional services. Second, EJBs take an approach based on proxy pattern
rather than a monolithic component, which effectively separates out the com-
ponent into client objects and remote objects. While the EJB user only sees
the client object represented by the EJB interfaces, the remote object is free to
change in terms of implementation details like location on the network and
underlying transport mechanism. Third, EJBs use the concept of deployment
descriptors that decouples the development from the deployment aspects.
There are three types of EJBs:
1. Entity Beans: Entity beans are EJBs designed specifically to repre-
sent data in a persistent store, which is typically a database. They
encapsulate persistent data in a data store, which is typically a row
or record of data in a database table. Apart from the built-in database
access and synchronization capabilities, entity beans automatically
provide the ability to share both state and behavior across multiple
clients concurrently, disaster recovery facilities, and so on.
An entity bean consists of a Home interface, a Remote interface, an
implementation class, and a primary key class. The Home interface
defines create, finder, remove, and home methods. The remote inter-
face defines business methods. It also has a primary key class that
contains methods for operating on the primary key for a single or a
compounded database table. The implementation class implements
all of the life cycle, finder, select, and business methods. Like all
EJBs, entity beans also make use of the deployment descriptor to
hold additional information pertaining to the component including
transaction settings on business methods, relationships with other
entity beans, and persistent filed settings.
2. Session Beans: Session beans are the most popular of the EJBs and
are used primarily to manage transactions or client sessions. In an
enterprise application, they are often used as the main controller con-
necting servlets or JSPs to entity beans or other components. Apart
from the built-in transaction management and state management
capabilities, EJB container also provides additional services such as
automated resource management, concurrency, and security.
These are used mainly for transient activities. They are nonpersis-
tent and often encapsulate bulk of the business logic. While state-
ful session beans retain client state between successive interactions
Search WWH ::




Custom Search