Author: chris.laprun(a)jboss.com
Date: 2007-03-21 17:01:14 -0400 (Wed, 21 Mar 2007)
New Revision: 6795
Added:
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
Modified:
trunk/build/build.xml
trunk/build/ide/intellij/idea60/modules/wsrp/wsrp.iml
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
Log:
JBPORTAL-1252:
- Added SessionEventListenerRegistry to gather SessionListener and transmit session
events to them.
- ReleaseSessionsSessionListener is now a service and registers with the registry.
- wsrp module now depends on core (should be fixed in future revisions).
Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml 2007-03-21 20:07:44 UTC (rev 6794)
+++ trunk/build/build.xml 2007-03-21 21:01:14 UTC (rev 6795)
@@ -142,7 +142,7 @@
<group name="portal">
<include
- modules="common, test, api, jems, server, security, identity, search,
format, portlet, portlet-server, bridge, faces, portlet-federation, theme, workflow, cms,
samples, registration, wsrp, core, core-admin, core-cms, core-management,
core-samples"/>
+ modules="common, test, api, jems, server, security, identity, search,
format, portlet, portlet-server, bridge, faces, portlet-federation, theme, workflow, cms,
samples, registration, core, wsrp, core-admin, core-cms, core-management,
core-samples"/>
</group>
<group name="cms">
Modified: trunk/build/ide/intellij/idea60/modules/wsrp/wsrp.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/wsrp/wsrp.iml 2007-03-21 20:07:44 UTC (rev
6794)
+++ trunk/build/ide/intellij/idea60/modules/wsrp/wsrp.iml 2007-03-21 21:01:14 UTC (rev
6795)
@@ -231,6 +231,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="core" />
<orderEntryProperties />
<javadoc-paths>
<root
url="http://java.sun.com/j2ee/1.4/docs/api/" />
Added: trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java 2007-03-21
21:01:14 UTC (rev 6795)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.core.event;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class SessionEventListenerRegistry implements HttpSessionListener
+{
+ private static final Map listeners = new ConcurrentHashMap();
+
+ public static void registerListener(String id, HttpSessionListener listener)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"listener");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "registerListener");
+
+ listeners.put(id, listener);
+ }
+
+ public static void unregisterListener(String id)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "unregisterListener");
+
+ listeners.remove(id);
+ }
+
+ public static HttpSessionListener getListener(String id)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "getListener");
+
+ return (HttpSessionListener)listeners.get(id);
+ }
+
+ public void sessionCreated(HttpSessionEvent httpSessionEvent)
+ {
+ for (Iterator allListeners = listeners.values().iterator();
allListeners.hasNext();)
+ {
+ HttpSessionListener listener = (HttpSessionListener)allListeners.next();
+ listener.sessionCreated(httpSessionEvent);
+ }
+ }
+
+ public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
+ {
+ for (Iterator allListeners = listeners.values().iterator();
allListeners.hasNext();)
+ {
+ HttpSessionListener listener = (HttpSessionListener)allListeners.next();
+ listener.sessionDestroyed(httpSessionEvent);
+ }
+ }
+}
Property changes on:
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-03-21 20:07:44 UTC (rev 6794)
+++ trunk/wsrp/build.xml 2007-03-21 21:01:14 UTC (rev 6795)
@@ -137,6 +137,7 @@
<path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-core.classpath"/>
<path refid="jboss.portal-registration.classpath"/>
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-portlet.classpath"/>
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
20:07:44 UTC (rev 6794)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/ReleaseSessionsSessionListener.java 2007-03-21
21:01:14 UTC (rev 6795)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.servlet;
+import org.jboss.portal.core.event.SessionEventListenerRegistry;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
import org.jboss.portal.wsrp.handler.RequestHeaderClientHandler;
@@ -38,6 +39,7 @@
public class ReleaseSessionsSessionListener implements HttpSessionListener
{
private static ThreadLocal local = new ThreadLocal();
+ private static final String ID = "ReleaseSessionsSessionListener";
public void sessionCreated(HttpSessionEvent httpSessionEvent)
{
@@ -63,4 +65,14 @@
}
}
}
+
+ public void start()
+ {
+ SessionEventListenerRegistry.registerListener(ID, this);
+ }
+
+ public void stop()
+ {
+ SessionEventListenerRegistry.unregisterListener(ID);
+ }
}
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2007-03-21
20:07:44 UTC (rev 6794)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2007-03-21
21:01:14 UTC (rev 6795)
@@ -158,5 +158,11 @@
<attribute
name="SessionFactoryJNDIName">java:/portal/WSRPConsumerSessionFactory</attribute>
<depends optional-attribute-name="FederatingPortletInvoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
</mbean>
+
+ <!-- Listen for session events so that releaseSessions can be called when needed
-->
+ <mbean
code="org.jboss.portal.wsrp.servlet.ReleaseSessionsSessionListener"
name="portal.wsrp:service=SessionListener"
+ xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
</server>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-03-21 20:07:44 UTC (rev
6794)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/web.xml 2007-03-21 21:01:14 UTC (rev
6795)
@@ -57,11 +57,6 @@
<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>