针对Script执行工具化封装
ScriptUtil.eval
执行Javascript脚本,参数为脚本字符串。栗子:
ScriptUtil.eval("print('Script test!');");
ScriptUtil.compile
编译脚本,返回一个CompiledScript
对象栗子:
CompiledScript script = ScriptUtil.compile("print('Script test!');");
try {
script.eval();
} catch (ScriptException e) {
throw new ScriptRuntimeException(e);
}