struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [36/50] [abbrv] struts git commit: Simplifies logic to fetch HttpServletRequest
Date Fri, 15 Jul 2016 13:19:03 GMT
Simplifies logic to fetch HttpServletRequest


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

Branch: refs/heads/master
Commit: 4e36a54549d5d5f42b86315730c2d09312b85ea3
Parents: e53a119
Author: Lukasz Lenart <lukasz.lenart@gmail.com>
Authored: Thu Jan 14 08:17:50 2016 +0100
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Tue Jan 19 16:19:19 2016 +0100

----------------------------------------------------------------------
 .../tiles/StrutsFreeMarkerAttributeRenderer.java     | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/4e36a545/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
index 0b19b1d..5102ead 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsFreeMarkerAttributeRenderer.java
@@ -36,9 +36,8 @@ import org.apache.struts2.views.freemarker.StrutsBeanWrapper;
 import org.apache.tiles.freemarker.template.TilesFMModelRepository;
 import org.apache.tiles.impl.InvalidTemplateException;
 import org.apache.tiles.request.Request;
-import org.apache.tiles.request.jsp.JspRequest;
 import org.apache.tiles.request.render.Renderer;
-import org.apache.tiles.request.servlet.ServletRequest;
+import org.apache.tiles.request.servlet.ServletUtil;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -81,18 +80,10 @@ public class StrutsFreeMarkerAttributeRenderer implements Renderer {
      * or a ServletRequest (FreeMarker)
      */
     protected ActionContext readActionContext(Request request) {
-        ActionContext ctx = null;
-
         LOG.debug("Obtaining HttpServletRequest based on [{}]", request.getClass().getName());
 
-        if (request instanceof ServletRequest) {
-            HttpServletRequest httpRequest = ((ServletRequest) request).getRequest();
-            ctx = ServletActionContext.getActionContext(httpRequest);
-        }
-        if (request instanceof JspRequest) {
-            HttpServletRequest httpRequest = (HttpServletRequest) ((JspRequest) request).getPageContext().getRequest();
-            ctx = ServletActionContext.getActionContext(httpRequest);
-        }
+        HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
+        ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
 
         if (ctx == null) {
             LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());


Mime
View raw message