Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable in Passivation

 
Brenda Kwok
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused with the transient variable or non-transient(e.g. serializable object) variable different after passivation. Transient variable value will lose but non-transient variable value will be kept in activation?


Is it true we don't need to do anything (in ejbPassivated() method)? If it is wrong, what should we do in ejbPassivated() and ejbActivate() for those transient and non-transient varialbes.

Thanks!!!
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an instance variable is NOT serializable, assign null in ejbPassivate() and re-initialize it back in ejbActivate().
If an instance variable is Serializable, you need not do anything in ejbPassivate() and ejbActivate(). The container guarantees proper restoration on activation.

Transient variables are generally considered sensitive and are not preferred to be written to secondary storage. The container ignores them during passivation. They may not be restored back also, even if they are Serializable. So what does a transient variable contain after ejbActivate() is run? It may be null or may even be a garbage!
[ March 02, 2005: Message edited by: Keerthi P ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic