You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/07/22 17:53:11 UTC
cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl ExpressionEvaluatorImpl.java
hlship 2005/07/22 08:53:11
Modified: . status.xml
framework/src/test/org/apache/tapestry/services/impl
TestExpressionEvaluator.java
framework/src/java/org/apache/tapestry/services/impl
ExpressionEvaluatorImpl.java
Log:
TAPESTRY-408: OGNL can't access a static field in a class in the webapp context
Revision Changes Path
1.170 +1 -0 jakarta-tapestry/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-tapestry/status.xml,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -r1.169 -r1.170
--- status.xml 21 Jul 2005 19:17:34 -0000 1.169
+++ status.xml 22 Jul 2005 15:53:10 -0000 1.170
@@ -63,6 +63,7 @@
<action type="fix" dev="HLS" due-to="Kent Tong" fixes-bug="TAPESTRY-406">Bean Property does not get updated from component parameter</action>
<action type="fix" dev="HLS" due-to="Laurent Etiemble" fixes-bug="TAPESTRY-425">Foreach components cannot handle primitive arrays</action>
<action type="fix" dev="HLS" due-to="Fernando" fixes-bug="TAPESTRY-424">RestartService creates HttpSession wrongfully</action>
+ <action type="fix" dev="HLS" fixes-bug="TAPESTRY-408">OGNL can't access a static field in a class in the webapp context</action>
</release>
<release version="4.0-beta-2" date="Jul 9 2005">
<action type="fix" dev="HLS" fixes-bug="TAPESTRY-356">FormConditional extends BaseComponent but has no template</action>
1.5 +23 -3 jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java
Index: TestExpressionEvaluator.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/services/impl/TestExpressionEvaluator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestExpressionEvaluator.java 18 Apr 2005 17:07:51 -0000 1.4
+++ TestExpressionEvaluator.java 22 Jul 2005 15:53:11 -0000 1.5
@@ -35,7 +35,7 @@
*/
public class TestExpressionEvaluator extends HiveMindTestCase
{
- private ExpressionEvaluator create()
+ private ExpressionEvaluatorImpl create()
{
ExpressionCache cache = new ExpressionCacheImpl();
@@ -146,13 +146,33 @@
public void testIsConstant()
{
- ExpressionEvaluator ee = create();
+ ExpressionEvaluatorImpl ee = create();
+
+ ee.setApplicationSpecification(newAppSpec());
+ ee.setContributions(Collections.EMPTY_LIST);
+
+ replayControls();
+
+ ee.initializeService();
assertEquals(true, ee.isConstant("true"));
assertEquals(true, ee.isConstant("'OGNL'"));
assertEquals(false, ee.isConstant("foo.bar"));
assertEquals(false, ee.isConstant("bar()"));
assertEquals(true, ee.isConstant("@org.apache.tapestry.Tapestry@HOME_SERVICE"));
+
+ verifyControls();
+ }
+
+ private IApplicationSpecification newAppSpec()
+ {
+ MockControl control = newControl(IApplicationSpecification.class);
+ IApplicationSpecification spec = (IApplicationSpecification) control.getMock();
+
+ spec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER);
+ control.setReturnValue(false);
+
+ return spec;
}
public void testIsConstantFail()
@@ -196,7 +216,7 @@
ee.setExpressionCache(cache);
ee.setApplicationSpecification(as);
ee.setContributions(Collections.EMPTY_LIST);
-
+
ee.initializeService();
verifyControls();
1.5 +9 -2 jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java
Index: ExpressionEvaluatorImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExpressionEvaluatorImpl.java 18 Apr 2005 17:06:38 -0000 1.4
+++ ExpressionEvaluatorImpl.java 22 Jul 2005 15:53:11 -0000 1.5
@@ -37,7 +37,7 @@
{
// Uses Thread's context class loader
- private ClassResolver _ognlResolver = new OgnlClassResolver();
+ private final ClassResolver _ognlResolver = new OgnlClassResolver();
private ExpressionCache _expressionCache;
@@ -47,6 +47,11 @@
private List _contributions;
+ // Context, with a root of null, used when evaluating an expression
+ // to see if it is a constant.
+
+ private Map _defaultContext;
+
public void setApplicationSpecification(IApplicationSpecification applicationSpecification)
{
_applicationSpecification = applicationSpecification;
@@ -68,6 +73,8 @@
OgnlRuntime.setPropertyAccessor(c.getSubjectClass(), c.getAccessor());
}
+ _defaultContext = Ognl.createDefaultContext(null, _ognlResolver, _typeConverter);
+
}
public Object read(Object target, String expression)
@@ -127,7 +134,7 @@
try
{
- return Ognl.isConstant(compiled);
+ return Ognl.isConstant(compiled, _defaultContext);
}
catch (Exception ex)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org