Author: thomas.heute(a)jboss.com
Date: 2008-03-04 09:56:32 -0500 (Tue, 04 Mar 2008)
New Revision: 10191
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
Log:
PortletInvocationFcatory migration to PC2 API
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2008-03-04
13:26:22 UTC (rev 10190)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2008-03-04
14:56:32 UTC (rev 10191)
@@ -30,9 +30,11 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
import org.jboss.portal.portlet.spi.PortalContext;
import org.jboss.portal.portlet.spi.RequestContext;
import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.ServerContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.server.PortalConstants;
@@ -62,23 +64,30 @@
/** . */
private WindowContext windowContext;
+
+ /**. */
+ private ServerContext serverContext;
+
public PortletContextFactory(ControllerContext controllerContext, Portal portal,
Window window)
{
- this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
+ this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
this.securityContext = new
AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = new
org.jboss.portal.core.model.portal.portlet.PortalContextImpl(portal);
this.windowContext = new
org.jboss.portal.core.model.portal.portlet.WindowContextImpl(window);
+ this.serverContext = new
AbstractServerContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
+
}
public PortletContextFactory(ControllerContext controllerContext)
{
- this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
+ this.requestContext = new
AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
this.securityContext = new
AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
this.userContext = new ControllerUserContext(controllerContext);
this.portalContext = portalContextImpl;
this.windowContext = new WindowContextImpl("abc"); // Well ????
+ this.serverContext = new
AbstractServerContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(),
controllerContext.getServerInvocation().getServerContext().getClientResponse());
}
public PortalContext createPortalContext()
@@ -105,7 +114,13 @@
{
return windowContext;
}
+
+ public ServerContext createServerContext()
+ {
+ return serverContext;
+ }
+
/** . */
private static final PortalContextImpl portalContextImpl = new PortalContextImpl();
@@ -113,10 +128,10 @@
{
/** . */
- private final Set windowStates;
+ private final Set<WindowState> windowStates;
/** . */
- private final Set modes;
+ private final Set<Mode> modes;
/** . */
private final Map props;
@@ -133,12 +148,12 @@
return PortalConstants.VERSION.toString();
}
- public Set getWindowStates()
+ public Set<WindowState> getWindowStates()
{
return windowStates;
}
- public Set getModes()
+ public Set<Mode> getModes()
{
return modes;
}
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-03-04
13:26:22 UTC (rev 10190)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-03-04
14:56:32 UTC (rev 10191)
@@ -22,11 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.controller.portlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.invocation.EmptyAttributeResolver;
import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.Portal;
@@ -34,22 +38,17 @@
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
-import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.spi.ActionContext;
-import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -98,20 +97,18 @@
{
MarkupInfo markupInfo =
(MarkupInfo)controllerContext.getServerInvocation().getResponse().getContentInfo();
+ PortletInvocationContext portletInvocationContext = new
ControllerPortletInvocationContext(cpc, controllerContext, mode, windowState,
navigationalState, markupInfo);
+
//
- ActionContext ctx = new ControllerActionContext(
- cpc,
- controllerContext,
- mode, windowState,
- navigationalState,
- markupInfo,
- interactionState,
- form);
-
+ ActionInvocation action = new ActionInvocation(portletInvocationContext);
+
+ action.setForm(form);
+ action.setMode(mode);
+ action.setWindowState(windowState);
+ action.setNavigationalState(navigationalState);
+ action.setInteractionState(interactionState);
+
//
- ActionInvocation action = new ActionInvocation(ctx);
-
- //
action.setAttribute(PortletInvocation.INVOCATION_SCOPE,
"controller_context", controllerContext);
// Contextualize
@@ -120,6 +117,7 @@
action.setPortalContext(cf.createPortalContext());
action.setWindowContext(cf.createWindowContext());
action.setUserContext(cf.createUserContext());
+ action.setServerContext(cf.createServerContext());
//
return action;
@@ -135,40 +133,36 @@
{
MarkupInfo markupInfo =
(MarkupInfo)controllerContext.getServerInvocation().getResponse().getContentInfo();
- //
- RenderContext ctx = new ControllerRenderContext(
- cpc,
- controllerContext,
- mode,
- windowState,
- navigationalState,
- markupInfo);
+ PortletInvocationContext portletInvocationContext = new
ControllerPortletInvocationContext(cpc, controllerContext, mode, windowState,
navigationalState, markupInfo);
//
- RenderInvocation render = new RenderInvocation(ctx);
+ RenderInvocation render = new RenderInvocation(portletInvocationContext);
+ render.setMode(mode);
+ render.setWindowState(windowState);
+ render.setNavigationalState(navigationalState);
+
//
render.setAttribute(PortletInvocation.INVOCATION_SCOPE,
"controller_context", controllerContext);
// Contextualize
render.setSecurityContext(cf.createSecurityContext());
- render.setRequestContext(cf.createRequestContext());
render.setPortalContext(cf.createPortalContext());
render.setWindowContext(cf.createWindowContext());
render.setUserContext(cf.createUserContext());
-
+ render.setServerContext(cf.createServerContext());
//
return render;
}
- private static class ControllerActionContext extends AbstractActionContext
+ private static class ControllerPortletInvocationContext extends
AbstractPortletInvocationContext
{
private InvokePortletCommandFactory cmdFactory;
private ControllerContext controllerContext;
- public ControllerActionContext(InvokePortletCommandFactory cmdFactory,
ControllerContext controllerContext, Mode mode, WindowState windowState, StateString
navigationalState, MarkupInfo markupInfo, StateString interactionState, PortletParameters
form)
+ public ControllerPortletInvocationContext(InvokePortletCommandFactory cmdFactory,
ControllerContext controllerContext, Mode mode, WindowState windowState, StateString
navigationalState, MarkupInfo markupInfo)
{
- super(mode, windowState, navigationalState, markupInfo, interactionState,
form);
+ super(markupInfo);
//
this.cmdFactory = cmdFactory;
@@ -192,65 +186,29 @@
return
controllerContext.getServerInvocation().getServerContext().getClientResponse();
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
- return PortletInvocationFactory.renderURL(controllerContext, cmdFactory,
portletURL, wantSecure, wantAuthenticated, relative);
+ return PortletInvocationFactory.renderURL(controllerContext, cmdFactory,
containerURL, wantSecure, wantAuthenticated, relative);
}
}
- private static class ControllerRenderContext extends AbstractRenderContext
- {
- private InvokePortletCommandFactory cmdFactory;
- private ControllerContext controllerContext;
- public ControllerRenderContext(InvokePortletCommandFactory cmdFactory,
ControllerContext controllerContext, Mode mode, WindowState windowState, StateString
navigationalState, MarkupInfo markupInfo)
- {
- super(mode, windowState, navigationalState, markupInfo);
-
- //
- this.cmdFactory = cmdFactory;
- this.controllerContext = controllerContext;
-
- //
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return
controllerContext.getServerInvocation().getServerContext().getClientRequest();
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return
controllerContext.getServerInvocation().getServerContext().getClientResponse();
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
- {
- return PortletInvocationFactory.renderURL(controllerContext, cmdFactory,
portletURL, wantSecure, wantAuthenticated, relative);
- }
- }
-
public static String renderURL(
ControllerContext controllerContext,
InvokePortletCommandFactory factory,
- PortletURL portletURL,
+ ContainerURL containerURL,
Boolean wantSecure,
Boolean wantAuthenticated,
boolean relative)
{
ControllerCommand cmd;
- if (portletURL instanceof ActionURL)
+ if (containerURL instanceof ActionURL)
{
- cmd = factory.createInvokeActionCommand((ActionURL)portletURL);
+ cmd = factory.createInvokeActionCommand((ActionURL)containerURL);
}
else
{
- cmd = factory.createInvokeRenderCommand((RenderURL)portletURL);
+ cmd = factory.createInvokeRenderCommand((RenderURL)containerURL);
}
//