This is an automated email from the ASF dual-hosted git repository.

amashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new fc81832  WW-5001 Adds support for struts-conversion.properties files
     new 3d25d2f  Merge pull request #313 from lukaszlenart/WW-5001
fc81832 is described below

commit fc81832e8afbe9e47f74e4f61b74733ec66892c1
Author: Lukasz Lenart <lukaszlen...@apache.org>
AuthorDate: Tue Jan 15 08:14:12 2019 +0100

    WW-5001 Adds support for struts-conversion.properties files
---
 .../xwork2/config/impl/DefaultConfiguration.java   |  3 ++-
 .../providers/XWorkConfigurationProvider.java      |  4 ++--
 .../StrutsConversionPropertiesProcessor.java}      | 24 ++++++++++++++--------
 core/src/main/resources/struts-default.xml         |  2 +-
 .../xwork2/conversion/impl/XWorkConverterTest.java |  4 ++--
 ...roperties => test-struts-conversion.properties} |  0
 6 files changed, 23 insertions(+), 14 deletions(-)

diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
index e43efaa..42cfabb 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
@@ -42,6 +42,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.conversion.StrutsConversionPropertiesProcessor;
 import org.apache.struts2.conversion.StrutsTypeConverterHolder;
 import org.apache.struts2.conversion.StrutsTypeConverterCreator;
 
@@ -256,7 +257,7 @@ public class DefaultConfiguration implements Configuration {
         builder.factory(ValueStackFactory.class, OgnlValueStackFactory.class, 
Scope.SINGLETON);
 
         builder.factory(XWorkConverter.class, Scope.SINGLETON);
-        builder.factory(ConversionPropertiesProcessor.class, 
DefaultConversionPropertiesProcessor.class, Scope.SINGLETON);
+        builder.factory(ConversionPropertiesProcessor.class, 
StrutsConversionPropertiesProcessor.class, Scope.SINGLETON);
         builder.factory(ConversionFileProcessor.class, 
DefaultConversionFileProcessor.class, Scope.SINGLETON);
         builder.factory(ConversionAnnotationProcessor.class, 
DefaultConversionAnnotationProcessor.class, Scope.SINGLETON);
         builder.factory(TypeConverterCreator.class, 
StrutsTypeConverterCreator.class, Scope.SINGLETON);
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
 
b/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
index 1b04864..a34a421 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
@@ -54,7 +54,7 @@ import 
com.opensymphony.xwork2.conversion.impl.CollectionConverter;
 import com.opensymphony.xwork2.conversion.impl.DateConverter;
 import 
com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor;
 import com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor;
-import 
com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor;
+import org.apache.struts2.conversion.StrutsConversionPropertiesProcessor;
 import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer;
 import org.apache.struts2.conversion.StrutsTypeConverterCreator;
 import org.apache.struts2.conversion.StrutsTypeConverterHolder;
@@ -155,7 +155,7 @@ public class XWorkConfigurationProvider implements 
ConfigurationProvider {
 
                 .factory(XWorkConverter.class, Scope.SINGLETON)
                 .factory(XWorkBasicConverter.class, Scope.SINGLETON)
-                .factory(ConversionPropertiesProcessor.class, 
DefaultConversionPropertiesProcessor.class, Scope.SINGLETON)
+                .factory(ConversionPropertiesProcessor.class, 
StrutsConversionPropertiesProcessor.class, Scope.SINGLETON)
                 .factory(ConversionFileProcessor.class, 
DefaultConversionFileProcessor.class, Scope.SINGLETON)
                 .factory(ConversionAnnotationProcessor.class, 
DefaultConversionAnnotationProcessor.class, Scope.SINGLETON)
                 .factory(TypeConverterCreator.class, 
StrutsTypeConverterCreator.class, Scope.SINGLETON)
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultConversionPropertiesProcessor.java
 
b/core/src/main/java/org/apache/struts2/conversion/StrutsConversionPropertiesProcessor.java
similarity index 76%
rename from 
core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultConversionPropertiesProcessor.java
rename to 
core/src/main/java/org/apache/struts2/conversion/StrutsConversionPropertiesProcessor.java
index 7336db1..0f509df 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultConversionPropertiesProcessor.java
+++ 
b/core/src/main/java/org/apache/struts2/conversion/StrutsConversionPropertiesProcessor.java
@@ -16,19 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package com.opensymphony.xwork2.conversion.impl;
+package org.apache.struts2.conversion;
 
-import com.opensymphony.xwork2.XWorkException;
 import com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor;
 import com.opensymphony.xwork2.conversion.TypeConverter;
 import com.opensymphony.xwork2.conversion.TypeConverterCreator;
 import com.opensymphony.xwork2.conversion.TypeConverterHolder;
 import com.opensymphony.xwork2.inject.EarlyInitializable;
-import com.opensymphony.xwork2.inject.Initializable;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
+import org.apache.struts2.StrutsException;
 
 import java.io.IOException;
 import java.net.URL;
@@ -36,9 +35,13 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
-public class DefaultConversionPropertiesProcessor implements 
ConversionPropertiesProcessor, EarlyInitializable {
+public class StrutsConversionPropertiesProcessor implements 
ConversionPropertiesProcessor, EarlyInitializable {
 
-    private static final Logger LOG = 
LogManager.getLogger(DefaultConversionPropertiesProcessor.class);
+    private static final Logger LOG = 
LogManager.getLogger(StrutsConversionPropertiesProcessor.class);
+
+    private static final String STRUTS_DEFAULT_CONVERSION_PROPERTIES = 
"struts-default-conversion.properties";
+    private static final String XWORK_CONVERSION_PROPERTIES = 
"xwork-conversion.properties";
+    private static final String STRUTS_CONVERSION_PROPERTIES = 
"struts-conversion.properties";
 
     private TypeConverterCreator converterCreator;
     private TypeConverterHolder converterHolder;
@@ -56,8 +59,9 @@ public class DefaultConversionPropertiesProcessor implements 
ConversionPropertie
     @Override
     public void init() {
         LOG.debug("Processing default conversion properties files");
-        processRequired("struts-default-conversion.properties");
-        process("xwork-conversion.properties");
+        processRequired(STRUTS_DEFAULT_CONVERSION_PROPERTIES);
+        process(STRUTS_CONVERSION_PROPERTIES);
+        process(XWORK_CONVERSION_PROPERTIES);
     }
 
     public void process(String propsName) {
@@ -72,6 +76,10 @@ public class DefaultConversionPropertiesProcessor implements 
ConversionPropertie
         try {
             Iterator<URL> resources = ClassLoaderUtil.getResources(propsName, 
getClass(), true);
             while (resources.hasNext()) {
+                if (XWORK_CONVERSION_PROPERTIES.equals(propsName)) {
+                    LOG.warn("Instead of using deprecated {} please use the 
new file name {}",
+                        XWORK_CONVERSION_PROPERTIES, 
STRUTS_CONVERSION_PROPERTIES);
+                }
                 URL url = resources.next();
                 Properties props = new Properties();
                 props.load(url.openStream());
@@ -95,7 +103,7 @@ public class DefaultConversionPropertiesProcessor implements 
ConversionPropertie
             }
         } catch (IOException ex) {
             if (require) {
-                throw new XWorkException("Cannot load conversion properties 
file: "+propsName, ex);
+                throw new StrutsException("Cannot load conversion properties 
file: " + propsName, ex);
             } else {
                 LOG.debug("Cannot load conversion properties file: {}", 
propsName, ex);
             }
diff --git a/core/src/main/resources/struts-default.xml 
b/core/src/main/resources/struts-default.xml
index d4e28c3..7575b27 100644
--- a/core/src/main/resources/struts-default.xml
+++ b/core/src/main/resources/struts-default.xml
@@ -111,7 +111,7 @@
 
     <bean type="com.opensymphony.xwork2.conversion.impl.XWorkConverter" 
name="struts" class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" />
 
-    <bean 
type="com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor" 
name="struts" 
class="com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor"
 />
+    <bean 
type="com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor" 
name="struts" 
class="org.apache.struts2.conversion.StrutsConversionPropertiesProcessor" />
     <bean type="com.opensymphony.xwork2.conversion.ConversionFileProcessor" 
name="struts" 
class="com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor" 
/>
     <bean 
type="com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor" 
name="struts" 
class="com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor"
 />
     <bean type="com.opensymphony.xwork2.conversion.TypeConverterCreator" 
name="struts" class="org.apache.struts2.conversion.StrutsTypeConverterCreator" 
/>
diff --git 
a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
 
b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
index 5982cb4..1b2113c 100644
--- 
a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
+++ 
b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
@@ -466,7 +466,7 @@ public class XWorkConverterTest extends XWorkTestCase {
             Thread.currentThread().setContextClassLoader(new ClassLoader(cl) {
                 @Override
                 public Enumeration<URL> getResources(String name) throws 
IOException {
-                    if ("xwork-conversion.properties".equals(name)) {
+                    if ("struts-conversion.properties".equals(name)) {
                         return new Enumeration<URL>() {
                             boolean done = false;
                             public boolean hasMoreElements() {
@@ -481,7 +481,7 @@ public class XWorkConverterTest extends XWorkTestCase {
                                 }
 
                                 done = true;
-                                return 
getClass().getResource("/com/opensymphony/xwork2/conversion/impl/test-xwork-conversion.properties");
+                                return 
getClass().getResource("/com/opensymphony/xwork2/conversion/impl/test-struts-conversion.properties");
                             }
                         };
                     } else {
diff --git 
a/core/src/test/resources/com/opensymphony/xwork2/conversion/impl/test-xwork-conversion.properties
 
b/core/src/test/resources/com/opensymphony/xwork2/conversion/impl/test-struts-conversion.properties
similarity index 100%
rename from 
core/src/test/resources/com/opensymphony/xwork2/conversion/impl/test-xwork-conversion.properties
rename to 
core/src/test/resources/com/opensymphony/xwork2/conversion/impl/test-struts-conversion.properties

Reply via email to