Author: julien(a)jboss.com
Date: 2008-02-27 19:05:49 -0500 (Wed, 27 Feb 2008)
New Revision: 10145
Removed:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
Log:
refactor the inheritence logic of the PortletResourceRequest : use a Scope delegate object
instead of having the scope behavior in PortletResourceRequest subclasses
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -32,9 +32,7 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PortletScopedPortletResourceRequest;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
@@ -67,19 +65,21 @@
StateString portletNS = null;
CacheLevel cacheability;
+ PortletResourceRequest.Scope scope = portletResourceRequest.getScope();
+
//
- if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
+ if (scope instanceof PortletResourceRequest.PortletScope)
{
- PortletScopedPortletResourceRequest portletScopedRequest =
(PortletScopedPortletResourceRequest)portletResourceRequest;
- mode = portletScopedRequest.getWindowNavigationalState().getMode();
- windowState =
portletScopedRequest.getWindowNavigationalState().getWindowState();
- portletNS =
portletScopedRequest.getWindowNavigationalState().getPortletNavigationalState();
+ PortletResourceRequest.PortletScope portletScope =
(PortletResourceRequest.PortletScope)scope;
+ mode = portletScope.getWindowNavigationalState().getMode();
+ windowState = portletScope.getWindowNavigationalState().getWindowState();
+ portletNS =
portletScope.getWindowNavigationalState().getPortletNavigationalState();
//
- if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
+ if (scope instanceof PortletResourceRequest.PageScope)
{
- PageScopedFullPortletResourceRequest pageScopedRequest =
(PageScopedFullPortletResourceRequest)portletResourceRequest;
- pageState = pageScopedRequest.getPageState();
+ PortletResourceRequest.PageScope pageScope =
(PortletResourceRequest.PageScope)scope;
+ pageState = pageScope.getPageState();
cacheability = CacheLevel.PAGE;
//
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -25,11 +25,9 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
-import
org.jboss.portal.portlet.controller.request.FullScopedCacheablePortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PortletScopedPortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
+import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.cache.CacheLevel;
@@ -119,32 +117,29 @@
CacheLevel resourceCacheLevel =
CacheLevel.valueOf(req.getParameter(ControllerRequestParameterNames.RESOURCE_CACHEABILITY));
//
+ PortletResourceRequest.Scope scope;
switch (resourceCacheLevel)
{
case FULL:
- return new FullScopedCacheablePortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters);
+ scope = new PortletResourceRequest.FullScope();
+ break;
case PORTLET:
- return new PortletScopedPortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters,
- windowNavigationalState);
+ scope = new PortletResourceRequest.PortletScope(windowNavigationalState);
+ break;
case PAGE:
- return new PageScopedFullPortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters,
- pageState,
- windowNavigationalState);
+ scope = new PortletResourceRequest.PageScope(windowNavigationalState,
pageState);
+ break;
default:
throw new AssertionError();
}
+
+ //
+ return new PortletResourceRequest(
+ windowId,
+ resourceId,
+ resourceState,
+ formParameters,
+ scope);
}
else
{
Deleted:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * 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.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
-{
-
- public FullScopedCacheablePortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters)
- {
- super(windowId, resourceId, resourceState, bodyParameters);
- }
-}
Deleted:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * 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.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PageScopedFullPortletResourceRequest extends
PortletScopedPortletResourceRequest
-{
-
- /** . */
- private final PageNavigationalState pageState;
-
- public PageScopedFullPortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- PageNavigationalState pageState,
- WindowNavigationalState windowNavigationalState)
- {
- super(windowId, resourceId, resourceState, bodyParameters,
windowNavigationalState);
-
- //
- this.pageState = pageState;
- }
-
- public PageNavigationalState getPageState()
- {
- return pageState;
- }
-}
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -24,6 +24,8 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.cache.CacheLevel;
import java.util.HashMap;
@@ -37,16 +39,6 @@
{
/** . */
- private static final Map<Class, CacheLevel> cacheability = new HashMap<Class,
CacheLevel>();
-
- static
- {
- cacheability.put(FullScopedCacheablePortletResourceRequest.class,
CacheLevel.FULL);
- cacheability.put(PortletScopedPortletResourceRequest.class, CacheLevel.PORTLET);
- cacheability.put(PageScopedFullPortletResourceRequest.class, CacheLevel.PAGE);
- }
-
- /** . */
private final String resourceId;
/** . */
@@ -55,12 +47,15 @@
/** . */
private final ParameterMap bodyParameters;
- PortletResourceRequest(
+ /** . */
+ private final Scope scope;
+
+ public PortletResourceRequest(
String windowId,
String resourceId,
StateString resourceState,
- ParameterMap bodyParameters
- )
+ ParameterMap bodyParameters,
+ Scope scope)
{
super(windowId);
@@ -68,13 +63,19 @@
this.resourceId = resourceId;
this.resourceState = resourceState;
this.bodyParameters = bodyParameters;
+ this.scope = scope;
}
- public CacheLevel getCacheabilityType()
+ public Scope getScope()
{
- return cacheability.get(getClass());
+ return scope;
}
+ public CacheLevel getCacheability()
+ {
+ return scope.getCacheability();
+ }
+
public String getResourceId()
{
return resourceId;
@@ -89,4 +90,66 @@
{
return bodyParameters;
}
+
+ public abstract static class Scope
+ {
+
+ public abstract CacheLevel getCacheability();
+
+ }
+
+ public static class FullScope extends Scope
+ {
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.FULL;
+ }
+ }
+
+ public static class PortletScope extends FullScope
+ {
+
+ /** . */
+ private final WindowNavigationalState windowNavigationalState;
+
+ public PortletScope(WindowNavigationalState windowNavigationalState)
+ {
+ this.windowNavigationalState = windowNavigationalState;
+ }
+
+ public WindowNavigationalState getWindowNavigationalState()
+ {
+ return windowNavigationalState;
+ }
+
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.PORTLET;
+ }
+ }
+
+ public static class PageScope extends PortletScope
+ {
+
+ /** . */
+ private final PageNavigationalState pageState;
+
+ public PageScope(WindowNavigationalState windowNavigationalState,
PageNavigationalState pageState)
+ {
+ super(windowNavigationalState);
+
+ //
+ this.pageState = pageState;
+ }
+
+ public PageNavigationalState getPageState()
+ {
+ return pageState;
+ }
+
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.PAGE;
+ }
+ }
}
Deleted:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java 2008-02-27
23:49:05 UTC (rev 10144)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java 2008-02-28
00:05:49 UTC (rev 10145)
@@ -1,57 +0,0 @@
-/******************************************************************************
- * 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.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortletScopedPortletResourceRequest extends
FullScopedCacheablePortletResourceRequest
-{
-
- /** . */
- private final WindowNavigationalState windowNavigationalState;
-
- public PortletScopedPortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- WindowNavigationalState windowNavigationalState)
- {
- super(windowId, resourceId, resourceState, bodyParameters);
-
- //
- this.windowNavigationalState = windowNavigationalState;
- }
-
- public WindowNavigationalState getWindowNavigationalState()
- {
- return windowNavigationalState;
- }
-}