JBoss Portal SVN: r6795 - in trunk: build/ide/intellij/idea60/modules/wsrp and 5 other directories.
by portal-commits@lists.jboss.org
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>
17 years, 3 months
JBoss Portal SVN: r6794 - in docs/trunk/referenceGuide/en: images/content and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 16:07:44 -0400 (Wed, 21 Mar 2007)
New Revision: 6794
Added:
docs/trunk/referenceGuide/en/images/content/
docs/trunk/referenceGuide/en/images/content/after.png
docs/trunk/referenceGuide/en/images/content/before.png
Modified:
docs/trunk/referenceGuide/en/modules/cmsPortlet.xml
docs/trunk/referenceGuide/en/modules/contentIntegration.xml
Log:
adding images to the content integration chapter
Added: docs/trunk/referenceGuide/en/images/content/after.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/content/after.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: docs/trunk/referenceGuide/en/images/content/before.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/referenceGuide/en/images/content/before.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: docs/trunk/referenceGuide/en/modules/cmsPortlet.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/cmsPortlet.xml 2007-03-21 19:10:08 UTC (rev 6793)
+++ docs/trunk/referenceGuide/en/modules/cmsPortlet.xml 2007-03-21 20:07:44 UTC (rev 6794)
@@ -42,7 +42,7 @@
locale, or display content using the default locale setting.</listitem>
</orderedlist>
</section>
- <section>
+ <section id="configuration-cms_content">
<title>CMS content</title>
<para>Since 2.6 displaying CMS content in the portal is done using the new content integration
feature. Each window of the portal can be configured to display CMS content directly instead of
Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 19:10:08 UTC (rev 6793)
+++ docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 20:07:44 UTC (rev 6794)
@@ -16,6 +16,22 @@
simplifies the configuration: it helps to make content a first class citizen of the portal instead of having an intermediary
portlet that holds the content for the portal. The portlet preferences can still be used to configure how content is displayed
to the user.</note>
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" fileref="images/content/before.png" format="png"/>
+ </imageobject>
+ <caption>
+ <para>The portal uses portlets to configure content</para>
+ </caption>
+ </mediaobject>
+ <mediaobject>
+ <imageobject>
+ <imagedata align="center" fileref="images/content/after.png" format="png"/>
+ </imageobject>
+ <caption>
+ <para>The portal references directly the content and use portlet to interact with content</para>
+ </caption>
+ </mediaobject>
<sect1>
<title>Window content</title>
<para>The content of a window is defined by
@@ -378,9 +394,28 @@
</web-app>
]]></programlisting>
<para>The web.xml descriptor</para>
- <note>You don't need to add the listener class into your war file. As it is provided by the portal
- it will always be available.</note>
+ <warning>You don't need to add the listener class into your war file. As it is provided by the portal
+ it will always be available.</warning>
</sect3>
</sect2>
</sect1>
+ <sect1>
+ <title>Configuring window content in deployment descriptor</title>
+ <para>How to create a portlet that will enable configuration of content at runtime has been covered above, however
+ it is also possible to configure content in deployment descriptors. With our previous example it would give
+ the following snippet placed in a <emphasis>*-portal.xml</emphasis> file:
+ </para>
+ <programlisting><![CDATA[
+<window>
+<window-name>MyWindow</window-name>
+<content>
+ <content-type>filesystem</content-type>
+ <content-uri>/dir1/foo.txt</content-uri>
+</content>
+<region>center</region>
+<height>1</height>
+</window>
+]]></programlisting>
+ <note>How to configure CMS file this way is covered in the CMS chapter: <xref linkend="configuration-cms_content"/></note>
+ </sect1>
</chapter>
17 years, 3 months
JBoss Portal SVN: r6793 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 15:10:08 -0400 (Wed, 21 Mar 2007)
New Revision: 6793
Modified:
docs/trunk/referenceGuide/en/modules/contentIntegration.xml
Log:
improved the content integration chapter
Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 19:00:50 UTC (rev 6792)
+++ docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 19:10:08 UTC (rev 6793)
@@ -8,11 +8,14 @@
</author>
</chapterinfo>
<title>Content Integration</title>
- <para>Since JBoss Portal 2.6 it is possible to provide easy integration of content within the portal. Up to the 2.4 version
+ <para>Since JBoss Portal 2.6 it is possible to provide an easy integration of content within the portal. Up to the 2.4 version
content integration had to be done by configuring a portlet to show some content from an URI and then place that
portlet on a page. The new content integration capabilities allows to directly configure a page window with the content URI
- removing the need to configure a portlet for that purpose. It is important here to note that we do not advocate to
- not use portlet preferences but rather we advocate the configuration of content to be managed at the portal level.</para>
+ removing the need to configure a portlet for that purpose.</para>
+ <note>We do not advocate to avoid to use portlet preferences, we rather advocate that content configuration managed at the portal level
+ simplifies the configuration: it helps to make content a first class citizen of the portal instead of having an intermediary
+ portlet that holds the content for the portal. The portlet preferences can still be used to configure how content is displayed
+ to the user.</note>
<sect1>
<title>Window content</title>
<para>The content of a window is defined by
@@ -49,8 +52,8 @@
</sect1>
<sect1>
<title>Content Driven Portlet</title>
- <para>Portlet components are used to integrate content in the portal. It relies on a few conventions which allow
- the portal and the portlet to communicate between each other.
+ <para>Portlet components are used to integrate content into the portal. It relies on a few conventions which allow
+ the portal and the portlet to communicate.
</para>
<sect2>
<title>Displaying content</title>
@@ -66,7 +69,7 @@
In that mode the portlet and the portal will communicate using either action or render parameters. We have two use cases
which are:
<itemizedlist>
- <listitem>The portal needs to configure a new content item. In that use case the portal will not send special
+ <listitem>The portal needs to configure a new content item for a new window. In that use case the portal will not send special
render parameters to the portlet and the initial set of render parameters will be empty. The portlet can
then use render parameters in order to provide navigation in the content repository. For example the portlet
can navigate the CMS tree and store the current CMS path in the render parameters. Whenever the portlet has decided
@@ -78,7 +81,7 @@
<listitem><emphasis>content.param.</emphasis> used as prefix to configure content parameters</listitem>
</itemizedlist>
</listitem>
- <listitem>The second use case arises when the portal needs to edit existing content. In such situation
+ <listitem>The second use case happens when the portal needs to edit existing content. In such situation
everything works as explained before except that the initial set of render parameters of the portlet
will be prepopulated with the content uri URI and parameters.</listitem>
</itemizedlist>
@@ -314,9 +317,9 @@
</sect3>
<sect3>
<title>Hooking the portlet into the portal</title>
- <para>Finally we need to make the portal aware of the fact that the portlet can edit and interpret. For that
- we need various descriptors. The <emphasis>portlet.xml</emphasis> descriptor will define our portlet, the
- <emphasis>portlet-instances.xml</emphasis> will create a single instance of our portlet and finally the
+ <para>Finally we need to make the portal aware of the fact that the portlet can edit and interpret content. For that
+ we need a few descriptors. The <emphasis>portlet.xml</emphasis> descriptor will define our portlet, the
+ <emphasis>portlet-instances.xml</emphasis> will create a single instance of our portlet. The
<emphasis>web.xml</emphasis> descriptor will contain a servlet context listener that will hook the content
type in the portal content type registry.</para>
<programlisting><![CDATA[
@@ -369,12 +372,14 @@
<param-value>FSContentDrivenPortletInstance</param-value>
</context-param>
<listener>
- <listener-class>org.jboss.portal.core.servlet.jsp.ContentTypeRegistration</listener-class>
+ <listener-class>org.jboss.content.ContentTypeRegistration</listener-class>
</listener>
...
</web-app>
]]></programlisting>
<para>The web.xml descriptor</para>
+ <note>You don't need to add the listener class into your war file. As it is provided by the portal
+ it will always be available.</note>
</sect3>
</sect2>
</sect1>
17 years, 3 months
JBoss Portal SVN: r6792 - in trunk: core/src/main/org/jboss/portlet and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 15:00:50 -0400 (Wed, 21 Mar 2007)
New Revision: 6792
Added:
trunk/core/src/main/org/jboss/portlet/content/
trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java
Removed:
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml
Log:
moved the content type registration to a better package, not core
Deleted: trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java 2007-03-21 18:56:43 UTC (rev 6791)
+++ trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java 2007-03-21 19:00:50 UTC (rev 6792)
@@ -1,87 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.servlet.jsp;
-
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.core.model.content.ContentType;
-import org.apache.log4j.Logger;
-
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContext;
-
-/**
- * Provide registration of a content type with a portlet instance. This listener can be used
- * in war files to register content driven portlet.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentTypeRegistration implements ServletContextListener
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(ContentTypeRegistration.class);
-
- /** . */
- private ContentType contentType;
-
- public void contextInitialized(ServletContextEvent event)
- {
- ServletContext ctx = event.getServletContext();
-
- //
- String tmp = ctx.getInitParameter("org.jboss.portal.content_type");
- if (tmp == null)
- {
- log.warn("The content type of the content registration is not defined, please define the init parameter org.jboss.portal.content_type in web.xml");
- return;
- }
- contentType = ContentType.create(tmp);
-
- //
- String portletInstance = event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
- if (portletInstance == null)
- {
- log.warn("The portlet instance of the content registration is not defined, please define the init parameter org.jboss.portal.portlet_instance in web.xml");
- return;
- }
-
- //
- log.debug("About to register content type "+ contentType + " with portlet instance " + portletInstance);
- ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
- registry.registerEditor(contentType, portletInstance);
- log.debug("Registered content type "+ contentType + " with portlet instance " + portletInstance);
- }
-
- public void contextDestroyed(ServletContextEvent event)
- {
- if (contentType != null)
- {
- log.debug("About to unregister content type "+ contentType);
- ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
- registry.unregisterEditor(contentType);
- log.debug("Content type "+ contentType + " has been unregistered");
- }
- }
-}
Copied: trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java (from rev 6780, trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java)
===================================================================
--- trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java (rev 0)
+++ trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java 2007-03-21 19:00:50 UTC (rev 6792)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.portlet.content;
+
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.model.content.ContentType;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContext;
+
+/**
+ * Provide registration of a content type with a portlet instance. This listener can be used
+ * in war files to register content driven portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentTypeRegistration implements ServletContextListener
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ContentTypeRegistration.class);
+
+ /** . */
+ private ContentType contentType;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ ServletContext ctx = event.getServletContext();
+
+ //
+ String tmp = ctx.getInitParameter("org.jboss.portal.content_type");
+ if (tmp == null)
+ {
+ log.warn("The content type of the content registration is not defined, please define the init parameter org.jboss.portal.content_type in web.xml");
+ return;
+ }
+ contentType = ContentType.create(tmp);
+
+ //
+ String portletInstance = event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
+ if (portletInstance == null)
+ {
+ log.warn("The portlet instance of the content registration is not defined, please define the init parameter org.jboss.portal.portlet_instance in web.xml");
+ return;
+ }
+
+ //
+ log.debug("About to register content type "+ contentType + " with portlet instance " + portletInstance);
+ ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
+ registry.registerEditor(contentType, portletInstance);
+ log.debug("Registered content type "+ contentType + " with portlet instance " + portletInstance);
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ if (contentType != null)
+ {
+ log.debug("About to unregister content type "+ contentType);
+ ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
+ registry.unregisterEditor(contentType);
+ log.debug("Content type "+ contentType + " has been unregistered");
+ }
+ }
+}
Modified: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java 2007-03-21 18:56:43 UTC (rev 6791)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java 2007-03-21 19:00:50 UTC (rev 6792)
@@ -252,7 +252,7 @@
/**
* Avoid the WEB-INF directory and list only text files.
*/
- private FileFilter filter = new FileFilter()
+ private final FileFilter filter = new FileFilter()
{
public boolean accept(File file)
{
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml 2007-03-21 18:56:43 UTC (rev 6791)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml 2007-03-21 19:00:50 UTC (rev 6792)
@@ -38,6 +38,6 @@
<param-value>FSContentDrivenPortletInstance</param-value>
</context-param>
<listener>
- <listener-class>org.jboss.portal.core.servlet.jsp.ContentTypeRegistration</listener-class>
+ <listener-class>org.jboss.portlet.content.ContentTypeRegistration</listener-class>
</listener>
</web-app>
17 years, 3 months
JBoss Portal SVN: r6791 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 14:56:43 -0400 (Wed, 21 Mar 2007)
New Revision: 6791
Modified:
docs/trunk/referenceGuide/en/modules/contentIntegration.xml
Log:
improved the content integration chapter
Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 18:22:58 UTC (rev 6790)
+++ docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 18:56:43 UTC (rev 6791)
@@ -85,54 +85,297 @@
</para>
</sect2>
<sect2>
- <title>Example</title>
+ <title>Step by step example of a content driven portlet</title>
<para></para>
- <programlisting><![CDATA[
-
-public class FileContentPortlet extends GenericPortlet
+ <sect3>
+ <title>The Portlet skeleton</title>
+ <para>Here is the base skeleton of the content portlet. The FSContentDrivenPortlet shows the files which are
+ in the war file in which the portlet is deployed. The arbitrary name <emphasis>filesystem</emphasis>
+ will be the content type interpreted by the portlet.
+ </para>
+ <programlisting><![CDATA[
+public class FSContentDrivenPortlet extends GenericPortlet
{
+ /** The edit_content mode. */
public static final PortletMode EDIT_CONTENT_MODE = new PortletMode("edit_content");
- /**
- * Additional dispatch for the edit content mode.
- */
- protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ ...
+
+}
+]]></programlisting>
+ </sect3>
+ <sect3>
+ <title>Overriding the dispatch method</title>
+ <para>First the <emphasis>doDispatch(RenderRequest req, RenderResponse resp)</emphasis> is overriden in order
+ to branch the requeset flow to a method that will take care of displaying the editor.</para>
+ <programlisting><![CDATA[
+protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+{
+ if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
{
- if (EDIT_CONTENT.equals(req.getPortletMode()))
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+}
+]]></programlisting>
+ </sect3>
+ <sect3>
+ <title>Utilities methods</title>
+ <para>The portlet also needs a few utilities methods which take care of converting content URI to a file
+ back and forth. There is also an implementation of a file filter that keep only text files and avoid the
+ WEB-INF directory of the war file for security reasons.</para>
+ <programlisting><![CDATA[
+protected File getFile(String contentURI) throws IOException
+{
+ String realPath = getPortletContext().getRealPath(contentURI);
+ if (realPath == null)
+ {
+ throw new IOException("Cannot access war file content");
+ }
+ File file = new File(realPath);
+ if (!file.exists())
+ {
+ throw new IOException("File " + contentURI + " does not exist");
+ }
+ return file;
+}
+]]></programlisting>
+ <programlisting><![CDATA[
+ protected String getContentURI(File file) throws IOException
+ {
+ String rootPath = getPortletContext().getRealPath("/");
+ if (rootPath == null)
{
- doEditContent(req, resp);
+ throw new IOException("Cannot access war file content");
}
- else
+
+ // Make it canonical
+ rootPath = new File(rootPath).getCanonicalPath();
+
+ // Get the portion of the path that is significant for us
+ String filePath = file.getCanonicalPath();
+ return filePath.length() >= rootPath.length() ? filePath.substring(rootPath.length()) : null;
+ }
+]]></programlisting>
+ <programlisting><![CDATA[
+ private final FileFilter filter = new FileFilter()
+ {
+ public boolean accept(File file)
{
- super.doDispatch(req, resp);
+ String name = file.getName();
+ if (file.isDirectory())
+ {
+ return !"WEB-INF".equals(name);
+ }
+ else if (file.isFile())
+ {
+ return name.endsWith(".txt");
+ }
+ else
+ {
+ return false;
+ }
}
+ };
+]]></programlisting>
+ </sect3>
+ <sect3>
+ <title>The editor</title>
+ <para>The editor is probably the longest part of the portlet. It tries to stay simple though and goes directly
+ to the point.</para>
+ <programlisting><![CDATA[
+protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+{
+ // Get the uri value optionally provided by the portal
+ String uri = req.getParameter("content.uri");
+
+ // Get the working directory directory
+ File workingDir;
+ if (uri != null)
+ {
+ workingDir = getFile(uri).getParentFile();
}
+ else
+ {
+ // Otherwise try to get the current directory we are browsing, if no current dir exist we use the root
+ String currentDir = req.getParameter("current_dir");
+ if (currentDir == null)
+ {
+ currentDir = "/";
+ }
+ workingDir = getFile(currentDir);
+ }
- protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ // Get the parent path
+ String parentPath = getContentURI(workingDir.getParentFile());
+
+ // Get the children of the selected file, we use a filter to retain only text files and avoid WEB-INF dir
+ File[] children = workingDir.listFiles(filter);
+
+ // Configure the response
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ writer.print("Directories:<br/>");
+ writer.print("<ul>");
+ PortletURL choseDirURL = resp.createRenderURL();
+ if (parentPath != null)
{
- // Get the uri value either provided by the portal or by ourself
- String uri = req.getParameter("content.uri");
- File root = null;
- if (uri == null)
+ choseDirURL.setParameter("current_dir", parentPath);
+ writer.print("<li><a href=\"" + choseDirURL + "\">..</a></li>");
+ }
+ for (int i = 0;i < children.length;i++)
+ {
+ File child = children[i];
+ if (child.isDirectory())
{
- root = "/";
+ choseDirURL.setParameter("current_dir", getContentURI(child));
+ writer.print("<li><a href=\"" + choseDirURL + "\">" + child.getName() + "</a></li>");
}
- else
+ }
+ writer.print("</ul><br/>");
+
+ //
+ writer.print("Files:<br/>");
+ writer.print("<ul>");
+ PortletURL selectFileURL = resp.createActionURL();
+ selectFileURL.setParameter("content.action.select", "select");
+ for (int i = 0;i < children.length;i++)
+ {
+ File child = children[i];
+ if (child.isFile())
{
- root = new File(uri).getParentFile().getCanonicalPath();
+ selectFileURL.setParameter("content.uri", getContentURI(child));
+ writer.print("<li><a href=\"" + selectFileURL + "\">" + child.getName() + "</a></li>");
}
+ }
+ writer.print("</ul><br/>");
- // Get the children of the selected file
- File fic = new File(uri);
- File[] children = fic.listFiles();
+ //
+ writer.close();
+}
+]]></programlisting>
+ </sect3>
+ <sect3>
+ <title>Viewing content at runtime</title>
+ <para>Last but not least the portlet needs to implement the <emphasis>doView(RenderRequest req, RenderResponse resp)</emphasis>
+ method in order to display the file that the portal window wants to show.</para>
+ <programlisting><![CDATA[
+protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+{
+ // Get the URI provided by the portal
+ String uri = req.getParameter("uri");
+ // Configure the response
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ if (uri == null)
+ {
+ writer.print("No selected file");
}
+ else
+ {
+ File file = getFile(uri);
+ FileInputStream in = null;
+ try
+ {
+ in = new FileInputStream(file);
+ FileChannel channel = in.getChannel();
+ byte[] bytes = new byte[(int)channel.size()];
+ ByteBuffer buffer = ByteBuffer.wrap(bytes);
+ channel.read(buffer);
+ writer.write(new String(bytes, 0, bytes.length, "UTF8"));
+ }
+ catch (FileNotFoundException e)
+ {
+ writer.print("No such file " + uri);
+ getPortletContext().log("Cannot find file " + uri, e);
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ }
+ }
-
+ //
+ writer.close();
}
-
]]></programlisting>
+ </sect3>
+ <sect3>
+ <title>Hooking the portlet into the portal</title>
+ <para>Finally we need to make the portal aware of the fact that the portlet can edit and interpret. For that
+ we need various descriptors. The <emphasis>portlet.xml</emphasis> descriptor will define our portlet, the
+ <emphasis>portlet-instances.xml</emphasis> will create a single instance of our portlet and finally the
+ <emphasis>web.xml</emphasis> descriptor will contain a servlet context listener that will hook the content
+ type in the portal content type registry.</para>
+ <programlisting><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app
+ xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ version="1.0">
+ ...
+ <portlet>
+ <description>File System Content Driven Portlet</description>
+ <portlet-name>FSContentDrivenPortlet</portlet-name>
+ <display-name>File System Content Driven Portlet</display-name>
+ <portlet-class>org.jboss.portal.core.portlet.test.FSContentDrivenPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>File Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ </portlet>
+ ...
+</portlet-app>
+]]></programlisting>
+ <para>The portlet.xml descriptor</para>
+ <programlisting><![CDATA[
+<deployments>
+ ...
+ <deployment>
+ <instance>
+ <instance-id>FSContentDrivenPortletInstance</instance-id>
+ <portlet-ref>FSContentDrivenPortlet</portlet-ref>
+ </instance>
+ </deployment>
+ ...
+</deployments
+]]></programlisting>
+ <para>The portlet-instances.xml descriptor</para>
+ <programlisting><![CDATA[
+<web-app>
+ ...
+ <context-param>
+ <param-name>org.jboss.portal.content_type</param-name>
+ <param-value>filesystem</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.jboss.portal.portlet_instance</param-name>
+ <param-value>FSContentDrivenPortletInstance</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.core.servlet.jsp.ContentTypeRegistration</listener-class>
+ </listener>
+ ...
+</web-app>
+]]></programlisting>
+ <para>The web.xml descriptor</para>
+ </sect3>
</sect2>
</sect1>
</chapter>
17 years, 3 months
JBoss Portal SVN: r6790 - in trunk/core-samples/src: resources/portal-samples-war and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 14:22:58 -0400 (Wed, 21 Mar 2007)
New Revision: 6790
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
trunk/core-samples/src/resources/portal-samples-war/dir1/
trunk/core-samples/src/resources/portal-samples-war/dir1/bar.txt
trunk/core-samples/src/resources/portal-samples-war/dir1/foo.txt
trunk/core-samples/src/resources/portal-samples-war/dir2/
trunk/core-samples/src/resources/portal-samples-war/dir2/foo.txt
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml
Log:
example of content driven portlet that use the war file content, will be used in the doco
Added: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java (rev 0)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FSContentDrivenPortlet.java 2007-03-21 18:22:58 UTC (rev 6790)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.portlet.test;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.IOException;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.nio.channels.FileChannel;
+import java.nio.ByteBuffer;
+
+/**
+ * <p>An example of content driven portlet that display the files located in the war file. The portlet does not implement
+ * any code to improve performance like caching in order to keep the code easier to understand. It should not be
+ * used in production for a large scale portal.</p>
+ *
+ * <p>Content URI is defined as the canonical path of the file relative to the war file context root.</p>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FSContentDrivenPortlet extends GenericPortlet
+{
+
+ /** The edit_content mode. */
+ public static final PortletMode EDIT_CONTENT_MODE = new PortletMode("edit_content");
+
+ /**
+ * Additional dispatch that will call the <code>doEditContent(RenderRequest,RenderResponse)</code> method.
+ */
+ protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
+ {
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+ }
+
+ /**
+ * Implements the edit content functionnality.
+ */
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ // Get the uri value optionally provided by the portal
+ String uri = req.getParameter("content.uri");
+
+ // Get the working directory directory
+ File workingDir;
+ if (uri != null)
+ {
+ workingDir = getFile(uri).getParentFile();
+ }
+ else
+ {
+ // Otherwise try to get the current directory we are browsing, if no current dir exist we use the root
+ String currentDir = req.getParameter("current_dir");
+ if (currentDir == null)
+ {
+ currentDir = "/";
+ }
+ workingDir = getFile(currentDir);
+ }
+
+ // Get the parent path
+ String parentPath = getContentURI(workingDir.getParentFile());
+
+ // Get the children of the selected file, we use a filter to retain only text files and avoid WEB-INF dir
+ File[] children = workingDir.listFiles(filter);
+
+ // Configure the response
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ writer.print("Directories:<br/>");
+ writer.print("<ul>");
+ PortletURL choseDirURL = resp.createRenderURL();
+ if (parentPath != null)
+ {
+ choseDirURL.setParameter("current_dir", parentPath);
+ writer.print("<li><a href=\"" + choseDirURL + "\">..</a></li>");
+ }
+ for (int i = 0;i < children.length;i++)
+ {
+ File child = children[i];
+ if (child.isDirectory())
+ {
+ choseDirURL.setParameter("current_dir", getContentURI(child));
+ writer.print("<li><a href=\"" + choseDirURL + "\">" + child.getName() + "</a></li>");
+ }
+ }
+ writer.print("</ul><br/>");
+
+ //
+ writer.print("Files:<br/>");
+ writer.print("<ul>");
+ PortletURL selectFileURL = resp.createActionURL();
+ selectFileURL.setParameter("content.action.select", "select");
+ for (int i = 0;i < children.length;i++)
+ {
+ File child = children[i];
+ if (child.isFile())
+ {
+ selectFileURL.setParameter("content.uri", getContentURI(child));
+ writer.print("<li><a href=\"" + selectFileURL + "\">" + child.getName() + "</a></li>");
+ }
+ }
+ writer.print("</ul><br/>");
+
+ //
+ writer.close();
+ }
+
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ // Get the URI provided by the portal
+ String uri = req.getParameter("uri");
+
+ // Configure the response
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ //
+ if (uri == null)
+ {
+ writer.print("No selected file");
+ }
+ else
+ {
+ File file = getFile(uri);
+ FileInputStream in = null;
+ try
+ {
+ in = new FileInputStream(file);
+ FileChannel channel = in.getChannel();
+ byte[] bytes = new byte[(int)channel.size()];
+ ByteBuffer buffer = ByteBuffer.wrap(bytes);
+ channel.read(buffer);
+ writer.write(new String(bytes, 0, bytes.length, "UTF8"));
+ }
+ catch (FileNotFoundException e)
+ {
+ writer.print("No such file " + uri);
+ getPortletContext().log("Cannot find file " + uri, e);
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ }
+ }
+
+ //
+ writer.close();
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT_MODE.equals(req.getPortletMode()))
+ {
+ String contentURI = req.getParameter("content.uri");
+
+ // We just propagate the content URI as a render parameter for the doEditContent method
+ if (contentURI != null)
+ {
+ resp.setRenderParameter("content.uri", contentURI);
+ }
+ }
+ }
+
+ /**
+ * Return a file from the specified path or null if the file cannot be determined.
+ *
+ * @param contentURI the file path
+ * @return the file or null
+ */
+ protected File getFile(String contentURI) throws IOException
+ {
+ String realPath = getPortletContext().getRealPath(contentURI);
+ if (realPath == null)
+ {
+ throw new IOException("Cannot access war file content");
+ }
+ File file = new File(realPath);
+ if (!file.exists())
+ {
+ throw new IOException("File " + contentURI + " does not exist");
+ }
+ return file;
+ }
+
+ /**
+ * Return the content uri of the file or null if it cannot be determined.
+ *
+ * @param file the file to get the URI from
+ * @return the URI or null
+ */
+ protected String getContentURI(File file) throws IOException
+ {
+ String rootPath = getPortletContext().getRealPath("/");
+ if (rootPath == null)
+ {
+ throw new IOException("Cannot access war file content");
+ }
+
+ // Make it canonical
+ rootPath = new File(rootPath).getCanonicalPath();
+
+ // Get the portion of the path that is significant for us
+ String filePath = file.getCanonicalPath();
+ return filePath.length() >= rootPath.length() ? filePath.substring(rootPath.length()) : null;
+ }
+
+ /**
+ * Avoid the WEB-INF directory and list only text files.
+ */
+ private FileFilter filter = new FileFilter()
+ {
+ public boolean accept(File file)
+ {
+ String name = file.getName();
+ if (file.isDirectory())
+ {
+ return !"WEB-INF".equals(name);
+ }
+ else if (file.isFile())
+ {
+ return name.endsWith(".txt");
+ }
+ else
+ {
+ return false;
+ }
+ }
+ };
+}
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-03-21 15:55:05 UTC (rev 6789)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-03-21 18:22:58 UTC (rev 6790)
@@ -140,4 +140,10 @@
<portlet-ref>EncodingPortlet</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>FSContentDrivenPortletInstance</instance-id>
+ <portlet-ref>FSContentDrivenPortlet</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-03-21 15:55:05 UTC (rev 6789)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-03-21 18:22:58 UTC (rev 6790)
@@ -334,6 +334,19 @@
<keywords>sample,test</keywords>
</portlet-info>
</portlet>
+ <portlet>
+ <description>File System Content Driven Portlet</description>
+ <portlet-name>FSContentDrivenPortlet</portlet-name>
+ <display-name>File System Content Driven Portlet</display-name>
+ <portlet-class>org.jboss.portal.core.portlet.test.FSContentDrivenPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>File Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ </portlet>
<user-attribute>
<name>user.name.nickName</name>
</user-attribute>
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml 2007-03-21 15:55:05 UTC (rev 6789)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/web.xml 2007-03-21 18:22:58 UTC (rev 6790)
@@ -29,4 +29,15 @@
<listener>
<listener-class> org.jboss.portal.portlet.session.SessionListener </listener-class>
</listener>
+ <context-param>
+ <param-name>org.jboss.portal.content_type</param-name>
+ <param-value>filesystem</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.jboss.portal.portlet_instance</param-name>
+ <param-value>FSContentDrivenPortletInstance</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.jboss.portal.core.servlet.jsp.ContentTypeRegistration</listener-class>
+ </listener>
</web-app>
Added: trunk/core-samples/src/resources/portal-samples-war/dir1/bar.txt
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/dir1/bar.txt (rev 0)
+++ trunk/core-samples/src/resources/portal-samples-war/dir1/bar.txt 2007-03-21 18:22:58 UTC (rev 6790)
@@ -0,0 +1 @@
+Bar content
\ No newline at end of file
Added: trunk/core-samples/src/resources/portal-samples-war/dir1/foo.txt
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/dir1/foo.txt (rev 0)
+++ trunk/core-samples/src/resources/portal-samples-war/dir1/foo.txt 2007-03-21 18:22:58 UTC (rev 6790)
@@ -0,0 +1 @@
+Foo content
\ No newline at end of file
Added: trunk/core-samples/src/resources/portal-samples-war/dir2/foo.txt
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/dir2/foo.txt (rev 0)
+++ trunk/core-samples/src/resources/portal-samples-war/dir2/foo.txt 2007-03-21 18:22:58 UTC (rev 6790)
@@ -0,0 +1 @@
+Foo content
\ No newline at end of file
17 years, 3 months
JBoss Portal SVN: r6789 - in trunk: core-admin/src/main/org/jboss/portal/core/admin/ui/portlet and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 11:55:05 -0400 (Wed, 21 Mar 2007)
New Revision: 6789
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
trunk/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp
Log:
updated the render parameter convention to be clearer for portlet content editors
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-03-21 15:36:51 UTC (rev 6788)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-03-21 15:55:05 UTC (rev 6789)
@@ -63,6 +63,18 @@
{
/** . */
+ private static final String CONTENT_ACTION_SELECT = "content.action.select";
+
+ /** . */
+ private static final String CONTENT_URI = "content.uri";
+
+ /** . */
+ private static final String CONTENT_PARAM_PREFIX = "content.param.";
+
+ /** . */
+ private static final int CONTENT_PARAM_PREFIX_LENGTH = CONTENT_PARAM_PREFIX.length();
+
+ /** . */
private static final int MOVE_UP = 'u';
/** . */
@@ -211,9 +223,9 @@
{
PortletActionEvent actionEvent = (PortletActionEvent)event;
Map actionParams = actionEvent.getParameterMap();
- if (actionParams.get("meta_action") != null)
+ if (actionParams.get(CONTENT_ACTION_SELECT) != null)
{
- String[] uris = (String[])actionParams.get("uri");
+ String[] uris = (String[])actionParams.get(CONTENT_URI);
if (uris != null && uris.length > 0)
{
String uri = uris[0];
@@ -247,9 +259,9 @@
{
Map.Entry entry = (Map.Entry)i.next();
String name = (String)entry.getKey();
- if (name.startsWith("param."))
+ if (name.startsWith(CONTENT_PARAM_PREFIX))
{
- String paramName = name.substring(6);
+ String paramName = name.substring(CONTENT_PARAM_PREFIX_LENGTH);
String paramValue = ((String[])entry.getValue())[0];
params.put(paramName, paramValue);
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-21 15:36:51 UTC (rev 6788)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-21 15:55:05 UTC (rev 6789)
@@ -66,10 +66,10 @@
{
if (req.getPortletMode().equals(EDIT_CONTENT))
{
- String uri = req.getParameter("uri");
+ String uri = req.getParameter("content.uri");
if (uri != null)
{
- resp.setRenderParameter("uri", uri);
+ resp.setRenderParameter("content.uri", uri);
}
}
}
@@ -88,7 +88,7 @@
protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
- String selectedURI = req.getParameter("uri");
+ String selectedURI = req.getParameter("content.uri");
//
PortletURL actionURL = resp.createActionURL();
@@ -103,7 +103,7 @@
writer.print("<form action=\"");
writer.print(actionURL);
writer.print("\" method=\"post\">\n");
- writer.println("<select name=\"uri\"size=\"20\">\n");
+ writer.println("<select name=\"content.uri\"size=\"20\">\n");
for (int i = 0; i < available_instances.size(); i++)
{
Instance instance = (Instance)available_instances.get(i);
@@ -126,8 +126,8 @@
writer.println("</option>\n");
}
writer.println("</select>");
- writer.println("<input name=\"meta_action\" value=\"Select\" type=\"submit\"/>");
- writer.println("<input name=\"select\" value=\"Info\" type=\"submit\"/>");
+ writer.println("<input type=\"submit\" name=\"content.action.select\" value=\"Select\"/>");
+ writer.println("<input type=\"submit\" value=\"Info\"/>");
writer.print("</form>");
//
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-21 15:36:51 UTC (rev 6788)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-21 15:55:05 UTC (rev 6789)
@@ -60,17 +60,16 @@
{
if (req.getPortletMode().equals(EDIT_CONTENT))
{
- String uri = req.getParameter("uri");
+ String uri = req.getParameter("content.uri");
String path = req.getParameter("path");
if (uri != null)
{
- resp.setRenderParameter("uri", uri);
+ resp.setRenderParameter("content.uri", uri);
}
if (path != null)
{
resp.setRenderParameter("path", path);
}
- resp.setRenderParameter("meta_action", "blah");
}
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-03-21 15:36:51 UTC (rev 6788)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-03-21 15:55:05 UTC (rev 6789)
@@ -17,7 +17,7 @@
String sCurrPath = (String)request.getAttribute("currpath");
List folders = (List)request.getAttribute("folders");
List files = (List)request.getAttribute("files");
- String uri = (String)renderRequest.getParameter("uri");
+ String uri = (String)renderRequest.getParameter("content.uri");
PortletURL url = renderResponse.createRenderURL();
url.setParameter("op", CMSAdminConstants.OP_MAIN);
url.setParameter("path", "/");
@@ -90,9 +90,9 @@
File file = (File)files.get(j);
PortletURL metaURL = renderResponse.createActionURL();
- metaURL.setParameter("uri", file.getBasePath());
+ metaURL.setParameter("content.uri", file.getBasePath());
metaURL.setParameter("path", sCurrPath);
- metaURL.setParameter("meta_action", "select");
+ metaURL.setParameter("content.action.select", "select");
if ((uri!=null) && (uri.equals(file.getBasePath())))
{
Modified: trunk/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp
===================================================================
--- trunk/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-03-21 15:36:51 UTC (rev 6788)
+++ trunk/widget/src/resources/widget-war/WEB-INF/jsp/edit.jsp 2007-03-21 15:55:05 UTC (rev 6789)
@@ -63,7 +63,7 @@
%>
<p>You have selected the widget <%= selWidget.getTitle().getDefaultString() %></p>
<p>
- <form action="<p:actionURL><p:param name="meta_action" value="select"/><p:param name="uri" value="<%= selWidget.getId() %>"/></p:actionURL>" method="post">
+ <form action="<p:actionURL><p:param name="content.action.select" value="select"/><p:param name="content.uri" value="<%= selWidget.getId() %>"/></p:actionURL>" method="post">
<%
for (Iterator i = selWidget.getPreferencesInfo().getPreferencesInfo().iterator(); i.hasNext();)
{
@@ -72,7 +72,7 @@
{
%>
- <input type="hidden" name="param.<%= prefInfo.getName() %>" value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/>
+ <input type="hidden" name="content.param.<%= prefInfo.getName() %>" value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/>
<%
}
}
@@ -93,7 +93,7 @@
break;
case DataType.ENUM:
%>
- <td><select name="param.<%= prefInfo.getName() %>" class="portlet-form-field">
+ <td><select name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field">
<%
EnumType e = (EnumType)prefInfo.getType();
for (int j = 0;j < e.getSize();j++)
@@ -110,7 +110,7 @@
break;
default:
%>
- <td><input type="text" name="param.<%= prefInfo.getName() %>" class="portlet-form-field" value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/></td>
+ <td><input type="text" name="content.param.<%= prefInfo.getName() %>" class="portlet-form-field" value="<%= prefInfo.getDefaultValue() != null ? prefInfo.getDefaultValue() : "" %>"/></td>
<%
break;
}
17 years, 3 months
JBoss Portal SVN: r6788 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-21 11:36:51 -0400 (Wed, 21 Mar 2007)
New Revision: 6788
Modified:
docs/trunk/referenceGuide/en/modules/contentIntegration.xml
Log:
started to write content integration doc
Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 12:10:57 UTC (rev 6787)
+++ docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 15:36:51 UTC (rev 6788)
@@ -7,6 +7,132 @@
<email>julien @ jboss dot com</email>
</author>
</chapterinfo>
- <title>Content integration</title>
- <para>Blah.</para>
+ <title>Content Integration</title>
+ <para>Since JBoss Portal 2.6 it is possible to provide easy integration of content within the portal. Up to the 2.4 version
+ content integration had to be done by configuring a portlet to show some content from an URI and then place that
+ portlet on a page. The new content integration capabilities allows to directly configure a page window with the content URI
+ removing the need to configure a portlet for that purpose. It is important here to note that we do not advocate to
+ not use portlet preferences but rather we advocate the configuration of content to be managed at the portal level.</para>
+ <sect1>
+ <title>Window content</title>
+ <para>The content of a window is defined by
+ <itemizedlist>
+ <listitem>The content URI which is the resource that the window is pointing to. It is an arbitrary string that
+ the portal cannot interpret and is left up to the content provider to interpret.</listitem>
+ <listitem>The window content type which defines how the portal interpret the window content
+ <itemizedlist>
+ <listitem>The default content type is for portlets and has the value <emphasis>portlet</emphasis>. For that
+ content type, the content URI is the portlet instance id.</listitem>
+ <listitem>The CMS content type allows to integrate content from the CMS at the page and it has the value
+ <emphasis>cms</emphasis>. For that content type, the content URI is the CMS file path.</listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>The content parameters which is a set of additional key/value string pairs holding state that is interpreted
+ by the content provider.</listitem>
+ </itemizedlist>
+ </para>
+ <para>At runtime when the portal needs to render a window it delegates the production of markup to a content provider.
+ The portal comes with a preconfigured set of providers which handles the portlet and the cms content types. The most
+ natural way to plug a content provider in the portal is to use a JSR 168 Portlet. Based on a few carefully chosen conventions
+ it is possible to provide an efficient content integration with the benefit of using standards and without requiring
+ the usage of a proprietary API.</para>
+ </sect1>
+ <sect1>
+ <title>Content customization</title>
+ <para>Content providers must be able to allow the user or administrator to chose content from the external resource
+ it integrates in the portal in order to properly configure a portal window. A few interactions between the portal, the content
+ provider and the portal user are necessary to achieve that goal. Here again it is possible to provide content
+ customization using a JSR 168 Portlet. For that purpose a special portlet mode called
+ <emphasis>edit_content</emphasis> has been introduced. It signals to the portlet that it is editing the content portion
+ of the state of a portlet. The traditional edit mode is not used because the edit mode is more targetted to configure how
+ the portlet show content to the end user rather than what content it shows.</para>
+ </sect1>
+ <sect1>
+ <title>Content Driven Portlet</title>
+ <para>Portlet components are used to integrate content in the portal. It relies on a few conventions which allow
+ the portal and the portlet to communicate between each other.
+ </para>
+ <sect2>
+ <title>Displaying content</title>
+ <para>At runtime the portal will call the portlet with the view mode when it displays content. It will send to the
+ portlet the information about the content to display using the render parameters. Therefore the portlet has
+ just to read the render parameters and use them to properly display the content in the portlet. The render parameters
+ values are the key/value pairs that forms the content properties and the resource URI is found under the <emphasis>uri</emphasis>
+ parameter name.</para>
+ </sect2>
+ <sect2>
+ <title>Configuring content</title>
+ <para>As explained before, the portal will call the portlet using the <emphasis>edit_content</emphasis> mode.
+ In that mode the portlet and the portal will communicate using either action or render parameters. We have two use cases
+ which are:
+ <itemizedlist>
+ <listitem>The portal needs to configure a new content item. In that use case the portal will not send special
+ render parameters to the portlet and the initial set of render parameters will be empty. The portlet can
+ then use render parameters in order to provide navigation in the content repository. For example the portlet
+ can navigate the CMS tree and store the current CMS path in the render parameters. Whenever the portlet has decided
+ to tell the portal that content has been selected by the user it needs to use an action URL with a special set of
+ parameters:
+ <itemizedlist>
+ <listitem><emphasis>content.action.select</emphasis> equals to any value</listitem>
+ <listitem><emphasis>content.uri</emphasis> equals to the content URI</listitem>
+ <listitem><emphasis>content.param.</emphasis> used as prefix to configure content parameters</listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>The second use case arises when the portal needs to edit existing content. In such situation
+ everything works as explained before except that the initial set of render parameters of the portlet
+ will be prepopulated with the content uri URI and parameters.</listitem>
+ </itemizedlist>
+ </para>
+ </sect2>
+ <sect2>
+ <title>Example</title>
+ <para></para>
+ <programlisting><![CDATA[
+
+public class FileContentPortlet extends GenericPortlet
+{
+
+ public static final PortletMode EDIT_CONTENT_MODE = new PortletMode("edit_content");
+
+ /**
+ * Additional dispatch for the edit content mode.
+ */
+ protected void doDispatch(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
+ {
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+ }
+
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ // Get the uri value either provided by the portal or by ourself
+ String uri = req.getParameter("content.uri");
+ File root = null;
+ if (uri == null)
+ {
+ root = "/";
+ }
+ else
+ {
+ root = new File(uri).getParentFile().getCanonicalPath();
+ }
+
+ // Get the children of the selected file
+ File fic = new File(uri);
+ File[] children = fic.listFiles();
+
+ }
+
+
+}
+
+]]></programlisting>
+ </sect2>
+ </sect1>
</chapter>
17 years, 3 months
JBoss Portal SVN: r6787 - trunk/identity/src/main/org/jboss/portal/identity/db.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-21 08:10:57 -0400 (Wed, 21 Mar 2007)
New Revision: 6787
Modified:
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java
Log:
Looks like useless code to me
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java 2007-03-21 03:43:18 UTC (rev 6786)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java 2007-03-21 12:10:57 UTC (rev 6787)
@@ -187,9 +187,6 @@
{
Session session = getCurrentSession();
- HibernateUserImpl userimpl = new HibernateUserImpl();
- userimpl.setEnabled(true);
-
Query query;
if (userNameFilter.trim().length() != 0)
{
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java 2007-03-21 03:43:18 UTC (rev 6786)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java 2007-03-21 12:10:57 UTC (rev 6787)
@@ -293,9 +293,6 @@
{
Session session = getCurrentSession();
- HibernateUserImpl HibernateUserImpl = new HibernateUserImpl();
- HibernateUserImpl.setEnabled(true);
-
Query query;
if (userNameFilter.trim().length() != 0)
{
17 years, 3 months
JBoss Portal SVN: r6786 - trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet.
by portal-commits@lists.jboss.org
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);
+ }
+ }
}
}
17 years, 3 months