Author: julien(a)jboss.com
Date: 2007-03-28 09:44:55 -0400 (Wed, 28 Mar 2007)
New Revision: 6862
Modified:
trunk/bridge/src/main/org/jboss/portal/bridge/BridgeRequest.java
trunk/bridge/src/main/org/jboss/portal/bridge/BridgeResponse.java
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java
Log:
- improve request dispatching responsibilities to portlet container
- do not expose client request and client response from RequestContext (because it may be
unsafe to use them at some point in the pipeline)
Modified: trunk/bridge/src/main/org/jboss/portal/bridge/BridgeRequest.java
===================================================================
--- trunk/bridge/src/main/org/jboss/portal/bridge/BridgeRequest.java 2007-03-28 12:45:32
UTC (rev 6861)
+++ trunk/bridge/src/main/org/jboss/portal/bridge/BridgeRequest.java 2007-03-28 13:44:55
UTC (rev 6862)
@@ -52,7 +52,7 @@
public BridgeRequest(JBossServletContextProvider.BridgeInfo info)
{
PortletInvocation invocation = info.getInvocation();
- this.hreq =
((AbstractRequestContext)invocation.getRequestContext()).getClientRequest();
+ this.hreq = invocation.getDispatchedRequest();
this.preq = (PortletRequest)hreq.getAttribute("javax.portlet.request");
}
Modified: trunk/bridge/src/main/org/jboss/portal/bridge/BridgeResponse.java
===================================================================
--- trunk/bridge/src/main/org/jboss/portal/bridge/BridgeResponse.java 2007-03-28 12:45:32
UTC (rev 6861)
+++ trunk/bridge/src/main/org/jboss/portal/bridge/BridgeResponse.java 2007-03-28 13:44:55
UTC (rev 6862)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.bridge;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import javax.portlet.PortletResponse;
@@ -43,15 +42,19 @@
public class BridgeResponse implements HttpServletResponse
{
+ /** . */
protected final PortletResponse presp;
+
+ /** . */
protected final PortletInvocation invocation;
+ /** . */
protected ServletOutputStream sos;
public BridgeResponse(JBossServletContextProvider.BridgeInfo info)
{
invocation = info.getInvocation();
- HttpServletRequest hreq =
((AbstractRequestContext)invocation.getRequestContext()).getClientRequest();
+ HttpServletRequest hreq = invocation.getDispatchedRequest();
this.presp =
(PortletResponse)hreq.getAttribute("javax.portlet.response");
this.sos = null;
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2007-03-28
12:45:32 UTC (rev 6861)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2007-03-28
13:44:55 UTC (rev 6862)
@@ -32,7 +32,6 @@
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.RequestContext;
-import org.jboss.portal.portlet.info.PortletInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -69,14 +68,7 @@
PortletApplication portletApplication = container.getApplication();
RequestContext reqCtx = invocation.getRequestContext();
ServletContext targetCtx = portletApplication.getContext().getServletContext();
- HttpServletRequest clientRequest = reqCtx.getClientRequest();
- HttpServletResponse clientResponse = reqCtx.getClientResponse();
- return servletContainerContext.dispatch(
- clientRequest,
- clientResponse,
- targetCtx,
- callback,
- invocation);
+ return reqCtx.dispatch(servletContainerContext, targetCtx, callback, invocation);
}
private static final RequestDispatchCallback callback = new RequestDispatchCallback()
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java 2007-03-28
12:45:32 UTC (rev 6861)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRequestContext.java 2007-03-28
13:44:55 UTC (rev 6862)
@@ -23,9 +23,12 @@
package org.jboss.portal.portlet.impl.spi;
import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.spi.RequestDispatchCallback;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,45 +37,47 @@
public class AbstractRequestContext implements RequestContext
{
+ /** . */
private HttpServletRequest req;
+
+ /** . */
private HttpServletResponse resp;
+ /** . */
+ private String scheme;
+
+ /** . */
+ private String serverName;
+
+ /** . */
+ private int serverPort;
+
public AbstractRequestContext(HttpServletRequest req, HttpServletResponse resp)
{
this.req = req;
this.resp = resp;
+ this.scheme = req.getScheme();
+ this.serverName = req.getServerName();
+ this.serverPort = req.getServerPort();
}
- public HttpServletRequest getClientRequest()
+ public String getScheme()
{
- if (req == null)
- {
- throw new IllegalStateException("No request available");
- }
- return req;
+ return scheme;
}
- public HttpServletResponse getClientResponse()
+ public String getServerName()
{
- if (resp == null)
- {
- throw new IllegalStateException("No response available");
- }
- return resp;
+ return serverName;
}
- public String getScheme()
+ public int getServerPort()
{
- return getClientRequest().getScheme();
+ return serverPort;
}
- public String getServerName()
+ public Object dispatch(ServletContainerContext scc, ServletContext targetCtx,
RequestDispatchCallback callback, Object handback) throws Exception
{
- return getClientRequest().getServerName();
+ return scc.dispatch(req, resp, targetCtx, callback, handback);
}
-
- public int getServerPort()
- {
- return getClientRequest().getServerPort();
- }
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java 2007-03-28
12:45:32 UTC (rev 6861)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/spi/RequestContext.java 2007-03-28
13:44:55 UTC (rev 6862)
@@ -22,8 +22,12 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
+import org.jboss.portal.web.spi.ServletContainerContext;
+import org.jboss.portal.web.spi.RequestDispatchCallback;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -47,12 +51,15 @@
int getServerPort();
/**
+ * Delegate to the request context the dispatching to the target servlet context using
the specified spi elements.
*
+ * @param servletContainerContext the servlet container spi
+ * @param targetServletContext the target servlet context
+ * @param callback the call back to be done after dispatch
+ * @param handback the hand back object to provide after dispatch to the call back
+ * @return the call back returned object
+ * @throws Exception any exception
*/
- HttpServletRequest getClientRequest();
+ Object dispatch(ServletContainerContext servletContainerContext, ServletContext
targetServletContext, RequestDispatchCallback callback, Object handback) throws
Exception;
- /**
- *
- */
- HttpServletResponse getClientResponse();
}
Show replies by date