dlr 2003/02/04 14:13:20
Modified: src/java/org/apache/turbine/services/session
SessionListener.java
Log:
* src/java/org/apache/turbine/services/session/SessionListener.java
Imported and implemented HttpSessionActivationListener. Adjusted
header JavaDoc accordingly.
sessionCreated(HttpSessionEvent): Add a self-reference for listening
to activation and passivation events.
sessionDestroyed(HttpSessionEvent): Removed the self-reference for
listening to activation and passivation events.
sessionDidActivate(HttpSessionEvent): A new method which is called
by the servlet container when an existing session is (re-)activated.
sessionWillPassivate(HttpSessionEvent): A new method which is called
by the servlet container when a an existing session is passivated.
Revision Changes Path
1.4 +44 -7
jakarta-turbine-2/src/java/org/apache/turbine/services/session/SessionListener.java
Index: SessionListener.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/session/SessionListener.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -u -r1.3 -r1.4
--- SessionListener.java 4 Feb 2003 17:01:45 -0000 1.3
+++ SessionListener.java 4 Feb 2003 22:13:20 -0000 1.4
@@ -56,11 +56,13 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+import javax.servlet.http.HttpSessionActivationListener;
/**
- * This class is a listener for Session creation and destruction. It
- * must be configured via your web application's <code>web.xml</code>
- * deployment descriptor as follows for the container to call it:
+ * This class is a listener for both session creation and destruction,
+ * and for session activation and passivation. It must be configured
+ * via your web application's <code>web.xml</code> deployment
+ * descriptor as follows for the container to call it:
*
* <blockquote><code><pre>
* <listener>
@@ -74,30 +76,65 @@
* <code><context-param></code> and <code><servlet></code>
* elements in your deployment descriptor.
*
+ * The {@link #sessionCreated(HttpSessionEvent)} callback will
+ * automatically add an instance of this listener to any newly created
+ * <code>HttpSession</code> for detection of session passivation and
+ * re-activation.
+ *
* @since 2.3
* @version $Id$
* @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @see javax.servlet.http.HttpSessionListener
*/
public class SessionListener
- implements HttpSessionListener
+ implements HttpSessionListener, HttpSessionActivationListener
{
+ // ---- HttpSessionListener implementation -----------------------------
+
/**
* Called by the servlet container when a new session is created
*
- * @param event
+ * @param event Session creation event.
*/
public void sessionCreated(HttpSessionEvent event)
{
TurbineSession.addSession(event.getSession());
+ event.getSession().setAttribute(getClass().getName(), this);
}
/**
* Called by the servlet container when a session is destroyed
*
- * @param event
+ * @param event Session destruction event.
*/
public void sessionDestroyed(HttpSessionEvent event)
+ {
+ event.getSession().removeAttribute(getClass().getName());
+ TurbineSession.removeSession(event.getSession());
+ }
+
+
+ // ---- HttpSessionActivationListener implementation -------------------
+
+ /**
+ * Called by the servlet container when an existing session is
+ * (re-)activated.
+ *
+ * @param event Session activation event.
+ */
+ public void sessionDidActivate(HttpSessionEvent event)
+ {
+ TurbineSession.addSession(event.getSession());
+ }
+
+ /**
+ * Called by the servlet container when a an existing session is
+ * passivated.
+ *
+ * @param event Session passivation event.
+ */
+ public void sessionWillPassivate(HttpSessionEvent event)
{
TurbineSession.removeSession(event.getSession());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]