Author: chris.laprun(a)jboss.com
Date: 2007-04-05 17:12:38 -0400 (Thu, 05 Apr 2007)
New Revision: 6931
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
Log:
- Now implements PortalEventListener and uses Portal-level events.
- Still needs to be wired as a service...
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-04-05
21:10:04 UTC (rev 6930)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-04-05
21:12:38 UTC (rev 6931)
@@ -23,35 +23,31 @@
package org.jboss.portal.wsrp.servlet;
-// import org.jboss.portal.core.event.SessionEventListenerRegistry;
+import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
import org.jboss.portal.wsrp.handler.RequestHeaderClientHandler;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
* @since 2.6
*/
-public class ReleaseSessionsSessionListener implements HttpSessionListener
+public class ReleaseSessionsSessionListener implements PortalEventListener
{
private static ThreadLocal local = new ThreadLocal();
private static final String ID = "ReleaseSessionsSessionListener";
- public void sessionCreated(HttpSessionEvent httpSessionEvent)
+ public void sessionCreated(String id)
{
// do nothing when the session is created
- System.out.println("Session created: " +
httpSessionEvent.getSession().getId());
- local.set(httpSessionEvent.getSession().getId());
+ System.out.println("Session created: " + id);
+ local.set(id);
}
- public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
+ public void sessionDestroyed(String id)
{
- HttpSession session = httpSessionEvent.getSession();
- String id = session.getId();
System.out.println("Session destroyed: " + id);
// check if the session being destroyed is the one associated with this thread
@@ -61,18 +57,28 @@
ProducerSessionInformation producerSessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
if (producerSessionInfo != null)
{
- producerSessionInfo.releaseSession(id);
+ producerSessionInfo.removeSession(id);
}
}
}
- public void start()
+ public void onEvent(PortalEvent event)
{
-// SessionEventListenerRegistry.registerListener(ID, this);
+ if (event instanceof UserSessionEvent)
+ {
+ UserSessionEvent use = (UserSessionEvent)event;
+ int type = use.getType();
+ switch (type)
+ {
+ case UserSessionEvent.SESSION_CREATED:
+ sessionCreated(use.getRuntimeContext().getSession().getId());
+ break;
+ case UserSessionEvent.SESSION_DESTROYED:
+ sessionDestroyed(use.getRuntimeContext().getSession().getId());
+ break;
+ default:
+ throw new RuntimeException("Unexpected event: " + event);
+ }
+ }
}
-
- public void stop()
- {
-// SessionEventListenerRegistry.unregisterListener(ID);
- }
}