What is the life cycle of Stateful session bean

Showing Answers 1 - 2 of 2 Answers

John

  • May 3rd, 2005
 

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().  

pradeep.gt

  • Jul 24th, 2005
 

1. doesnot exsist 
2. exsists 
3. passivate 
 
invoke ejbcreate() 
set the sessioncontext() 
call create() 
 
if the session idle call ejbPassivate() 
to get back to session call ejbActivate() 
 
to end the session call ejbRemove() 
then call remove() 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions