Professional Documents
Culture Documents
R. Praveen.
What is EJB?
An EJB is just a collection of Java classes and XML file, bundled into a single unit. The Java classes must follow certain rules and provide certain callback methods. EJB is just a specification. It is not a product. EJBs are reusable components.
What is EJB?
EJB is a widely-adopted server-side component architecture for J2EE. EJB components are designed to encapsulate business logic, and to protect the application developer from having to worry about system level issues.
Contents
Services provided by EJB container Circumstances of EJB component usage How an EJB component looks like? View of an EJB component by client programmer and EJB developer Mechanisms by which EJB container provides its services Rules an EJB developer must follow and how to use EJBs in a web architecture?
EJB vs JavaBeans
The JavaBeans architecture is meant to provide a format for general-purpose components whereas the EJB architecture provides a format for encapsulation and management of business logic. JavaBeans has tier of execution at Client and EJB has at Server (specifically business logic tier)
EJB vs JavaBeans
In JavaBeans the runtime execution environment provides services like Java libraries, Java application etc. The EJB runtime environment provides services of Persistence, declarative transactions and security, connection pooling and lifecycle services.
Varieties of Beans
Session Beans Stateful session bean Stateless session bean Entity Beans With container-managed persistence With bean-managed persistence Message-Driven Beans
EJB Architecture
Client Application Logic J2EE Application Server
RDBMS
Data
Deployer
System Administrator
Services provided by an EJB container Persistence Ex: simple connection pooling, automatic persistence, etc. EJBs created with application development tools will encapsulate data access in components.
How the Container Provides Services Third, the container interposes on each and every call to an EJB component so that it can provide its services. In other words, the container puts itself between the client and the component on every single business method call.
Contracts
EJB Container/Application Server
Enterprise JavaBean
Client
Interposition diagram
Client
RMI Stub
Network
RMI Stub
EJB
Interposition class
EJB Clients
EJB Clients are applications that access EJB components in EJB containers. There are two possible types. The first category is application clients which are stand-alone applications accessing the EJB components using the RMI-IIOP protocol. The second category of application clients are components in the web container. They are java servlets and JSPs which also access the EJB components via the RMI-IIOP protocol.
EJBs interface
Home Interface : It is primarily for the life cycle operations of the bean: creating, finding, and removing EJBs. The home interface is not associated with a particular bean, just with a type of bean. Remote Interface : It is for business methods. Logically, it represents a particular bean on the server. The remote interface also provides some infrastructure methods associated with a bean instance, rather than a bean type.
Execute methods
Reference (Handle)
Remove bean
use Read/Write static fields use java.io package Load a native library use this as an Argument or Return value use Loopback Calls