// 创建 JexlBuilder
JexlBuilder jexlB = new JexlBuilder();
// 表达式调用 用户自定义函数
java.util.Map funcs = new java.util.HashMap();
funcs.put(null, new foo()); // 可以是 null或特定字符串,如果是null
jexlB.namespaces(funcs);
// 创建 JexlEngine
JexlEngine jexl = jexlB.create(); //new JexlBuilder().namespaces(funcs).create();
// 创建表达式对象
String jexlExp ="foo.test1('abc')+ test() + SUM1(1,2)"; // 表达式
JexlExpression e = jexl.createExpression(jexlExp);
// 创建context,用于传递参数
JexlContext jc = new MapContext();
jc.set("foo", new foo() );
// 执行表达式
Object o = e.evaluate(jc);