SET AS HOME PAGE

ADD TO FAVORITES / BOOKMARK THIS WEBSITE (More Details)

Introduction

Servlet

Jsp

Security

Enterprise Beans

Contact Us


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
    1.  Stateless Session Beans
    2. Stateful Session Beans
  • Entity Beans
    1. Bean Managed Persistent (BMP) Entity Beans
    2. 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:
    1. Invokes the newInstance() method, which creates a new stateless session bean instance by calling the stateless session beanís default constructor.
    2. Invokes the setSessionContext() method to associate the beanís instance with information about the environment in which bean instance will execute.
    3. 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 ...
<- PREVIOUSNEXT ->