01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package winstone.testApplication.listeners;
08:
09: import javax.servlet.http.HttpSessionActivationListener;
10: import javax.servlet.http.HttpSessionAttributeListener;
11: import javax.servlet.http.HttpSessionBindingEvent;
12: import javax.servlet.http.HttpSessionEvent;
13: import javax.servlet.http.HttpSessionListener;
14:
15: /**
16: * Logs messages when any session event is received
17: *
18: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
19: * @version $Id: SessionListener.java,v 1.2 2006/02/28 07:32:46 rickknowles Exp $
20: */
21: public class SessionListener implements HttpSessionListener,
22: HttpSessionAttributeListener, HttpSessionActivationListener {
23: public void sessionCreated(HttpSessionEvent se) {
24: se.getSession().getServletContext().log(
25: "Session Created - id=" + se.getSession().getId());
26: }
27:
28: public void sessionDestroyed(HttpSessionEvent se) {
29: se.getSession().getServletContext().log(
30: "Session Destroyed - id=" + se.getSession().getId());
31: }
32:
33: public void attributeAdded(HttpSessionBindingEvent se) {
34: se.getSession().getServletContext().log(
35: "Session Attribute added (session id="
36: + se.getSession().getId() + ") " + se.getName()
37: + "=" + se.getValue());
38: }
39:
40: public void attributeRemoved(HttpSessionBindingEvent se) {
41: se.getSession().getServletContext().log(
42: "Session Attribute removed (session id="
43: + se.getSession().getId() + ") " + se.getName()
44: + "=" + se.getValue());
45: }
46:
47: public void attributeReplaced(HttpSessionBindingEvent se) {
48: se.getSession().getServletContext().log(
49: "Session Attribute replaced (session id="
50: + se.getSession().getId() + ") " + se.getName()
51: + "=" + se.getValue());
52: }
53:
54: public void sessionDidActivate(HttpSessionEvent se) {
55: se.getSession().getServletContext().log(
56: "Session activated - id=" + se.getSession().getId());
57: }
58:
59: public void sessionWillPassivate(HttpSessionEvent se) {
60: se.getSession().getServletContext().log(
61: "Session passivating - id=" + se.getSession().getId());
62: }
63: }
|