Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient Field - page 72 in spec!

 
Tulsi Rai
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
could you please explain the following statement in detail?
here is the statement in the page 72 in spec:

The restriction on the use of transient fields ensure that container can use java serialization during passivation and activation.

Why is so much importance given here to *transient* fields?
Happy New Year 2004 to all of you!
cheers
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All this means is that the Container *may* use Java serialization to passivate the bean, so the spec is warning the developer that if a variables is marked "transient", you cannot expect the value to be maintained. In other words, you can assume that passivation might serialize your bean, and therefore transient variables are lost.
But then of course there is the *other* little note that warns that since it might NOT be serialization, the transient value won't necessarily be reset to its default value... but that's a different issue.
The thing to remember is the list of *states* your variables are allowed to be in by the end of ejbPassivate() (for a stateFUL session bean). You're required to know this for the exam... to know, for example, that the Container MUST successfully passivate a reference to a SessionContext even if the SessionContext implementation class turned out NOT to be serializable... doesn't matter because it is on the Container's MUST BE PASSIVATED SUCCESSFULLY list.
cheers,
Kathy
 
Tulsi Rai
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i still have confusion. there is a list of *STATE* that *non-transient* instance variables must be for successful passivation. my question here is that is that list of *STATE* required BECAUSE the instance variables are *non-transient*?does making these *non-transient* variables *transeint* instead passivate succefully regardless of whatever state transient variables are?
i am still confused
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic