mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-4186 Removes static and uses instance value to set enableExpressionCache constant
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1519588 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -335,6 +335,7 @@ public class DefaultConfiguration implements Configuration {
|
||||
builder.constant(XWorkConstants.DEV_MODE, "false");
|
||||
builder.constant(XWorkConstants.LOG_MISSING_PROPERTIES, "false");
|
||||
builder.constant(XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, "false");
|
||||
builder.constant(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE, "true");
|
||||
builder.constant(XWorkConstants.RELOAD_XML_CONFIGURATION, "false");
|
||||
return builder.create(true);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class MockConfiguration implements Configuration {
|
||||
new XWorkConfigurationProvider().register(builder, props);
|
||||
builder.constant(XWorkConstants.DEV_MODE, "false");
|
||||
builder.constant(XWorkConstants.RELOAD_XML_CONFIGURATION, "true");
|
||||
builder.constant(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE, "true");
|
||||
container = builder.create(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ public class OgnlUtil {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OgnlUtil.class);
|
||||
private ConcurrentMap<String, Object> expressions = new ConcurrentHashMap<String, Object>();
|
||||
private final ConcurrentMap<Class, BeanInfo> beanInfoCache = new ConcurrentHashMap<Class, BeanInfo>();
|
||||
|
||||
private TypeConverter defaultConverter;
|
||||
static boolean devMode = false;
|
||||
static boolean enableExpressionCache = true;
|
||||
|
||||
private boolean devMode = false;
|
||||
private boolean enableExpressionCache = true;
|
||||
private boolean enableEvalExpression;
|
||||
|
||||
@Inject
|
||||
@@ -64,12 +64,12 @@ public class OgnlUtil {
|
||||
}
|
||||
|
||||
@Inject(XWorkConstants.DEV_MODE)
|
||||
public static void setDevMode(String mode) {
|
||||
public void setDevMode(String mode) {
|
||||
devMode = "true".equals(mode);
|
||||
}
|
||||
|
||||
@Inject(XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE)
|
||||
public static void setEnableExpressionCache(String cache) {
|
||||
public void setEnableExpressionCache(String cache) {
|
||||
enableExpressionCache = "true".equals(cache);
|
||||
}
|
||||
|
||||
@@ -464,10 +464,8 @@ public class OgnlUtil {
|
||||
|
||||
if (throwPropertyExceptions) {
|
||||
throw new ReflectionException(msg, exception);
|
||||
} else {
|
||||
if (devMode) {
|
||||
LOG.warn(msg, exception);
|
||||
}
|
||||
} else if (devMode) {
|
||||
LOG.warn(msg, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ public class OgnlUtilTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testCacheEnabled() throws OgnlException {
|
||||
OgnlUtil.setEnableExpressionCache("true");
|
||||
ognlUtil.setEnableExpressionCache("true");
|
||||
Object expr0 = ognlUtil.compile("test");
|
||||
Object expr2 = ognlUtil.compile("test");
|
||||
assertSame(expr0, expr2);
|
||||
}
|
||||
|
||||
public void testCacheDisabled() throws OgnlException {
|
||||
OgnlUtil.setEnableExpressionCache("false");
|
||||
ognlUtil.setEnableExpressionCache("false");
|
||||
Object expr0 = ognlUtil.compile("test");
|
||||
Object expr2 = ognlUtil.compile("test");
|
||||
assertNotSame(expr0, expr2);
|
||||
|
||||
Reference in New Issue
Block a user