mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
WW-5000 Extracts string literals as constants
This commit is contained in:
@@ -31,6 +31,7 @@ import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
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 @@ public class ObjectFactory implements Serializable {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class DefaultConfiguration implements Configuration {
|
||||
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");
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ public class StrutsDefaultConfigurationProvider implements ConfigurationProvider
|
||||
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());
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
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 @@ import java.util.*;
|
||||
* </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 @@ public class ChainingInterceptor extends AbstractInterceptor {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
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);
|
||||
}
|
||||
|
||||
-6
@@ -51,12 +51,6 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor {
|
||||
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);
|
||||
|
||||
@@ -250,7 +250,7 @@ public final class StrutsConstants {
|
||||
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";
|
||||
public static final String STRUTS_OGNL_LOG_MISSING_PROPERTIES = "struts.ognl.logMissingProperties";
|
||||
|
||||
/** Enables caching of parsed OGNL expressions */
|
||||
public static final String STRUTS_ENABLE_OGNL_EXPRESSION_CACHE = "struts.ognl.enableExpressionCache";
|
||||
@@ -346,4 +346,9 @@ public final class StrutsConstants {
|
||||
|
||||
/** 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";
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class ConstantConfig {
|
||||
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));
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class XWorkListPropertyAccessorTest extends XWorkTestCase {
|
||||
|
||||
public void testDeprecatedAutoGrowCollectionLimit() {
|
||||
PropertyAccessor accessor = container.getInstance(PropertyAccessor.class, ArrayList.class.getName());
|
||||
((XWorkListPropertyAccessor) accessor).setDeprecatedAutoGrowCollectionLimit("2");
|
||||
((XWorkListPropertyAccessor) accessor).setAutoGrowCollectionLimit("2");
|
||||
|
||||
List<String> myList = new ArrayList<>();
|
||||
ListHolder listHolder = new ListHolder();
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
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 class CdiObjectFactory extends ObjectFactory {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
+27
@@ -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";
|
||||
|
||||
}
|
||||
+2
-2
@@ -110,7 +110,7 @@ public class JavaTemplateEngine extends BaseTemplateEngine {
|
||||
*
|
||||
* @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 @@ public class JavaTemplateEngine extends BaseTemplateEngine {
|
||||
*
|
||||
* @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())) {
|
||||
|
||||
+4
-1
@@ -55,6 +55,9 @@ import java.util.Map;
|
||||
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 @@ public class OValValidationInterceptor extends MethodFilterInterceptor {
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user