mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
新增一个验证脚本的方法
This commit is contained in:
@@ -19,12 +19,7 @@ public class JavaExecutor extends ScriptExecutor {
|
||||
@Override
|
||||
public void load(String nodeId, String script) {
|
||||
try{
|
||||
IScriptEvaluator se = CompilerFactoryFactory.getDefaultCompilerFactory(this.getClass().getClassLoader()).newScriptEvaluator();
|
||||
se.setTargetVersion(8);
|
||||
se.setReturnType(Object.class);
|
||||
se.setParameters(new String[] {"_meta"}, new Class[] {ScriptExecuteWrap.class});
|
||||
se.cook(convertScript(script));
|
||||
compiledScriptMap.put(nodeId, se);
|
||||
compiledScriptMap.put(nodeId, (IScriptEvaluator) compile(script));
|
||||
}catch (Exception e){
|
||||
String errorMsg = StrUtil.format("script loading error for node[{}],error msg:{}", nodeId, e.getMessage());
|
||||
throw new ScriptLoadException(errorMsg);
|
||||
@@ -52,6 +47,16 @@ public class JavaExecutor extends ScriptExecutor {
|
||||
return ScriptTypeEnum.JAVA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object compile(String script) throws Exception {
|
||||
IScriptEvaluator se = CompilerFactoryFactory.getDefaultCompilerFactory(this.getClass().getClassLoader()).newScriptEvaluator();
|
||||
se.setTargetVersion(8);
|
||||
se.setReturnType(Object.class);
|
||||
se.setParameters(new String[] {"_meta"}, new Class[] {ScriptExecuteWrap.class});
|
||||
se.cook(convertScript(script));
|
||||
return se;
|
||||
}
|
||||
|
||||
private String convertScript(String script){
|
||||
//替换掉public,private,protected等修饰词
|
||||
String script1 = script.replaceAll("public class", "class")
|
||||
|
||||
Reference in New Issue
Block a user