wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Can someone explain about HttpSessionActivationListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Can someone explain about HttpSessionActivationListener" Watch "Can someone explain about HttpSessionActivationListener" New topic
Author

Can someone explain about HttpSessionActivationListener

Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
Hi all,

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?

Thank you,
Srikanth
Max zhang
Greenhorn

Joined: Oct 28, 2006
Posts: 14
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.
Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
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.

That is...


Does this mean that my PersonSaver now have to implement Seriablizable now??? Then it's really a dumb solution.

Can someone explain this?
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Hi,

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>
gopinathang nathan
Ranch Hand

Joined: Oct 28, 2006
Posts: 41
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.

does anyone have any info to share?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can someone explain about HttpSessionActivationListener