What is the Life Cycle of Session bean ?

Showing Answers 1 - 5 of 5 Answers

Preeti

  • May 17th, 2005
 

The session bean passes from the steps during its life time are: 
 
The client initiate the life cylcle by invoking the create() method. 
The EJB container instantiates the bean and then invokes the setSessionContext and ejbCreate methods. 
The bean is now ready to have its business methods invoked. 
 
while in the ready state the EJB container decide to deactivate or passivate the bean by moving it from memory to secondary storage, it invokes ejbPassivate method immediately, and when the container activates the bean then calls the beans ejbActivate methods 
At the end of life cycle client invokes remove method and calls the bean ejbRemove method

  Was this answer useful?  Yes

Shashidhar Mahavadi

  • Jun 6th, 2005
 

I suppose the question should be more specific, since the life cycle will be different for both stateless and stateful session beans...

  Was this answer useful?  Yes

Anita

  • Jul 28th, 2006
 

Life Cycle of Session Bean is:

public void Create()

 public void  ejbActivate () 

public void  ejbPassivate () 

public void  remove () 

public void  setSessionContext ( SessionContext  cxt)                                                                                                              

  Was this answer useful?  Yes

First setSessionContext() will be called followed by ejbCreate().ejbRemove() will be called when the ejb container removes bean instance from the pool -- This is in case of stateless session bean.
In case of stateful session beans also, setSessionContext() will be called followed by ejbCreate().  It will call ejbPassivate() before passivation. When it is in passivated state, if any request comes then it will call ejbActivate() and moves toready state...will be called when the ejb container removes bean instance from the pool

  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