Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can someone explain about HttpSessionActivationListener

 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
gopinathang nathan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic