struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4838 Allows define incompatible improvements as an init-param
Date Wed, 23 Aug 2017 07:23:32 GMT
Repository: struts
Updated Branches:
  refs/heads/master 853b44611 -> 68cb702dc


WW-4838 Allows define incompatible improvements as an init-param


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

Branch: refs/heads/master
Commit: 68cb702dc8b13eb0e948a59cc3e274206019c642
Parents: 853b446
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Wed Aug 23 09:23:23 2017 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Wed Aug 23 09:23:23 2017 +0200

----------------------------------------------------------------------
 .../views/freemarker/FreemarkerManager.java       | 18 ++++++++++++++++--
 .../views/freemarker/StrutsBeanWrapper.java       |  4 +++-
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/68cb702d/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
index b1010c3..22a66e5 100644
--- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
+++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java
@@ -314,7 +314,9 @@ public class FreemarkerManager {
      * @throws TemplateException in case of errors during creating the configuration
      */
     protected Configuration createConfiguration(ServletContext servletContext) throws TemplateException
{
-        Configuration configuration = new Configuration(Configuration.VERSION_2_3_0);
+        Version incompatibleImprovements = getFreemarkerVersion(servletContext);
+
+        Configuration configuration = new Configuration(incompatibleImprovements);
 
         configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
 
@@ -340,6 +342,17 @@ public class FreemarkerManager {
         return configuration;
     }
 
+    protected Version getFreemarkerVersion(ServletContext servletContext) {
+        Version incompatibleImprovements = Configuration.VERSION_2_3_0;
+
+        String incompatibleImprovementsParam = servletContext.getInitParameter("freemarker."
+ Configuration.INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE);
+        if (incompatibleImprovementsParam != null) {
+            incompatibleImprovements = new Version(incompatibleImprovementsParam);
+        }
+
+        return incompatibleImprovements;
+    }
+
 
     protected ScopesHashModel buildScopesHashModel(ServletContext servletContext, HttpServletRequest
request, HttpServletResponse response, ObjectWrapper wrapper, ValueStack stack) {
         ScopesHashModel model = new ScopesHashModel(wrapper, servletContext, request, stack);
@@ -396,7 +409,8 @@ public class FreemarkerManager {
     }
 
     protected ObjectWrapper createObjectWrapper(ServletContext servletContext) {
-        StrutsBeanWrapper wrapper = new StrutsBeanWrapper(altMapWrapper);
+        Version incompatibleImprovements = getFreemarkerVersion(servletContext);
+        StrutsBeanWrapper wrapper = new StrutsBeanWrapper(altMapWrapper, incompatibleImprovements);
         wrapper.setUseCache(cacheBeanWrapper);
         return wrapper;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/68cb702d/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
b/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
index ad1222f..c9e7eed 100644
--- a/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
+++ b/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java
@@ -33,6 +33,7 @@ import freemarker.template.SimpleSequence;
 import freemarker.template.TemplateCollectionModel;
 import freemarker.template.TemplateHashModelEx;
 import freemarker.template.TemplateModel;
+import freemarker.template.Version;
 
 /**
  * <!-- START SNIPPET: javadoc -->
@@ -53,7 +54,8 @@ import freemarker.template.TemplateModel;
 public class StrutsBeanWrapper extends BeansWrapper {
     private boolean altMapWrapper;
 
-    public StrutsBeanWrapper(boolean altMapWrapper) {
+    public StrutsBeanWrapper(boolean altMapWrapper, Version incompatibleImprovements) {
+        super(incompatibleImprovements);
         this.altMapWrapper = altMapWrapper;
     }
 


Mime
View raw message