Author: chris.laprun(a)jboss.com
Date: 2007-02-14 01:52:37 -0500 (Wed, 14 Feb 2007)
New Revision: 6266
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
Log:
- Added minimal releaseSessions implementation (still need to hook the session listener in
web.xml and test).
- Adapted ProducerSessionInformation to accomodate support of releaseSessions (in
particular, now references the associated consumer).
- Updated test cases.
- Minor other improvements.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-02-14 06:48:32 UTC (rev 6265)
+++ trunk/wsrp/build.xml 2007-02-14 06:52:37 UTC (rev 6266)
@@ -359,6 +359,7 @@
<target name="package-other-test" description="Generates the test
artifacts" depends="compile">
<jar jarfile="${build.lib.test}/test-other-lib.jar">
<fileset dir="${build.classes}/">
+ <include
name="org/jboss/portal/test/wsrp/framework/support/*.class"/>
<include
name="org/jboss/portal/test/wsrp/other/*TestCase.class"/>
<include
name="org/jboss/portal/test/wsrp/handler/*.class"/>
</fileset>
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.wsrp.framework.support;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+import org.jboss.portal.wsrp.services.ServiceFactory;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class MockWSRPConsumer implements WSRPConsumer
+{
+ public String getProducerId()
+ {
+ return null;
+ }
+
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ }
+
+ public ServiceFactory getServiceFactory()
+ {
+ return null;
+ }
+
+ public ProducerSessionInformation getProducerSessionInformationFrom(PortletInvocation
invocation)
+ {
+ return null;
+ }
+
+ public ProducerSessionInformation getProducerSessionInformationFrom(HttpSession
session)
+ {
+ return null;
+ }
+
+ public ProducerInfo getProducerInfo()
+ {
+ return null;
+ }
+
+ public void setProducerInfo(ProducerInfo producerInfo)
+ {
+ }
+
+ public void refreshProducerInfo() throws PortletInvokerException
+ {
+ }
+
+ public void releaseSession(String sessionId) throws PortletInvokerException
+ {
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ return null;
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return null;
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return null;
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public void create() throws Exception
+ {
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-02-14
06:48:32 UTC (rev 6265)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.apache.commons.httpclient.Cookie;
+import org.jboss.portal.test.wsrp.framework.support.MockWSRPConsumer;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
@@ -42,6 +43,7 @@
protected void setUp() throws Exception
{
info = new ProducerSessionInformation();
+ info.setAssociatedConsumer(new MockWSRPConsumer());
}
public void testUserCookie() throws Exception
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-02-14
06:48:32 UTC (rev 6265)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -157,6 +157,12 @@
ExtendedAssert.assertNotNull(sessionInfo.getUserCookie());
}
+ public void testImplicitCloning() throws Exception
+ {
+// ActionInvocation action = createActionInvocation()
+
+ }
+
private FragmentResponse checkRenderResult(PortletInvocationResponse response, String
markup)
{
ExtendedAssert.assertNotNull(response);
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2007-02-14
06:48:32 UTC (rev 6265)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/ServiceDescriptionTestCase.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -51,6 +51,7 @@
super.setUp();
// override default service description behavior to make sure we have the correct
state
producer.getBehaviorRegistry().setServiceDescriptionBehavior(new
BasicServiceDescriptionBehavior());
+ consumer.refreshProducerInfo();
}
public void testGetportlets() throws Exception
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-02-14 06:48:32 UTC
(rev 6265)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-02-14 06:52:37 UTC
(rev 6266)
@@ -96,4 +96,12 @@
* @since 2.6
*/
void refreshProducerInfo() throws PortletInvokerException;
+
+ /**
+ * Instructs the associated producer to release the specified session.
+ *
+ * @param sessionId the session id to be released
+ * @since 2.6
+ */
+ void releaseSession(String sessionId) throws PortletInvokerException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-02-14 06:48:32 UTC
(rev 6265)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-02-14 06:52:37 UTC
(rev 6266)
@@ -62,6 +62,7 @@
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.ReleaseSessions;
import org.jboss.portal.wsrp.core.ResetProperty;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
@@ -856,4 +857,17 @@
return new ResetProperty(name);
}
+
+ /**
+ * registrationContext(RegistrationContext)?, sessionIDs(xsd:string)*
+ *
+ * @return
+ * @since 2.6
+ */
+ public static ReleaseSessions createReleaseSessions(RegistrationContext
registrationContext, String[] sessionIDs)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(sessionIDs, "Session
IDs");
+
+ return new ReleaseSessions(registrationContext, sessionIDs);
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-02-14
06:48:32 UTC (rev 6265)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -27,7 +27,9 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.core.SessionContext;
import java.util.HashMap;
@@ -54,8 +56,19 @@
/** portlet handle -> SessionInfo */
private Map portletSessions;
+ /** session id -> portlet handle */
+ private Map sessionId2PortletHandle;
+
private Cookie[] userCookie;
+ private WSRPConsumer associatedConsumer;
+
+ public void setAssociatedConsumer(WSRPConsumer associatedConsumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(associatedConsumer,
"Consumer");
+ this.associatedConsumer = associatedConsumer;
+ }
+
public String getUserCookie()
{
if (userCookie == null)
@@ -155,14 +168,17 @@
public void addSessionForPortlet(String portletHandle, SessionContext sessionContext)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
+ // sessionContext is validated in SessionInfo constructor
+ SessionInfo info = new SessionInfo(sessionContext, portletHandle);
if (portletSessions == null)
{
portletSessions = new HashMap();
+ sessionId2PortletHandle = new HashMap();
}
- portletSessions.put(portletHandle, new SessionInfo(sessionContext));
+ portletSessions.put(portletHandle, info);
+ sessionId2PortletHandle.put(sessionContext.getSessionID(), portletHandle);
}
/**
@@ -175,34 +191,43 @@
*/
public String getSessionIdForPortlet(String portletHandle)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
-
- if (portletSessions == null)
+ ProducerSessionInformation.SessionIdResult idResult =
internalGetSessionIdForPortlet(portletHandle);
+ if (idResult.expired)
{
return null;
}
- SessionInfo session = (SessionInfo)portletSessions.get(portletHandle);
- if (session != null)
- {
- String id = session.getSessionId();
- // if the returned id is null, the session is invalid so we remove it
- if (id == null)
- {
- portletSessions.remove(portletHandle);
- }
-
- return id;
- }
- return null;
+ return idResult.id;
}
public void removeSessionIdForPortlet(String portletHandle)
{
- if (portletHandle != null && portletSessions != null)
+ ProducerSessionInformation.SessionIdResult result =
internalGetSessionIdForPortlet(portletHandle);
+ final String id = result.id;
+
+ // if the session is still valid, release it and remove the associated mappings
+ if (!result.expired)
{
portletSessions.remove(portletHandle);
+ sessionId2PortletHandle.remove(id);
+
+ Runnable releaseSession = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ associatedConsumer.releaseSession(id);
+ }
+ catch (PortletInvokerException e)
+ {
+ log.debug(e);
+ }
+ }
+ };
+ new Thread(releaseSession).start();
}
+
}
public int getNumberOfSessions()
@@ -217,6 +242,19 @@
}
}
+ public void releaseSession(String id)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(id, "session id");
+
+ String portletHandle = (String)sessionId2PortletHandle.get(id);
+ if (portletHandle == null)
+ {
+ throw new IllegalArgumentException("No such session id: '" + id +
"'");
+ }
+
+ removeSessionIdForPortlet(portletHandle);
+ }
+
public void replaceUserCookiesWith(ProducerSessionInformation currentSessionInfo)
{
if (currentSessionInfo != null && currentSessionInfo.userCookie != null
&& currentSessionInfo.userCookie.length > 0)
@@ -270,17 +308,52 @@
return (Cookie[])cleanCookies.toArray(new Cookie[0]);
}
+ private SessionIdResult internalGetSessionIdForPortlet(String portletHandle)
+ {
+ SessionInfo session = getSessionInfoFor(portletHandle);
+ if (session != null)
+ {
+ String id = session.getSessionId();
+ if (!session.isStillValid())
+ {
+ portletSessions.remove(session.getPortletHandle());
+ sessionId2PortletHandle.remove(session.getSessionId());
+ return new SessionIdResult(id, true);
+ }
+ else
+ {
+ return new SessionIdResult(id, false);
+ }
+ }
+ return new SessionIdResult(null, false);
+ }
+
+ private SessionInfo getSessionInfoFor(String portletHandle)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
+
+ if (portletSessions == null)
+ {
+ return null;
+ }
+
+ return (SessionInfo)portletSessions.get(portletHandle);
+ }
+
private class SessionInfo
{
private SessionContext sessionContext;
private long lastInvocationTime;
+ private String portletHandle;
- public SessionInfo(SessionContext sessionContext)
+ public SessionInfo(SessionContext sessionContext, String portletHandle)
{
ParameterValidation.throwIllegalArgExceptionIfNull(sessionContext,
"SessionContext");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(sessionContext.getSessionID(),
"session id", "SessionContext");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", "SessionInfo");
this.sessionContext = sessionContext;
+ this.portletHandle = portletHandle;
lastInvocationTime = System.currentTimeMillis();
}
@@ -307,13 +380,26 @@
return diff > 0;
}
- public String getSessionId()
+ private String getSessionId()
{
- if (isStillValid())
- {
- return sessionContext.getSessionID();
- }
- return null;
+ return sessionContext.getSessionID();
}
+
+ private String getPortletHandle()
+ {
+ return portletHandle;
+ }
}
+
+ private class SessionIdResult
+ {
+ private String id;
+ private boolean expired;
+
+ public SessionIdResult(String id, boolean expired)
+ {
+ this.id = id;
+ this.expired = expired;
+ }
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-02-14
06:48:32 UTC (rev 6265)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -234,11 +234,21 @@
ParameterValidation.throwIllegalArgExceptionIfNull(session, "Session");
String producerSessionKey = getProducerSessionInformationKey();
ProducerSessionInformation sessionInformation =
(ProducerSessionInformation)session.getAttribute(producerSessionKey);
- if (sessionInformation == null && create)
+
+ if (sessionInformation != null)
{
- sessionInformation = new ProducerSessionInformation();
- session.setAttribute(producerSessionKey, sessionInformation);
+ sessionInformation.setAssociatedConsumer(consumer);
}
+ else
+ {
+ if (create)
+ {
+ sessionInformation = new ProducerSessionInformation();
+ session.setAttribute(producerSessionKey, sessionInformation);
+ sessionInformation.setAssociatedConsumer(consumer);
+ }
+ }
+
return sessionInformation;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-02-14
06:48:32 UTC (rev 6265)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -54,10 +54,12 @@
import org.jboss.portal.wsrp.core.DestroyPortlets;
import org.jboss.portal.wsrp.core.DestroyPortletsResponse;
import org.jboss.portal.wsrp.core.GetPortletProperties;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.ReleaseSessions;
import org.jboss.portal.wsrp.core.ResetProperty;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.SetPortletProperties;
@@ -556,6 +558,27 @@
sessionHandler.setRequiresInitCookie(producerInfo.getRequiresInitCookie());
}
+ public void releaseSession(String sessionId) throws PortletInvokerException
+ {
+ ReleaseSessions releaseSessions =
+
WSRPTypeFactory.createReleaseSessions(producerInfo.getRegistrationInfo().getRegistrationContext(),
new String[]{sessionId});
+
+ try
+ {
+ getMarkupService().releaseSessions(releaseSessions);
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ log.debug("Invalid Registration");
+ handleInvalidRegistrationFault();
+ }
+ catch (Exception e)
+ {
+ log.debug(e);
+ throw new PortletInvokerException("Couldn't release session '"
+ sessionId + "'.", e);
+ }
+ }
+
// Support methods
**************************************************************************************************
private String getUserContextKeyFor(UserContext userContext)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-02-14
06:48:32 UTC (rev 6265)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -260,6 +260,7 @@
{
throwInvalidRegistrationFault("no registration necessary yet one was
provided!");
}
+ RegistrationLocal.setRegistration(null);
return true;
}
}
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-02-14
06:52:37 UTC (rev 6266)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.servlet;
+
+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 void sessionCreated(HttpSessionEvent httpSessionEvent)
+ {
+ // do nothing when the session is created
+ System.out.println("Session created: " +
httpSessionEvent.getSession().getId());
+ }
+
+ public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
+ {
+ HttpSession session = httpSessionEvent.getSession();
+ String id = session.getId();
+ System.out.println("Session destroyed: " + id);
+ ProducerSessionInformation producerSessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ producerSessionInfo.releaseSession(id);
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-02-14 06:48:32 UTC (rev
6265)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-02-14 06:52:37 UTC (rev
6266)
@@ -45,6 +45,11 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <!--<listener>
+ <description>Listen for session events so that we can call releaseSessions
appropriately</description>
+
<listener-class>org.jboss.portal.wsrp.servlet.ReleaseSessionsSessionListener</listener-class>
+ </listener>-->
+
<!-- WSRP Endpoints -->
<servlet>
<servlet-name>ServiceDescriptionService</servlet-name>