• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sessionDidActivate() and sessionWillPassivate()

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I might need some enlightment regarding the HttpSessionActivationListener interface.
You need to overridde 2 methods when implementing this interface: sessionDidActivate() and sessionWillPassivate().
These methods are called when the status of the session in a JVM is changed.

But when exactly is the sessionDidActivate() method triggered and when exactly is the sessionWillPassivate() method triggered ?
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a quote from my course at
http://www.examulator.com/moodle/mod/resource/view.php?id=367

(It looks prettily formatted over there)

Listening for Session Activation events

The HttpSessionActivationListener only has any relevance when a session is part of a web application in a distributed environment. Distributed applications are generally outside the scope of the exam and are fairly difficult to simulate with free software in the privacy of your own home.

The JSP/Servlet standard does not require that a web container supports distributed applications, but it must support the HttpSessionActivationListener interface, to allow code to be capable of supporting such an environment. The HttpSessionActivationListener has two methods.

public void sessionDidActivate(HttpSessionEvent se)
public void sessionWillPassivate(HttpSessionEvent se)

The specification mandates that a container may migrate a session to another JVM for purposes such as load balancing or fail-over. This type of capability is considered vital for the deployment of large scale web application

Session passivation is where inactive sessions are written to a persistent store. Session activation is the ability to a previously passivated session into memory from the persistent store. For an attributes to be migrated between distributed JVM's any attributes must implement the java.io.Serializable interface. This is not a very taxing programming task as Serializable is a marker interface i.e. it has no methods. For the purpose of the exam you just need to know it is possible to monitor the activation and passification session via the HttpSessionActivationListener.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Marcus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic