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
评论列表(0条)