expression - MVEL compileExpression vs ExecuteExpression - Stack Overflow

MVEL is used to evaluate the simple expression, user defined functions, MVEL supported expressions like

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744738037a4590865.html

相关推荐

  • expression - MVEL compileExpression vs ExecuteExpression - Stack Overflow

    MVEL is used to evaluate the simple expression, user defined functions, MVEL supported expressions like

    14小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信