Author: chris.laprun(a)jboss.com
Date: 2007-03-20 23:43:18 -0400 (Tue, 20 Mar 2007)
New Revision: 6786
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
Log:
- JBPORTAL-1252: improved session listener, need to hook up to Portal session support
though.
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-03-21
00:52:41 UTC (rev 6785)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-03-21
03:43:18 UTC (rev 6786)
@@ -37,10 +37,13 @@
*/
public class ReleaseSessionsSessionListener implements HttpSessionListener
{
+ private static ThreadLocal local = new ThreadLocal();
+
public void sessionCreated(HttpSessionEvent httpSessionEvent)
{
// do nothing when the session is created
System.out.println("Session created: " +
httpSessionEvent.getSession().getId());
+ local.set(httpSessionEvent.getSession().getId());
}
public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
@@ -48,7 +51,16 @@
HttpSession session = httpSessionEvent.getSession();
String id = session.getId();
System.out.println("Session destroyed: " + id);
- ProducerSessionInformation producerSessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
- producerSessionInfo.releaseSession(id);
+
+ // check if the session being destroyed is the one associated with this thread
+ String storedId = (String)local.get();
+ if (id != null && id.equals(storedId))
+ {
+ ProducerSessionInformation producerSessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ if (producerSessionInfo != null)
+ {
+ producerSessionInfo.releaseSession(id);
+ }
+ }
}
}