Hi James again,
I had written and posted my previous reply too fast, sorry.
One passus that I wrote:
Originally posted by Thomas Taeger:
... by the code that you provided in ejbPassivate() ...
was just half the truth.
There are three tasks the container will do when passivating a statefull session EJB:
- It will serialize all serializable, non-transient member variables and write them to a cache on harddisk, i.e.:
- - 1) simple and many other data types like
String being serializable anyway are automatically written,
- - 2) serializable compound datatypes are automatically written.
3) The container will call the ejbPassivate() method provided by you.
- This is your chance to handle non-serializable member variables like database connection or other resoures,
- - that are not serializable and
- - that you can not make serializable and
- - that therefore can not be written to cache but
- - that must be available after re-activation.
- These non-serializable member variables need to be treated speciallay:
- - declare them as transient because otherwise the container would throw an exception when trying to serialize,
- - initialize them in setSessionContext(sc) for example,
- - free them in ejbPassivate() by resetting these variables to null (!!) and
- - reallocate [and re-init] them in ejbActivate()
Thomas.
[ January 30, 2003: Message edited by: Thomas Taeger ]