Explain Stateful session bean life cycle?

Answers were Sorted based on User's Feedback



Explain Stateful session bean life cycle?..

Answer / 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

Explain Stateful session bean life cycle?..

Answer / srinivas

* A stateless session bean instance’s life starts when
the container invokes newInstance() on the session bean
class to create a new instance. Next, the container calls
setSessionContext() followed by ejbCreate() on the instance.
The container can perform the instance creation at any
time—there is NO relationship to a client’s invocation of
the create() method.
* The session bean instance is now ready to be
delegated a business method call from any client.
* When the container no longer needs the instance
(usually when the container wants to reduce the number of
instances in the method-ready pool), the container invokes
ejbRemove() on it. This ends the life of the stateless
session bean instance.

Is This Answer Correct ?    4 Yes 9 No

Post New Answer

More EJB Interview Questions

What is ejb application?

0 Answers  


Is success EJB3.0 in the Market? IF yes just explain main differences between EJB2.0 and EJB3.0.

1 Answers   ITC Infotech,


How to generate ejb stubs in eclipse?

0 Answers  


how can we decide a session bean as stateless or stateful without seeing jar file? i.e. by seeing the class file.

3 Answers  


Define Clone?

0 Answers  






How ejb invocation happens?

0 Answers  


What is an ejb platform?

0 Answers  


What is stateless and stateful session bean in ejb?

0 Answers  


What is ejb javatpoint?

0 Answers  


What is ejb framework?

0 Answers  


What are the callback annotations for the stateless bean?

0 Answers  


How to determine two identical beans?

1 Answers  


Categories