01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.webapp.listeners;
05:
06: import com.tctest.webapp.servlets.InvalidatorServlet;
07:
08: import javax.servlet.http.HttpSessionBindingEvent;
09: import javax.servlet.http.HttpSessionBindingListener;
10:
11: public final class InvalidatorBindingListener implements
12: HttpSessionBindingListener {
13:
14: private final String key;
15:
16: public InvalidatorBindingListener() {
17: key = null;
18: }
19:
20: public InvalidatorBindingListener(String key) {
21: System.err.println("### BindingListener is here!!! key = "
22: + key);
23: this .key = key;
24: }
25:
26: public void valueBound(HttpSessionBindingEvent e) {
27: System.err.println("### BindingListener.valueBound: "
28: + e.getValue());
29: // the value being bound must not be in session yet...
30: Object o = e.getSession().getAttribute(e.getName());
31: if (o == null)
32: InvalidatorServlet
33: .incrementCallCount("BindingListener.valueBound");
34: else
35: System.err.println("### Event sequence violated!!!");
36: }
37:
38: public void valueUnbound(HttpSessionBindingEvent e) {
39: System.err.println("### BindingListener.valueUnbound: "
40: + e.getValue());
41: InvalidatorServlet
42: .incrementCallCount("BindingListener.valueUnbound");
43: }
44:
45: public String toString() {
46: return key;
47: }
48: }
|