A stateless session bean is a session bean with no conversational state. All instances of a particular stateless session bean class are identical. A stateless session bean and its client do not share state or identity between method invocations. A stateless session bean is strictly a single invocation bean.
What is stateless session bean?
“Stateless session beans are session beans whose instances have no conversational state. This means that all bean instances are equivalent when they are not involved in servicing a client-invoked method. The term ‘stateless’ signifies that an instance has no state for a specific client.”
What is the difference between stateless and stateful session bean?
Stateful: A stateful session bean maintains client-specific session information, or conversational state, across multiple method calls and transactions. Stateless: A stateless session bean does not maintain conversational state. Instances of a stateless session bean have no conversational state.
What is the lifecycle of session bean stateless session bean is instantiated by?
When an instance transitions from the Does Not Exist state to the Method-Ready Pool, three operations are performed on it. First, the bean instance is instantiated by invoking the Class. newInstance() method on the stateless bean class.
What are stateful and stateless sessions?
Stateless session beans do not maintain state associated with any client. Each stateless session bean can server multiple clients. Stateful session beans maintain the state associated with a client. Therefore, any available instance of a stateless session bean can be used to service another client.
What is the life cycle of a stateless session bean?
The following figure shows the life cycle of a stateless session bean. A stateless session bean has two states: Does not exist. In this state, the bean instance simply does not exist. Ready state. When WebLogic Server is first started, several bean instances are created and placed in the Ready pool.
What are the states of Stateless Session Bean in EJB container?
There is only two states of stateless session bean: does not exist and ready. It is explained by the figure given below. EJB Container creates and maintains a pool of session bean first. It injects the dependency if then calls the @PostConstruct method if any. Now actual business logic method is invoked by the client.
When is a session bean instance ready for garbage collection?
Once execution has finished, the session bean instance is ready to execute another business method. When the EJB container decides to reduce the number of session bean instances in the ready pool, it makes the bean instance ready for garbage collection.
What happens when you remove a session bean from the pool?
For a stateless session bean, calling the remove method invalidates the reference to the bean instance already in the ready pool, but it does not move a bean instance from the ready to the does not exist state, as the management of stateless session bean instances is fully done by the EJB container.