Tuesday, 19 April 2016

What is the life cycle of Stateful session bean ?


A Stateful Session Bean has three states.
Does not exists, Method Ready and Passivated states.

Like Stateless beans, when the Stateful Session Bean hasnt been instantiated yet (so it is not an instance in memory) is it in the Does not exists state.
Once a container creates one or more instances of a Stateful Session Bean it sets them in a Method Ready state. In this state it can serve requests from its clients.
Like Stateless Session beans, a new instance is created [ Class.newInstance() ], the context is passed [ setSessionContext() ] and finally the bean is created with ejbCreate().

During the life of a Stateful Session bean, there are periods of inactivity.
In these periods, the container can set the bean to the Passivate state. This happens through the ejbPassivate() method.
From the Passivate state the bean can be moved back to the Method Ready state, via ejbActivate() method, or can go directly to the Does Not Exists state with ejbRemove().

No comments:

Post a Comment

Note: only a member of this blog may post a comment.