admin管理员组文章数量:1390794
MVEL is used to evaluate the simple expression, user defined functions, MVEL supported expressions like if else, ternary conditions.
Pseudo code:
public class expressionResolver{
MapVariableResolverFactory functionFactory = new MapVariableResolverFactory();
ParserContext parserContext = new ParserContext();
if( config has "function"){
MVEL.eval(function, functionFactory);
}else {
// read name and values from config
// <update type="String" name="colO" value="colO.concat(colR)" />
Serializable compiledExpr = MVELpileExpression(value, parserContext);
VariableResolverFactory rowResolver = new MapVariableResolverFactory(runtimeVars);
rowResolver.setNextFactory(functionFactory);
Object result = MVEL.executeExpression(expr.getCompiledExpr(), rowResolver);
}
}
Here when I have undefined function in my config file, which is been called, that should be caught during compilation and not during execution.
For eg: Here multiplyByThree is called where def has multiplyByTwo, this is caught during execution, but ideally it should be caught at compilation.
<function name="multiplyByTwo" value="def multiplyByTwo(x) { x * 2; }" />
<add type="Integer" name="multiply" value="multiplyByThree(colC))"/>
Kindly suggest any MVEL API is there which can help to capture the undefined function call during compilation.
本文标签: expressionMVEL compileExpression vs ExecuteExpressionStack Overflow
版权声明:本文标题:expression - MVEL compileExpression vs ExecuteExpression - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744738037a2622447.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论