mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-16 04:52:13 +08:00
feature #I44FT8 支持脚本语言的组件,并支持动态刷新脚本(版本特性)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.yomahub.liteflow.script;
|
||||
|
||||
/**
|
||||
* 脚本执行器
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.11
|
||||
*/
|
||||
public interface ScriptExecutor {
|
||||
|
||||
ScriptExecutor init();
|
||||
|
||||
void load(String nodeId, String script);
|
||||
|
||||
void execute(String nodeId, int slotIndex);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yomahub.liteflow.script;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public class ScriptFactory {
|
||||
|
||||
private static ScriptFactory scriptFactory;
|
||||
|
||||
private static ScriptExecutor scriptExecutor;
|
||||
|
||||
public static ScriptFactory loadInstance(){
|
||||
if (ObjectUtil.isNull(scriptFactory)){
|
||||
scriptFactory = new ScriptFactory();
|
||||
}
|
||||
return scriptFactory;
|
||||
}
|
||||
|
||||
public ScriptExecutor getScriptExecutor(){
|
||||
if (ObjectUtil.isNull(scriptExecutor)){
|
||||
ServiceLoader<ScriptExecutor> loader = ServiceLoader.load(ScriptExecutor.class);
|
||||
if (loader.iterator().hasNext()){
|
||||
scriptExecutor = loader.iterator().next().init();
|
||||
return scriptExecutor;
|
||||
}
|
||||
}
|
||||
return scriptExecutor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package com.yomahub.liteflow.script.exception;
|
||||
|
||||
/**
|
||||
* 脚本运行异常
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.11
|
||||
*/
|
||||
public class ScriptExecuteException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
private String message;
|
||||
|
||||
public ScriptExecuteException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package com.yomahub.liteflow.script.exception;
|
||||
|
||||
/**
|
||||
* 脚本加载异常
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.11
|
||||
*/
|
||||
public class ScriptLoadException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
private String message;
|
||||
|
||||
public ScriptLoadException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user