• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transient + passivation

 
cyril vidal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

my question is about passivation for stateful session beans.
Imagine you've got a reference to a variable that is not Serialisable, not a reference to component or home interface, not a reference to SessionContext, JNDI context, UserTransaction, or Resource Manager Factory.
The spec says you have to null out its value so that the passivation runs well. (and so reset the value after passivation in ejbActivate()).

What's the difference with declaring this variable simply as transient? You won't need to null out in ejbPassivate() but will still have to reset in ejbActivate() method.

Regards,
Cyril.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cyril,

What's the difference with declaring this variable simply as transient? You won't need to null out in ejbPassivate() but will still have to reset in ejbActivate() method.


The Bean Provider must assume that the content of transient fields may be lost between the ejbPassivate and ejbActivate notifications. Therefore, the Bean Provider should not store in a transient field a reference to any of the following objects: SessionContext object; environment JNDI naming context and any its subcontexts; home and component interfaces; and the User-Transaction interface.

The restrictions on use of transient fields ensure that Containers can use Java Serialization during passivation and activation.

Hope that clears your thoughts!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic