Merge pull request #464 from apache/WW-5000-constants
[WW-5000] Extracts string literals as constants
diff --git a/core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java b/core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java
index 0d9f6c7..3a5c8f2 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ObjectFactory.java
@@ -31,6 +31,7 @@
import com.opensymphony.xwork2.validator.Validator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsConstants;
import java.io.Serializable;
import java.util.Map;
@@ -68,7 +69,7 @@
this.container = container;
}
- @Inject(value="objectFactory.classloader", required=false)
+ @Inject(value=StrutsConstants.STRUTS_OBJECT_FACTORY_CLASSLOADER, required=false)
public void setClassLoader(ClassLoader cl) {
this.ccl = cl;
}
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 38d250a..bfbec00 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
@@ -284,7 +284,7 @@
builder.factory(ValueSubstitutor.class, EnvsValueSubstitutor.class, Scope.SINGLETON);
builder.constant(StrutsConstants.STRUTS_DEVMODE, "false");
- builder.constant(StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, "false");
+ builder.constant(StrutsConstants.STRUTS_OGNL_LOG_MISSING_PROPERTIES, "false");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, "false");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false");
diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java
index ccdb782..f263df3 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java
@@ -219,7 +219,7 @@
props.setProperty(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_DEVMODE, Boolean.FALSE.toString());
- props.setProperty(StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, Boolean.FALSE.toString());
+ props.setProperty(StrutsConstants.STRUTS_OGNL_LOG_MISSING_PROPERTIES, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, Boolean.TRUE.toString());
props.setProperty(StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, Boolean.FALSE.toString());
diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
index ad99281..31b0075 100644
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java
@@ -30,6 +30,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
+import org.apache.struts2.StrutsConstants;
import java.util.*;
@@ -59,9 +60,9 @@
* </p>
*
* <ul>
- * <li>struts.xwork.chaining.copyErrors - set to true to copy Action Errors</li>
- * <li>struts.xwork.chaining.copyFieldErrors - set to true to copy Field Errors</li>
- * <li>struts.xwork.chaining.copyMessages - set to true to copy Action Messages</li>
+ * <li>struts.chaining.copyErrors - set to true to copy Action Errors</li>
+ * <li>struts.chaining.copyFieldErrors - set to true to copy Field Errors</li>
+ * <li>struts.chaining.copyMessages - set to true to copy Action Messages</li>
* </ul>
*
* <p>
@@ -135,17 +136,17 @@
this.reflectionProvider = prov;
}
- @Inject(value = "struts.xwork.chaining.copyErrors", required = false)
+ @Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_ERRORS, required = false)
public void setCopyErrors(String copyErrors) {
this.copyErrors = "true".equalsIgnoreCase(copyErrors);
}
- @Inject(value = "struts.xwork.chaining.copyFieldErrors", required = false)
+ @Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_FIELD_ERRORS, required = false)
public void setCopyFieldErrors(String copyFieldErrors) {
this.copyFieldErrors = "true".equalsIgnoreCase(copyFieldErrors);
}
- @Inject(value = "struts.xwork.chaining.copyMessages", required = false)
+ @Inject(value = StrutsConstants.STRUTS_CHAINING_COPY_MESSAGES, required = false)
public void setCopyMessages(String copyMessages) {
this.copyMessages = "true".equalsIgnoreCase(copyMessages);
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
index 036407b..c08da93 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
@@ -105,7 +105,7 @@
this.devMode = BooleanUtils.toBoolean(mode);
}
- @Inject(value = "logMissingProperties", required = false)
+ @Inject(value = StrutsConstants.STRUTS_OGNL_LOG_MISSING_PROPERTIES, required = false)
protected void setLogMissingProperties(String logMissingProperties) {
this.logMissingProperties = BooleanUtils.toBoolean(logMissingProperties);
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
index 6f3a682..ece1a92 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
@@ -51,12 +51,6 @@
private OgnlUtil ognlUtil;
private int autoGrowCollectionLimit = 255;
- @Deprecated()
- @Inject(value = "xwork.autoGrowCollectionLimit", required = false)
- public void setDeprecatedAutoGrowCollectionLimit(String value) {
- this.autoGrowCollectionLimit = Integer.valueOf(value);
- }
-
@Inject(value = StrutsConstants.STRUTS_OGNL_AUTO_GROWTH_COLLECTION_LIMIT, required = false)
public void setAutoGrowCollectionLimit(String value) {
this.autoGrowCollectionLimit = Integer.parseInt(value);
diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index 9e6ff62..e5ed043 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -260,8 +260,18 @@
/** Throw RuntimeException when a property is not found, or the evaluation of the expression fails */
public static final String STRUTS_EL_THROW_EXCEPTION = "struts.el.throwExceptionOnFailure";
- /** Logs properties that are not found (very verbose) */
- public static final String STRUTS_LOG_MISSING_PROPERTIES = "struts.ognl.logMissingProperties";
+ /**
+ * Logs properties that are not found (very verbose)
+ * @since 2.6
+ */
+ public static final String STRUTS_OGNL_LOG_MISSING_PROPERTIES = "struts.ognl.logMissingProperties";
+
+ /**
+ * Logs properties that are not found (very verbose)
+ * @deprecated as of 2.6. Use {@link #STRUTS_OGNL_LOG_MISSING_PROPERTIES} instead.
+ */
+ @Deprecated
+ public static final String STRUTS_LOG_MISSING_PROPERTIES = STRUTS_OGNL_LOG_MISSING_PROPERTIES;
/** Enables caching of parsed OGNL expressions */
public static final String STRUTS_ENABLE_OGNL_EXPRESSION_CACHE = "struts.ognl.enableExpressionCache";
@@ -357,4 +367,9 @@
/** See {@link com.opensymphony.xwork2.config.impl.AbstractMatcher#appendNamedParameters */
public static final String STRUTS_MATCHER_APPEND_NAMED_PARAMETERS = "struts.matcher.appendNamedParameters";
+
+ public static final String STRUTS_CHAINING_COPY_ERRORS = "struts.chaining.copyErrors";
+ public static final String STRUTS_CHAINING_COPY_FIELD_ERRORS = "struts.chaining.copyFieldErrors";
+ public static final String STRUTS_CHAINING_COPY_MESSAGES = "struts.chaining.copyMessages";
+ public static final String STRUTS_OBJECT_FACTORY_CLASSLOADER = "struts.objectFactory.classloader";
}
diff --git a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
index 6d9be83..2842155 100644
--- a/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
+++ b/core/src/main/java/org/apache/struts2/config/entities/ConstantConfig.java
@@ -230,7 +230,7 @@
map.put(StrutsConstants.STRUTS_STATIC_CONTENT_LOADER, beanConfToString(staticContentLoader));
map.put(StrutsConstants.STRUTS_UNKNOWN_HANDLER_MANAGER, beanConfToString(unknownHandlerManager));
map.put(StrutsConstants.STRUTS_EL_THROW_EXCEPTION, Objects.toString(elThrowExceptionOnFailure, null));
- map.put(StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, Objects.toString(ognlLogMissingProperties, null));
+ map.put(StrutsConstants.STRUTS_OGNL_LOG_MISSING_PROPERTIES, Objects.toString(ognlLogMissingProperties, null));
map.put(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, Objects.toString(ognlEnableExpressionCache, null));
map.put(StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, Objects.toString(ognlEnableOGNLEvalExpression, null));
map.put(StrutsConstants.STRUTS_DISABLE_REQUEST_ATTRIBUTE_VALUE_STACK_LOOKUP, Objects.toString(disableRequestAttributeValueStackLookup, null));
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
index 542efda..66c716c 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessorTest.java
@@ -83,23 +83,4 @@
assertEquals(3, vs.findValue("strings.size()"));
}
- public void testDeprecatedAutoGrowCollectionLimit() {
- PropertyAccessor accessor = container.getInstance(PropertyAccessor.class, ArrayList.class.getName());
- ((XWorkListPropertyAccessor) accessor).setDeprecatedAutoGrowCollectionLimit("2");
-
- List<String> myList = new ArrayList<>();
- ListHolder listHolder = new ListHolder();
- listHolder.setStrings(myList);
-
- ValueStack vs = ActionContext.getContext().getValueStack();
- vs.push(listHolder);
-
- vs.setValue("strings[0]", "a");
- vs.setValue("strings[1]", "b");
- vs.setValue("strings[2]", "c");
- vs.setValue("strings[3]", "d");
-
- assertEquals(3, vs.findValue("strings.size()"));
- }
-
}
diff --git a/plugins/cdi/src/main/java/org/apache/struts2/cdi/CdiObjectFactory.java b/plugins/cdi/src/main/java/org/apache/struts2/cdi/CdiObjectFactory.java
index 72272cb..31a2766 100644
--- a/plugins/cdi/src/main/java/org/apache/struts2/cdi/CdiObjectFactory.java
+++ b/plugins/cdi/src/main/java/org/apache/struts2/cdi/CdiObjectFactory.java
@@ -45,7 +45,7 @@
*/
public class CdiObjectFactory extends ObjectFactory {
- private static final Logger LOG = LogManager.getLogger(CdiObjectFactory.class);
+ private static final Logger LOG = LogManager.getLogger(CdiObjectFactory.class);
/**
* The key under which the BeanManager can be found according to CDI API docs
@@ -60,10 +60,11 @@
*/
public static final String CDI_JNDIKEY_BEANMANAGER_COMP_ENV = "java:comp/env/BeanManager";
+ public static final String STRUTS_OBJECT_FACTORY_CDI_JNDI_KEY = "struts.objectFactory.cdi.jndiKey";
private String jndiKey;
- @Inject(value = "struts.objectFactory.cdi.jndiKey", required = false)
+ @Inject(value = STRUTS_OBJECT_FACTORY_CDI_JNDI_KEY, required = false)
public void setJndiKey( String jndiKey ) {
this.jndiKey = jndiKey;
}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateConstants.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateConstants.java
new file mode 100644
index 0000000..8001c83
--- /dev/null
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateConstants.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.views.java;
+
+public class JavaTemplateConstants {
+
+ public static final String STRUTS_JAVATEMPLATES_DEFAULT_TEMPLATE_TYPE = "struts.javatemplates.defaultTemplateType";
+
+ public static final String STRUTS_JAVATEMPLATES_CUSTOM_THEMES = "struts.javatemplates.customThemes";
+
+}
diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java
index 67bb9b3..dea448c 100644
--- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java
+++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/JavaTemplateEngine.java
@@ -110,7 +110,7 @@
*
* @param themeClasses a comma delimited list of custom theme class names
*/
- @Inject(value = "struts.javatemplates.customThemes", required = false)
+ @Inject(value = JavaTemplateConstants.STRUTS_JAVATEMPLATES_CUSTOM_THEMES, required = false)
public void setThemeClasses(String themeClasses) {
StringTokenizer customThemes = new StringTokenizer(themeClasses, ",");
while (customThemes.hasMoreTokens()) {
@@ -135,7 +135,7 @@
*
* @param defaultTemplateTheme the struts default theme
*/
- @Inject(value = "struts.javatemplates.defaultTemplateType", required = false)
+ @Inject(value = JavaTemplateConstants.STRUTS_JAVATEMPLATES_DEFAULT_TEMPLATE_TYPE, required = false)
public void setDefaultTemplateType(String defaultTemplateTheme) {
// Make sure we don't set ourself as default for race condition
if (defaultTemplateTheme != null && !defaultTemplateTheme.equalsIgnoreCase(getSuffix())) {
diff --git a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java
index e6cf603..58f1fd2 100644
--- a/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java
+++ b/plugins/oval/src/main/java/org/apache/struts2/oval/interceptor/OValValidationInterceptor.java
@@ -55,6 +55,9 @@
This interceptor provides validation using the OVal validation framework
*/
public class OValValidationInterceptor extends MethodFilterInterceptor {
+
+ public static final String STRUTS_OVAL_VALIDATE_JPAANNOTATIONS = "struts.oval.validateJPAAnnotations";
+
private static final Logger LOG = LogManager.getLogger(OValValidationInterceptor.class);
protected final static String VALIDATE_PREFIX = "validate";
@@ -85,7 +88,7 @@
/**
* Enable OVal support for JPA
*/
- @Inject(value = "struts.oval.validateJPAAnnotations")
+ @Inject(value = STRUTS_OVAL_VALIDATE_JPAANNOTATIONS)
public void setValidateJPAAnnotations(String validateJPAAnnotations) {
this.validateJPAAnnotations = Boolean.parseBoolean(validateJPAAnnotations);
}