Explain Stateful session bean life cycle?

Answer Posted / hari

Life Cycle of a Stateful Session Bean

While in the ready stage, the EJB container may decide to deactivate, or passivate, the bean by moving it from memory to secondary storage. (Typically, the EJB container uses a least-recently-used algorithm to select a bean for passivation.) The EJB container invokes the bean's ejbPassivate method immediately before passivating it. If a client invokes a business method on the bean while it is in the passive stage, the EJB container activates the bean, moving it back to the ready stage, and then calls the bean's ejbActivate method.

At the end of the life cycle, the client invokes the remove method and the EJB container calls the bean's ejbRemove method. The bean's instance is ready for garbage collection.

Your code controls the invocation of only two life-cycle methods--the create and remove methods in the client. All other methods in are invoked by the EJB container. The ejbCreate method, for example, is inside the bean class, allowing you to perform certain operations right after the bean is instantiated. For instance, you may wish to connect to a database in the ejbCreate method.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the callback annotations for entity bean?

518


how can u integrate ejb and hibernate? How can u call hibernateDAO methods in session bean?

2455


What do you mean enterprise javabeans (ejb) container?

611


How can enterprise javabeans be accessed from active server pages?

571


List some key actors in persistence api.

559






Is ejb a framework?

534


Define SessionContext ?

598


Define Initial Context?

590


What does ejb stand for?

621


What were entity beans?

594


Enlist the changes in EJB 2.1 ?

583


What is backing bean?

612


Can beans who are involved in transaction have 'passivation' process?

547


What is the new basic requirement for a cmp entity bean class in 2.0 from that of ejb 1.1?

577


Can you be deported if you are stateless?

480