From portal-commits at lists.jboss.org Thu Apr 5 17:12:39 2007 Content-Type: multipart/mixed; boundary="===============7138445658627960552==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6931 - trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet. Date: Thu, 05 Apr 2007 17:12:38 -0400 Message-ID: --===============7138445658627960552== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/ReleaseSessionsSession= Listener.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/ReleaseSessions= SessionListener.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessio= nListener.java 2007-04-05 21:10:04 UTC (rev 6930) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessio= nListener.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 Chris Laprun * @version $Revision$ * @since 2.6 */ -public class ReleaseSessionsSessionListener implements HttpSessionListener +public class ReleaseSessionsSessionListener implements PortalEventListener { private static ThreadLocal local =3D new ThreadLocal(); private static final String ID =3D "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 =3D httpSessionEvent.getSession(); - String id =3D session.getId(); System.out.println("Session destroyed: " + id); = // check if the session being destroyed is the one associated with t= his thread @@ -61,18 +57,28 @@ ProducerSessionInformation producerSessionInfo =3D RequestHeaderC= lientHandler.getCurrentProducerSessionInformation(); if (producerSessionInfo !=3D 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 =3D (UserSessionEvent)event; + int type =3D 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); - } } --===============7138445658627960552==--