EJB Introduction
Program. Restrictions
Stateless Session Bean
Stateless ...(Example-1)
Stateful Session Bean
Stateful ... (Example-2)
Entity Beans
BMP Entity Beans
Config. DB (Example-3)
BMP (Example-4)
Bookmark This Site
|
Creating Stateless Session Beans
Introduction
|
A stateless session bean does not maintain a conversational state for the client. When a client invokes the method of a stateless bean, the bean’s instance variables may contain a state, but only for the duration of the invocation. When the method is finished, the state is no longer retained. Except during method invocation, all instances of a stateless bean are equivalent, allowing the EJB container to assign an instance to any client.
- Types of Enterprise Beans are
-
- Session Beans
- Stateless Session Beans
- Stateful Session Beans
- Entity Beans
- Bean Managed Persistent (BMP) Entity Beans
- Container Managed Persistent (CMP) Entity Beans
- Message-Driven Bean
|
|
Life Cycle of a Stateless Session Bean
|
- A stateless session bean life cycle consists of two stages:
-
Ready Stage
-
Does Not Exist Stage
The following figure shows the stages of a stateless session bean’s life cycle:
|
Ready Stage
|
- At the beginning of its life cycle, a stateless session bean is in the Ready stage.
-
To create a new stateless session bean instance, EJB container performs the following steps:
-
Invokes the newInstance() method, which creates a new stateless session bean instance by calling the stateless session bean’s default constructor.
-
Invokes the setSessionContext() method to associate the bean’s instance with information about the environment in which bean instance will execute.
-
Invokes the ejbCreate() method defined in the stateless session bean class. The ejbCreate() method for a stateless session bean contains no arguments because a stateless session bean does not store client-specific information.
|
Does Not Exist Stage
|
- At the end of its life cycle, a stateless session bean is in the Does Not Exist stage.
-
In this stage, a stateless session bean is permanently removed from the shared pool.
|
|
Click Next To Continue ...
|
|
|