EJB 3.0 Tutorial
Through this section you will learn the various aspects of EJB like what is an
Enterprise Bean, what is EJB container, benefits of Enterprise Beans, when to
use Enterprise Beans, types of Enterprise Beans.
What is Enterprise Beans
A Java EE component is called an Enterprise Beans which implements the EJB
technology and runs inside an EJB container. Enterprise Beans are the server
side component where the application's business logic is encapsulated. The
business logic can be explained as, it is line of statement called code which is
written for completing the requirements of application.
What is EJB Container
EJB container is a specification within the Application Server that runs the
Enterprise Beans. Services provided by the EJB container is System-level
services. In such type of services it provides the transaction and security to
its enterprise beans. In addition they also provides for the Resource and life
cycle management, remote accessibility, concurrency control, collision etc.
Benefits of Enterprise Beans
Generally, Enterprise beans is used for creating large, distributed
applications. This is because of various reasons these are as follows :
- The first reason is the services that are provided by the EJB container to
enterprise beans i.e. System-level services that helps the developer to focus on
solving the business problems.
- The second reason is elaborated from first reason that the bean is
responsible for application's business logic not for the client. So, a client
developer can focus on only its presentation.
- The third reason is enterprise bean's portability feature i.e. the
enterprise beans components can be easily or conveniently portable.
When to use Enterprise Beans
Enterprise Beans should be used in any of the following requirements that an
application is required :
- Must be Scalable : The application must be scalable i.e. if users of your
application is increasing and you may need to distribute applications components
on multiple machines.
- Data Integrity : The application must have to ensure the data integrity
- The client of the application is of different kinds.
Types of Enterprise Beans
Commonly the Enterprise Beans is of two types :
- Session Bean : Session Bean implies that there is a single
client inside the Application Server. Session Bean is responsible for doing
tasks for a client that calls the session bean's methods of an application
deployed on server. Session beans executes the business process within the
server that protects the client from complicating the situation. A session bean
is like an interactive session that can't be shared. A session bean is not
persistent, it terminates with the client terminates. Session bean is of two
types : Stateful Session Beans, Stateless Session Beans.
- Message-Driven Bean : Message-Driven Bean permits the Java
Enterprise Edition applications for processing messages asynchronously.
Message-Driven beans likewise the JMS message listener, that receives the JMS
messages rather than events.
You may read in detail about EJB 3.0 from here