Author: thomas.heute(a)jboss.com
Date: 2008-08-26 07:18:46 -0400 (Tue, 26 Aug 2008)
New Revision: 11737
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/BackwardCompatibilityInterceptor.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/portlet/BackwardCompatibilityInterceptor.java
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossActionRequest.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossRenderRequest.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1944: Move ThreadLocals for JBossPortlet support to interceptors
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/BackwardCompatibilityInterceptor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/BackwardCompatibilityInterceptor.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/BackwardCompatibilityInterceptor.java 2008-08-26
11:18:46 UTC (rev 11737)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.aspects.controller;
+
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
+
+/**
+ * Only for backward compatibility with JBossActionRequest in 2.6
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class BackwardCompatibilityInterceptor extends ControllerInterceptor
+{
+ public static ThreadLocal<ControllerContext> controllerContextTL = new
ThreadLocal<ControllerContext>();
+
+ @Override
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
+ {
+
+ controllerContextTL.set(cmd.getControllerContext());
+ ControllerResponse response = null;
+ try
+ {
+ response = (ControllerResponse)cmd.invokeNext();
+ }
+ finally
+ {
+ controllerContextTL.remove();
+ }
+
+ //
+ return response;
+ }
+
+}
+
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/portlet/BackwardCompatibilityInterceptor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/portlet/BackwardCompatibilityInterceptor.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/portlet/BackwardCompatibilityInterceptor.java 2008-08-26
11:18:46 UTC (rev 11737)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.aspects.portlet;
+
+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.spi.UserContext;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class BackwardCompatibilityInterceptor extends CorePortletInterceptor
+{
+
+ public static ThreadLocal<UserContext> userContextTL = new
ThreadLocal<UserContext>();
+
+ @Override
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ userContextTL.set(invocation.getUserContext());
+ PortletInvocationResponse response = null;
+ try
+ {
+ response = super.invoke(invocation);
+ }
+ finally
+ {
+ userContextTL.remove();
+ }
+
+ //
+ return response;
+
+ }
+
+}
+
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-08-26
10:22:56 UTC (rev 11736)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-08-26
11:18:46 UTC (rev 11737)
@@ -61,12 +61,6 @@
public class PortletInvocationFactory
{
- /** Remove me / flawed. */
- public static ThreadLocal<ControllerContext> controllerContextTL = new
ThreadLocal<ControllerContext>();
-
- /** Remove me / flawed. */
- public static ThreadLocal<UserContext> userContextTL = new
ThreadLocal<UserContext>();
-
public static InvokePortletCommandFactory createInvokePortletCommandFactory(
ControllerContext controllerContext,
Window window,
@@ -183,13 +177,6 @@
{
invocation.setAttribute("controller_context", controllerContext);
- //
- UserContext userContext = cf.createUserContext();
-
- //
- controllerContextTL.set(controllerContext);
- userContextTL.set(userContext);
-
// Contextualize
invocation.setSecurityContext(cf.createSecurityContext());
invocation.setPortalContext(cf.createPortalContext());
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossActionRequest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossActionRequest.java 2008-08-26
10:22:56 UTC (rev 11736)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossActionRequest.java 2008-08-26
11:18:46 UTC (rev 11737)
@@ -31,10 +31,10 @@
import javax.portlet.filter.PortletRequestWrapper;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.core.aspects.controller.BackwardCompatibilityInterceptor;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portlet.util.Parameters;
@@ -61,9 +61,9 @@
{
super(portletRequest);
this.portletRequest = portletRequest;
- this.controllerContext = PortletInvocationFactory.controllerContextTL.get();
+ this.controllerContext =
BackwardCompatibilityInterceptor.controllerContextTL.get();
this.blah = null;
- this.userContext = PortletInvocationFactory.userContextTL.get();
+ this.userContext =
org.jboss.portal.core.aspects.portlet.BackwardCompatibilityInterceptor.userContextTL.get();
}
public ControllerContext getControllerContext()
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossRenderRequest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2008-08-26
10:22:56 UTC (rev 11736)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2008-08-26
11:18:46 UTC (rev 11737)
@@ -28,6 +28,7 @@
import javax.portlet.filter.PortletRequestWrapper;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.core.aspects.controller.BackwardCompatibilityInterceptor;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
@@ -58,8 +59,8 @@
{
super(portletRequest);
this.portletRequest = portletRequest;
- this.controllerContext = PortletInvocationFactory.controllerContextTL.get();
- this.userContext = PortletInvocationFactory.userContextTL.get();
+ this.controllerContext =
BackwardCompatibilityInterceptor.controllerContextTL.get();
+ this.userContext =
org.jboss.portal.core.aspects.portlet.BackwardCompatibilityInterceptor.userContextTL.get();
}
public ControllerContext getControllerContext()
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-08-26
10:22:56 UTC (rev 11736)
+++
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-08-26
11:18:46 UTC (rev 11737)
@@ -156,6 +156,11 @@
portal:service=ControlPolicy,type=Portal
</depends>
</mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.BackwardCompatibilityInterceptor"
+
name="portal:service=Interceptor,type=Command,name=BackwardCompatibility"
xmbean-dd=""
+
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
<mbean
code="org.jboss.portal.core.aspects.controller.ResourceAcquisitionInterceptor"
name="portal:service=Interceptor,type=Command,name=ResourceAcquisition"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -234,6 +239,7 @@
<!--
depends-list-element>portal:service=Interceptor,type=Command,name=CleanNS</depends-list-element
-->
<depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=Control</depends-list-element>
+
<depends-list-element>portal:service=Interceptor,type=Command,name=BackwardCompatibility</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PageCustomizer</depends-list-element>
@@ -327,6 +333,11 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
</mbean>
+ <mbean
code="org.jboss.portal.core.aspects.portlet.BackwardCompatibilityInterceptor"
+
name="portal:service=Interceptor,type=Portlet,name=BackwardCompatibility"
xmbean-dd=""
+
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
<mbean code="org.jboss.portal.core.aspects.portlet.SignOutInterceptor"
name="portal:service=Interceptor,type=Portlet,name=SignOut"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -351,6 +362,7 @@
<depends-list-element>portal:service=Interceptor,type=Portlet,name=ContextTracker</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Portlet,name=PortletSessionSynchronization</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Portlet,name=Bridge</depends-list-element>
+
<depends-list-element>portal:service=Interceptor,type=Portlet,name=BackwardCompatibility</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Portlet,name=Ajax</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Portlet,name=SignOut</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Portlet,name=ProducerCache</depends-list-element>