• 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

HttpSessionActivationListener

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the use of HttpSessionActivationListener. I know that this is to be used for Distributed enviroments, but i dont have much ideas ....
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andy,
The HttpSessionActivationListener is used for monitoring sessions on the server. When a session is activated, Notification that the session has just been activated will be received by the SessionDidActivate Method and when the session is about to be destroyed, the sessionWillPassivate is used.
Objects that are bound to the session can be initialised or destroyed based upon the listener. Also, when the session migrates between servers, the sessionwillpassivate is called and once it is successfully moved, the sessionDidActivate will be called. It is interesting to note that the sesssion is not yet ready for service at the time the sessionDidActivate method is called.
hope this helps...
Thanks,
Maneesh
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here I got sthing from the servlet 2.4 Specification... I think it's useful for you too..

Objects that are bound to a session may listen to container events notifying them that sessions will be passivated and that session will be activated. A container that migrates session between VMs or persists sessions is required to notify all attributes bound to sessions implementing HttpSessionActivationListener.


We just use it to be notified about the sessions travelling aroung the JVMs, if I am not wrong...
Any other suggestions are welcome too...
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the diffenerent scenarios when a servlet can passivate a session??
Is there any case besides migration?
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think a servlet can passivate sessions, Andy... And also there is only one case that the notification will happen only when the sessions are migrated around JVMs...
It's good to share knowledge like this...
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Naing..
Yes this s the great way to share the knowledge... and i m learning a lot by this way.. i would like other to encourage and participate more.. this would also improve ur thinking process..
I have read some where on some JRun tutorial..
********************
Understanding the HttpSessionActivationListener
When sessions are activated or passivated, JRun notifies the HttpSessionActivationListener.
Passivation occurs when JRun does not invalidate a session, but backs it up to disk to free up resources, or when a "mirrored" JRun server fails and another JRun server picks up its sessions. This is also called session persistence.
Activation occurs when the client with a passivated session makes a request and the session must be retrieved from disk or loaded into a new JRun server.
The following example of a simple HttpSession event listener implements the methods of the HttpSessionActivationListener interface. When one of these events occurs, a line is printed to the standard output.
...
public void sessionWillPassivate(HttpSessionEvent event) {
System.out.println("Session was passivated");
}
public void sessionDidActivate(HttpSessionEvent event) {
System.out.println("Session was activated");
}
************************

So I think that sessions can be passivated in more then one way..
at least to free up the resources.. in addition to migration..
Naing wat do u say??
Any other idea from any one??

[ November 26, 2003: Message edited by: Andy Smith ]
 
maneesh subherwal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think Andy is correct about sessions being passivated when they are not being used for sometime to free up resources. However, I think the major use is when the sessions are migrated from one server to another. The sessionwillpassivate is called in the first server and the sessionDidActivate is called in the second server. This is used when serialized objects exist in the session. If you do contain an object in the session that contains transient values, I believe they will not be transferred over.
I hope this helps.
Thanks,
Maneesh
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andy Smith:

Passivation occurs when JRun does not invalidate a session, but backs it up to disk to free up resources, or when a "mirrored" JRun server fails and another JRun server picks up its sessions. This is also called session persistence.
Activation occurs when the client with a passivated session makes a request and the session must be retrieved from disk or loaded into a new JRun server.
[ November 26, 2003: Message edited by: Andy Smith ]


Hi Andy,
I think it's App Server specific implementation... JBoss is trying to modify the specification and implements on its own way on HttpSessionActivationListener to make better usage on it... :roll:
I think since the situation, in which sessions are travelling around the JVMs looks like the situation, in which sessions are travelling to and from between the disk and server, JBoss then applied this concept... It's just my opinion on it... I'm not very sure about that... :roll:
reply
    Bookmark Topic Watch Topic
  • New Topic