Skip to content

Commit

Permalink
Simplify OGNL code
Browse files Browse the repository at this point in the history
  • Loading branch information
emacarron committed Jun 24, 2014
1 parent a026480 commit 27e0071
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/main/java/org/apache/ibatis/scripting/xmltags/OgnlCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@

package org.apache.ibatis.scripting.xmltags;

import java.io.StringReader;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import ognl.ExpressionSyntaxException;
import ognl.Node;
import ognl.Ognl;
import ognl.OgnlException;
import ognl.OgnlParser;
import ognl.ParseException;
import ognl.TokenMgrError;

import org.apache.ibatis.builder.BuilderException;

Expand All @@ -39,7 +33,7 @@
*/
public class OgnlCache {

private static final Map<String, ognl.Node> expressionCache = new ConcurrentHashMap<String, ognl.Node>();
private static final Map<String, Object> expressionCache = new ConcurrentHashMap<String, Object>();

public static Object getValue(String expression, Object root) {
try {
Expand All @@ -51,18 +45,12 @@ public static Object getValue(String expression, Object root) {
}

private static Object parseExpression(String expression) throws OgnlException {
try {
Node node = expressionCache.get(expression);
if (node == null) {
node = new OgnlParser(new StringReader(expression)).topLevelExpression();
expressionCache.put(expression, node);
}
return node;
} catch (ParseException e) {
throw new ExpressionSyntaxException(expression, e);
} catch (TokenMgrError e) {
throw new ExpressionSyntaxException(expression, e);
Object node = expressionCache.get(expression);
if (node == null) {
node = Ognl.parseExpression(expression);
expressionCache.put(expression, node);
}
return node;
}

}

0 comments on commit 27e0071

Please sign in to comment.