Skip to content

Commit

Permalink
Merge pull request #522 from apache/WW-4792-constants-cleanup
Browse files Browse the repository at this point in the history
[WW-4792] Uses proper names for constants
  • Loading branch information
yasserzamani committed Jan 6, 2022
2 parents bab276e + 5c9299b commit 60e1212
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
6 changes: 0 additions & 6 deletions apps/rest-showcase/pom.xml
Expand Up @@ -114,12 +114,6 @@
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<systemProperties>
<systemProperty>
<name>xwork.loggerFactory</name>
<value>com.opensymphony.xwork2.util.logging.log4j2.Log4j2LoggerFactory</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
<webAppConfig>
Expand Down
Expand Up @@ -285,8 +285,8 @@ protected Container createBootstrapContainer(List<ContainerProvider> providers)

builder.constant(StrutsConstants.STRUTS_DEVMODE, "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_OGNL_ENABLE_EVAL_EXPRESSION, "false");
builder.constant(StrutsConstants.STRUTS_OGNL_ENABLE_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false");
builder.constant(StrutsConstants.STRUTS_I18N_RELOAD, "false");

Expand Down
Expand Up @@ -53,7 +53,7 @@ public void selfRegister() {
new StrutsDefaultConfigurationProvider().register(builder, props);
builder.constant(StrutsConstants.STRUTS_DEVMODE, "false");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
builder.constant(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_OGNL_ENABLE_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, "false");
container = builder.create(true);
}
Expand Down
Expand Up @@ -224,8 +224,8 @@ public void register(ContainerBuilder builder, LocatableProperties props)
props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_DEVMODE, 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_OGNL_ENABLE_EXPRESSION_CACHE, Boolean.TRUE.toString());
props.setProperty(StrutsConstants.STRUTS_OGNL_ENABLE_EVAL_EXPRESSION, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS, Boolean.FALSE.toString());
props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS, Boolean.TRUE.toString());
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java
Expand Up @@ -98,12 +98,12 @@ protected void setDevMode(String mode) {
this.devMode = BooleanUtils.toBoolean(mode);
}

@Inject(StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE)
@Inject(StrutsConstants.STRUTS_OGNL_ENABLE_EXPRESSION_CACHE)
protected void setEnableExpressionCache(String cache) {
enableExpressionCache = BooleanUtils.toBoolean(cache);
}

@Inject(value = StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, required = false)
@Inject(value = StrutsConstants.STRUTS_OGNL_ENABLE_EVAL_EXPRESSION, required = false)
protected void setEnableEvalExpression(String evalExpression) {
this.enableEvalExpression = BooleanUtils.toBoolean(evalExpression);
if (this.enableEvalExpression) {
Expand Down Expand Up @@ -566,7 +566,7 @@ private <T> Object compileAndExecuteMethod(String expression, Map<String, Object
public Object compile(String expression, Map<String, Object> context) throws OgnlException {
return compileAndExecute(expression, context, tree -> tree);
}

private void checkEnableEvalExpression(Object tree, Map<String, Object> context) throws OgnlException {
if (!enableEvalExpression && isEvalExpression(tree, context)) {
throw new OgnlException("Eval expressions/chained expressions have been disabled!");
Expand Down
36 changes: 27 additions & 9 deletions core/src/main/java/org/apache/struts2/StrutsConstants.java
Expand Up @@ -35,13 +35,13 @@ public final class StrutsConstants {
/** The encoding to use for localization messages */
public static final String STRUTS_I18N_ENCODING = "struts.i18n.encoding";

/**
/**
* Whether the default bundles should be searched for messages first. Can be used to modify the
* standard processing order for message lookup in TextProvider implementations.
* <p>
* Note: This control flag may not be meaningful to all provider implementations, and should be false by default.
* </p>
*
*
* @since 2.6
*/
public static final String STRUTS_I18N_SEARCH_DEFAULTBUNDLES_FIRST = "struts.i18n.search.defaultbundles.first";
Expand Down Expand Up @@ -104,10 +104,10 @@ public final class StrutsConstants {

/** Update freemarker templates cache in seconds */
public static final String STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY = "struts.freemarker.templatesCache.updateDelay";

/** Cache model instances at BeanWrapper level */
public static final String STRUTS_FREEMARKER_BEANWRAPPER_CACHE = "struts.freemarker.beanwrapperCache";

/** Maximum strong sizing for MruCacheStorage for freemarker */
public static final String STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE = "struts.freemarker.mru.max.strong.size";

Expand Down Expand Up @@ -188,7 +188,7 @@ public final class StrutsConstants {
* You can specify different prefixes that will be handled by different mappers
*/
public static final String PREFIX_BASED_MAPPER_CONFIGURATION = "struts.mapper.prefixMapping";

/** Whether the Struts filter should serve static content or not */
public static final String STRUTS_SERVE_STATIC_CONTENT = "struts.serve.static";

Expand Down Expand Up @@ -262,11 +262,29 @@ public final class StrutsConstants {
@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";
/**
* Enables caching of parsed OGNL expressions
* @since 2.6
*/
public static final String STRUTS_OGNL_ENABLE_EXPRESSION_CACHE = "struts.ognl.enableExpressionCache";

/**
* Enables caching of parsed OGNL expressions
* @deprecated as of 2.6. Use {@link #STRUTS_OGNL_ENABLE_EXPRESSION_CACHE} instead.
*/
public static final String STRUTS_ENABLE_OGNL_EXPRESSION_CACHE = STRUTS_OGNL_ENABLE_EXPRESSION_CACHE;

/**
* Enables evaluation of OGNL expressions
* @since 2.6
*/
public static final String STRUTS_OGNL_ENABLE_EVAL_EXPRESSION = "struts.ognl.enableEvalExpression";

/** Enables evaluation of OGNL expressions */
public static final String STRUTS_ENABLE_OGNL_EVAL_EXPRESSION = "struts.ognl.enableOGNLEvalExpression";
/**
* Enables evaluation of OGNL expressions
* @deprecated as of 2.6. Use {@link #STRUTS_OGNL_ENABLE_EVAL_EXPRESSION} instead.
*/
public static final String STRUTS_ENABLE_OGNL_EVAL_EXPRESSION = STRUTS_OGNL_ENABLE_EVAL_EXPRESSION;

/** The maximum length of an expression (OGNL) */
public static final String STRUTS_OGNL_EXPRESSION_MAX_LENGTH = "struts.ognl.expressionMaxLength";
Expand Down
Expand Up @@ -101,7 +101,7 @@ public class ConstantConfig {
private Boolean elThrowExceptionOnFailure;
private Boolean ognlLogMissingProperties;
private Boolean ognlEnableExpressionCache;
private Boolean ognlEnableOGNLEvalExpression;
private Boolean ognlEnableEvalExpression;
private Boolean disableRequestAttributeValueStackLookup;
private BeanConfig viewUrlHelper;
private BeanConfig converterCollection;
Expand Down Expand Up @@ -230,8 +230,8 @@ public Map<String, String> getAllAsStringsMap() {
map.put(StrutsConstants.STRUTS_UNKNOWN_HANDLER_MANAGER, beanConfToString(unknownHandlerManager));
map.put(StrutsConstants.STRUTS_EL_THROW_EXCEPTION, Objects.toString(elThrowExceptionOnFailure, 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_OGNL_ENABLE_EXPRESSION_CACHE, Objects.toString(ognlEnableExpressionCache, null));
map.put(StrutsConstants.STRUTS_OGNL_ENABLE_EVAL_EXPRESSION, Objects.toString(ognlEnableEvalExpression, null));
map.put(StrutsConstants.STRUTS_DISABLE_REQUEST_ATTRIBUTE_VALUE_STACK_LOOKUP, Objects.toString(disableRequestAttributeValueStackLookup, null));
map.put(StrutsConstants.STRUTS_URL_HELPER, beanConfToString(viewUrlHelper));
map.put(StrutsConstants.STRUTS_CONVERTER_COLLECTION, beanConfToString(converterCollection));
Expand Down Expand Up @@ -922,12 +922,12 @@ public void setOgnlEnableExpressionCache(Boolean ognlEnableExpressionCache) {
this.ognlEnableExpressionCache = ognlEnableExpressionCache;
}

public Boolean getOgnlEnableOGNLEvalExpression() {
return ognlEnableOGNLEvalExpression;
public Boolean getOgnlEnableEvalExpression() {
return ognlEnableEvalExpression;
}

public void setOgnlEnableOGNLEvalExpression(Boolean ognlEnableOGNLEvalExpression) {
this.ognlEnableOGNLEvalExpression = ognlEnableOGNLEvalExpression;
public void setOgnlEnableEvalExpression(Boolean ognlEnableEvalExpression) {
this.ognlEnableEvalExpression = ognlEnableEvalExpression;
}

public Boolean getDisableRequestAttributeValueStackLookup() {
Expand Down

0 comments on commit 60e1212

Please sign in to comment.