From what I have understood in HFSJ book, HttpSessionActivationListener is used to prepare our non Seriablizable session attribute objects for the session migration.
Theoretically this sounds good. But I didn't understand one thing, how can we do this in real time? Because, the attribute themselves are not serializable, so how will they prepare themselves for migration?
Let's say I have a Person object which is not seriablizable. And if I want this object to survive during the session migration I have to implement HttpSessionActivationListener. But my question is... how??? Where will I store it???
I just didn't get the whole logic.... A sample code might help I guess, can someone explain me this?
I think you call sessionWillPassivate() before migration and you call sessionDidActivate() after migration,and you migrate from one JVM to another JVM if the application is distributed.What do you mean to store it?
Impossible is nothing.
Joined: Oct 31, 2005
I think I didn't explain it clearly in my first post.
Lets say there's a Session attribute called Person which doesn't implement the Seriablizable interface. And if I want to preserve this object during Session migration I have to have an HttpSessionActivationListener.
Does this mean that my PersonSaver now have to implement Seriablizable now??? Then it's really a dumb solution.
As far I as know, all Servlet container must support Java Native Serialization mechanism for session distribution, which is indicated by the marker interface java.io.Serializable. The container is not only limited to that mechanism. They are free to use any other means to serialize the HttpSession's attributes around the nodes. For example, some containers support the serialization of InitialContext even though it does not implement Serializable.
But beside instances of some specific classes, the container usually requires the adhoc classes to implement Serializable though.
SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
few points to share. - These are only listener. you cannot actually do anything with this. These can be used only for the logging/debugging purpose. - Activation and passivation will be taken care by the container. - we can say these are just a callback handler.