File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does stateful session bean store its state?

 
Chetan M
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
1> Wanted to know how does a stateful session bean store its state..??

Thanks,
 
Chris Mathews
Ranch Hand
Posts: 2712
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bean instance is serialized after ejbPassivate() is called. Therefore all state held in the Stateful Session Bean must be serializable or marked as transient.
 
Chetan M
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,
Stateless session bean also have ejbActivate() & ejbPassivate()s , then how come they doesn't hold their state info.?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ejbActivate and ejbPassivate are never called for Stateless Session Beans. They only implement the methods because the EJB Expert Group decided it would better to have a single interface for all Session Beans rather than two separate interfaces for Stateful and Stateless Session Beans.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming back to your original question, interesting as it may seem, the EJB sepecification does not say how the conversation state must be stored and restored. It is upto the container implementation- they may use standard Serialization and save the state as an object under java:comp:env JNDI context( or its subcontext). They are free to use other custom implementations too, that are entirely different than the standard Java Serialization protocol. The EJB spec only mandates that no matter what technique is employed to save the conversational state, the result must be consistent and equivalent to using the standard Serialization protocol.
Hope that helps.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic