Escolar Documentos
Profissional Documentos
Cultura Documentos
Enterprise JavaBeans
Distributed Object
Architecture
Distributed Object
Architecture
6
5 Stub Skeleton Server
3 4
Remote Object
Registered
6.
1.
2.
3.
4.
5.
7. Stub
Server
Registry
Client
talks
requests
invokes
SkeletonCreates
Registers
returns
to skeleton
stub
invokesobject
Remote
from
method
remoteregistry
reference
object.method
object
object with RMI Registry Virtual Machine
registry interface
through
Java Naming and Directory
Interface
Java Naming and Directory Interface
provides the naming and directory
functionality to Java applications.
Provides a standard interface to
locate the components,
users,networks, and services placed
across the network.
Bridges the gap between directory
services and makes it possible for the
developer to write portable naming
The JNDI Architecture
Client
JNDI
Service Provider
Interface
Naming
Service
Enterprise Beans
Enterprise Bean
Stateful Stateles
Bean s Bean BMP CMP
Life Cycle of a Session
Bean
A session bean may last as long as the
client session.
Will not survive if the application
server changes or crashes.
They are objects which are present in-
memory which die along with the
surrounding environment and are not
persisted in a database.
Stateless Session Beans
Provide a single use service.
They do not maintain state in class
level variables. they are called as
"Stateless“.
Since they do not have any states,
they need not be passivated.
They are fastest and most
efficient.
Life Cycle of Stateless
Session Bean
Stateful Session Beans
They do maintain state in class
level variables.
They need to handle Activation
and Passivation
Each client is provided a different
and specific Stateful Session bean.
they can be persisted, they are
also called Persistent Session
Beans
Life Cycle of Stateful
Session Bean
Entity Bean
They are a representation of
persistent data.
They can survive a crash.
Has a Primary key like in a
Database record.
Bean-Managed Persistence
Entity Beans (BMP)
BMP bean's persistence has to be
managed by the EJB itself.
It gives more control to the EJB
developer to save and retrieve
data.
Use of BMP beans would be to
retrieve and save data from non-
database data sources like XML
files, JMS resources etc.
Life Cycle of BMP Entity
Bean
Container-Managed
Persistence Entity Beans
CMP bean's persistence is managed by
the EJB container.
the EJB container is responsible for
saving the Bean's state.
The container-managed fields need to
be specified in the Deployment
Descriptor and the persistence is
automatically handled by the container.
CMP beans are easier to develop and
work well with database access.
Life Cycle of CMP Entity
Bean
BMP vs CMP
CMP is more
BMP offers a
strategic
tactical approach. Vendor takes care
The developer of everything by
takes care of using O-R or OODB
handling mappings using
persistence. metadata.
BMP uses hard
A developer cannot
optimize
coded queries so
performance as the
we can optimize vendor takes care
Message-Driven Beans
Allows JMS applications to receive messages
asynchronously (the sender is independent of
the receiver receiving and processing the
messages).
Includes business logic, which may include
operations such as:
* Performing computation on received data
* Initiating a step or condition in a workflow
* Storing data
* Sending a message
Uses of Message-Driven
Beans
Asynchronous messaging.
Integrating two applications in a
loosely coupled but reliable
manner.
Mere message delivery or message
content should drive other events
in the system.
Create message selectors which
are designed to consume only