Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

How does stateful session bean store its state?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
1> Wanted to know how does a stateful session bean store its state..??

Thanks,
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic