What is stateless session bean ? Explain Life Cycle?

Stateless session beans are of equal value for all instances of the bean. This means the container can assign any bean to any client, making it very scalable.
A stateless session bean is an enterprise bean that provides a stateless service to the client. 
Conceptually, the business methods on a stateless session bean are similar to procedural applications or static methods; there is no instance state, so all the data needed to execute the method is provided by the method arguments. The stateless session bean is an EJB component that implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute “stateless”. 
Stateless session beans are called “stateless” because they do not maintain conversational state specific to a client session. In other words, the instance fields in a stateless session bean do not maintain data relative to a client session. This makes stateless session beans very lightweight and fast, but also limits their behavior. Typically an application requires less number of stateless beans compared to stateful beans.
 Stateless Session Bean Life Cycle
Stateless session beans have a simple lifecycle and the Container performs the following:
  • Creates bean instances using the default constructor as needed
  • Injects resources such as database connections
  • Puts instances into a managed pool
  • Pulls an idle bean from the pool when an invocation request is received from the client
  • Executes the requested business method invoked through the business interface by the client
  • When the business method finishes executing, pushes the bean back into the "method-ready" pool
  • As needed retires (destroys) beans from the pool based on pool sizes  



Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email