Author: remy.maucherat(a)jboss.com
Date: 2014-11-12 10:43:14 -0500 (Wed, 12 Nov 2014)
New Revision: 2537
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
Log:
BZ1163126: Refactor using a serializable binding listener.
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
===================================================================
---
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-10-29
10:04:49 UTC (rev 2536)
+++
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-11-12
15:43:14 UTC (rev 2537)
@@ -19,6 +19,7 @@
import static org.jboss.web.CatalinaMessages.MESSAGES;
import java.io.IOException;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -45,7 +46,7 @@
* requests.
*/
public class CrawlerSessionManagerValve extends ValveBase
- implements Lifecycle, HttpSessionBindingListener {
+ implements Lifecycle {
/**
* The lifecycle event support for this component.
@@ -219,7 +220,7 @@
clientIpSessionId.put(clientIp, s.getId());
sessionIdClientIp.put(s.getId(), clientIp);
// #valueUnbound() will be called on session expiration
- s.setAttribute(this.getClass().getName(), this);
+ s.setAttribute(this.getClass().getName(), new
CrawlerBindingListener());
s.setMaxInactiveInterval(sessionInactiveInterval);
if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
@@ -236,18 +237,18 @@
}
}
-
- @Override
- public void valueBound(HttpSessionBindingEvent event) {
- // NOOP
- }
-
-
- @Override
- public void valueUnbound(HttpSessionBindingEvent event) {
- String clientIp = sessionIdClientIp.remove(event.getSession().getId());
- if (clientIp != null) {
- clientIpSessionId.remove(clientIp);
+ protected class CrawlerBindingListener implements HttpSessionBindingListener,
Serializable {
+ private static final long serialVersionUID = -3775762684177732270L;
+ @Override
+ public void valueBound(HttpSessionBindingEvent event) {
+ // NOOP
}
+ @Override
+ public void valueUnbound(HttpSessionBindingEvent event) {
+ String clientIp = sessionIdClientIp.remove(event.getSession().getId());
+ if (clientIp != null) {
+ clientIpSessionId.remove(clientIp);
+ }
+ }
}
}