Describe the life cycle of a stateful session bean.

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

Describe the life cycle of a stateful session bean.

Rating:

The life cycle of a stateful session bean is shown in the following image:



A stateful session bean can have three states during its life as follows:

  • Does not exist

  • Method ready

  • Passivated
A client invokes the create() method of the stateful session bean. As a result, the container creates an instance of a bean using the Class.newInstance() method. The container then invokes the setSessionContext() method on the bean instance and finally calls the ejbCreate() method. This moves the bean instance to the method ready state. The container uses this instance to service the client. The instance can move from the method ready state to the does not exist state or to the passivated state. The container can move the instance by calling the ejbRemove() method in response to the remove() method call from the client. Another reason for moving to the does not exist state is due to the timeout in the method ready state.

The bean instance moves from the method ready to the passivated state when the container calls the ejbPassivate() method. The container does this to release resources when the bean instance is not in use. The container can move the bean instance back to the method ready state by calling the ejbActivate() method.

From the passivated state, the instance can move directly to the does not exist state due to the following reasons:
  • The timeout occurs in the passivated state.

  • The bean instance throws a system exception.

  • The system crashes.
In any of these situations, the instance will move directly to the does not exist state, without moving to the passivated state.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.