• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can someone explain about HttpSessionActivationListener

 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic