You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/02/19 07:30:10 UTC

[09/14] git commit: Updates classes to use the new version of Dispatcher's methods without ServletContext

Updates classes to use the new version of Dispatcher's methods without ServletContext


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4da2ec65
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4da2ec65
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4da2ec65

Branch: refs/heads/develop
Commit: 4da2ec65c706e1029b827f2ca36242e05d99fb63
Parents: 9ff04d1
Author: Lukasz Lenart <lu...@apache.org>
Authored: Mon Feb 17 09:35:20 2014 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Mon Feb 17 09:35:20 2014 +0100

----------------------------------------------------------------------
 .../org/apache/struts2/validators/DWRValidator.java     | 12 +++---------
 .../struts2/portlet/dispatcher/Jsr168Dispatcher.java    |  7 ++++---
 .../sitemesh/OldDecorator2NewStrutsDecorator.java       |  2 +-
 3 files changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/4da2ec65/plugins/dwr/src/main/java/org/apache/struts2/validators/DWRValidator.java
----------------------------------------------------------------------
diff --git a/plugins/dwr/src/main/java/org/apache/struts2/validators/DWRValidator.java b/plugins/dwr/src/main/java/org/apache/struts2/validators/DWRValidator.java
index 8c9a2eb..9d6f750 100644
--- a/plugins/dwr/src/main/java/org/apache/struts2/validators/DWRValidator.java
+++ b/plugins/dwr/src/main/java/org/apache/struts2/validators/DWRValidator.java
@@ -32,22 +32,16 @@ import org.apache.struts2.dispatcher.ApplicationMap;
 import org.apache.struts2.dispatcher.Dispatcher;
 import org.apache.struts2.dispatcher.RequestMap;
 import org.apache.struts2.dispatcher.SessionMap;
-import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
 
 import uk.ltd.getahead.dwr.WebContextFactory;
 
 import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.ActionProxy;
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.DefaultActionInvocation;
 import com.opensymphony.xwork2.ValidationAware;
 import com.opensymphony.xwork2.ValidationAwareSupport;
-import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
-import com.opensymphony.xwork2.config.entities.PackageConfig;
-import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
@@ -69,8 +63,9 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
  * </pre>
  */
 public class DWRValidator {
+
     private static final Logger LOG = LoggerFactory.getLogger(DWRValidator.class);
-    
+
     public ValidationAwareSupport doPost(String namespace, String actionName, Map params) throws Exception {
         HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
         ServletContext servletContext = WebContextFactory.get().getServletContext();
@@ -91,8 +86,7 @@ public class DWRValidator {
                 session,
                 application,
                 req,
-                res,
-                servletContext);
+                res);
 
         try {
             ActionProxyFactory actionProxyFactory = du.getContainer().getInstance(ActionProxyFactory.class);

http://git-wip-us.apache.org/repos/asf/struts/blob/4da2ec65/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
----------------------------------------------------------------------
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
index 349d819..99da301 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
@@ -184,6 +184,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
     private Dispatcher dispatcherUtils;
     private ActionMapper actionMapper;
     private Container container;
+    private ServletContext servletContext;
 
     /**
      * Initialize the portlet with the init parameters from <tt>portlet.xml</tt>
@@ -201,7 +202,8 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
             params.put(name, value);
         }
 
-        dispatcherUtils = new Dispatcher(new PortletServletContext(cfg.getPortletContext()), params);
+        servletContext = new PortletServletContext(cfg.getPortletContext());
+        dispatcherUtils = new Dispatcher(servletContext, params);
         dispatcherUtils.init();
 
         // For testability
@@ -428,11 +430,10 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
         String actionName = null;
         String namespace;
         try {
-            ServletContext servletContext = new PortletServletContext(getPortletContext());
             HttpServletRequest servletRequest = new PortletServletRequest(request, getPortletContext());
             HttpServletResponse servletResponse = createPortletServletResponse(response);
             if (phase.isAction()) {
-                servletRequest = dispatcherUtils.wrapRequest(servletRequest, servletContext);
+                servletRequest = dispatcherUtils.wrapRequest(servletRequest);
                 if (servletRequest instanceof MultiPartRequestWrapper) {
                     // Multipart request. Request parameters are encoded in the multipart data,
                     // so we need to manually add them to the parameter map.

http://git-wip-us.apache.org/repos/asf/struts/blob/4da2ec65/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java
----------------------------------------------------------------------
diff --git a/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java b/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java
index 740095e..9b86adb 100644
--- a/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java
+++ b/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/OldDecorator2NewStrutsDecorator.java
@@ -97,7 +97,7 @@ public abstract class OldDecorator2NewStrutsDecorator extends BaseWebAppDecorato
         if (ctx == null) {
             // ok, one isn't associated with the request, so let's create one using the current Dispatcher
             ValueStack vs = Dispatcher.getInstance().getContainer().getInstance(ValueStackFactory.class).createValueStack();
-            vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null, servletContext));
+            vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null));
             ctx = new ActionContext(vs.getContext());
             if (ctx.getActionInvocation() == null) {
                 // put in a dummy ActionSupport so basic functionality still works