0% found this document useful (0 votes)
62 views4 pages

EJBEDITED

EJB is a standard for building server-side Java components called enterprise beans that can be deployed to an application server. Enterprise beans allow components to access databases, call legacy systems, and perform other business logic. There are three types of enterprise beans: session beans for business processes, entity beans for modeling persistent business data, and message-driven beans that are invoked when messages are received. Enterprise beans use distributed architecture with remote interfaces, stubs, skeletons, and EJB objects to allow clients to call components remotely or locally.

Uploaded by

Renuka Devi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views4 pages

EJBEDITED

EJB is a standard for building server-side Java components called enterprise beans that can be deployed to an application server. Enterprise beans allow components to access databases, call legacy systems, and perform other business logic. There are three types of enterprise beans: session beans for business processes, entity beans for modeling persistent business data, and message-driven beans that are invoked when messages are received. Enterprise beans use distributed architecture with remote interfaces, stubs, skeletons, and EJB objects to allow clients to call components remotely or locally.

Uploaded by

Renuka Devi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

 EJB is a standard for building server side component in java.

It defines a contract between the


component and application server that enables the component to run in any application server.
 EJB components (called as enterprise beans) are Deployable, imported, and loaded into an
application server, which host all these components.
Common Service includes: Transaction Management, Resource Management ,Connection pooling
Security ,Networking ,Persistant Management ,Concurrency ,Location transparency , Load Balancing
etc.
 Enterprise beans are intended for server side component development not for client side and So
it lies in Business Tier.
 EJB component can perform the following tasks:
 Perform business logic.
 Access to the database.
 E.g., Submitting an order for books.
 Enterprise bean can achieve database access using JDBC.
 Access another system.
 E.g., Calling some legacy system written in COBOL
EJB FUNDAMENTALS
Enterprise Beans
 An enterprise bean is a server side software component that can be deployed in a distributed
environment.
 It compose of one or more java objects.
 The client to an enterprise bean can be one of the following:
 A servlet
 An applet
 An enterprise bean (this results in chain of beans).
 Types of Beans:
 Session beans.
 Stateful session beans.
 Stateless session beans.
 Entity beans.
 Message Driven beans.
Session Beans
Session beans model business process.They are perform actions .Like, Adding numbers Accessing
database Unlike entity beans, they are non-persistent.
 Types: Stateful session beans. & Stateless session beans

Stateful Session Beans

 A stateful session bean maintains a conversational state


 The state is relevant only for a single client
 Cannot be seen by other clients
 The state is not persistent
 Expires after a certain timeout
 It has performance hit due to resource pooling.
 Canonical example: Shopping cart
Stateful Session Bean’s Lifecycle

Stateless Session Bean
 Conceptually, the same as stateful session beans.
 No need to save the conversational state, so called Stateless.
 Can have fields, but they are not unique to any client
 Since the container knows the bean has no state, it can:
 Use a single bean instance (While each client thinks it has its own copy)
 Destroy/re-instantiate on the fly
 Redirect requests to different instances (load balancing)
 Client does not care on which server the bean is stored
Example: Currency conversion bean
Stateful Session Bean’s Lifecycle

Entity Beans
 Entity beans model Business Data.
 Object-oriented view of entities stored in persistent storage
 Normally, each instance represents a row in a relational DB table
 Persistence code can be written manually (bean-managed persistence, BMP) or automatically
(container-managed persistence, CMP)
 A single bean instance (on the server) can be accessed by multiple clients Unlike stateful session
beans.
Message Driven Beans
 New in EJB 2.0 standard
 Built on top of JMS to send messages to clients, which in turn would be received by MDB.
 It is invoked by the container upon arrival of message at the destination that is serviced by the
message-driven bean.
 Have no client visibility,
Foundation of EJB
Distributed Architecture
 EJB components are based on Distributed Objects
 A distributed object is an object that is callable from a remote system.
 The client can be in-process, out-of-process or a client located elsewhere on the network.
 It does the invocation with the help of the followings:
 Stubs (client side proxy object):
 It masks the network communication from the client.
 It knows how to call over the network using the sockets, massaging parameters
as necessary into their network representation.
 Skeleton (server side proxy object):
 It masks the network communication from the distributed object.
 It understands how to receive calls on a network.
 Also knows how to massage parameters from the network representation to
their java representations.
It then delegates the call to the appropriate implementation object.
Enterprise Java Beans

 Enterprise Bean class:


 It contains the implementation of your business logic.
 It can be session or entity or MDB.
 Component Interface:
 Remote Interface:
 It is the java interface that enumerates the business methods of your bean class.
 Client code always go through the remote or local interface and never interacts
with the bean directly.
 It obeys the rules for java RMI-IIOP.
 Local Interface:
 It’s a high performing version of remote version.
 Used when you are calling the bean that presents in the same process.
 Unlike remote interface, it will not undergo stubs, skeleton,
marshaling/demarshaling of parameters.
 EJB object:
 It is container generated implementations of the remote interface.
 All client invoications go through this.It delegates the call to bean and implements the
remote interface
 Local home object:
 High performing version of home object.
 Implements the local home interface.
 Home interface:
 Java interface, acts as a EJB factory.
 Provides a handle of bean class to client
 Local Home interface:
 High version of Home interface.
 Home object:
 Container generated implementation of home interface.
 Obeys RMI-IIOP rules.
 Local home object:
 High performing version of home object.
 Implements the local home interface.
 Deployment Descriptor:
 An XML file, specifies the middleware requirements of your bean to the container.
 Vendor specific files:
 Enables you to take the advantage of vendor specific features
 EJB-jar file:
 A complete zip of the above said files.
 Given to the application server.
 Application server unpacks the jar file and loads the bean into the container.

You might also like