File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes [SFSB] Passivation question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "[SFSB] Passivation question" Watch "[SFSB] Passivation question" New topic
Author

[SFSB] Passivation question

Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3233
    
    7
Hello,
Specification says :
Instance variable of stateful session bean CAN hold reference to resource manager connection factory.
Does that means that DataSource instance variable will be handled by EJB container automatically during passivation/activation ?


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Yes! That's exactly what it means!
On page 71 in the EJB 2.0 spec, you have a whole list of things that will be passivated automatically by the Container, without you worrying about it...
Here's a little summary, for example -- at the end of ejbPassivate(), your non-transient instance variables MUST be one of the following:
* null
* Serializable object
* a bean's Remote component interface
* a bean's Remote home interface
* a bean's local component interface
* a bean's local home interface
* a reference to a SessionContext
* a reference to the environment naming context (java:comp/env)
* a reference to a UserTransaction
* a reference to a DataSource (or other resource manager connection factory)
But... you must close other non-serializable resources like a JDBC connection.
And don't forget the warning about transient -- of course you should mark transient variables 'transient', but you should ALSO set them to null (or primitives to default values) before passivation, since there is no guarantee about how those variables will come back in activation (as opposed to pure Serialization, which guarantees that transient variables will come back with default values for that type).
cheers,
Kathy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [SFSB] Passivation question