mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
feature #I44FT8 支持脚本语言的组件,并支持动态刷新脚本(版本特性)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.yomahub.liteflow.script;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yomahub.liteflow.script.exception.ScriptSpiException;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
@@ -8,7 +9,7 @@ public class ScriptFactory {
|
||||
|
||||
private static ScriptFactory scriptFactory;
|
||||
|
||||
private static ScriptExecutor scriptExecutor;
|
||||
private ScriptExecutor scriptExecutor;
|
||||
|
||||
public static ScriptFactory loadInstance(){
|
||||
if (ObjectUtil.isNull(scriptFactory)){
|
||||
@@ -20,9 +21,12 @@ public class 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;
|
||||
}else{
|
||||
throw new ScriptSpiException("script spi component failed to load");
|
||||
}
|
||||
}
|
||||
return scriptExecutor;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
package com.yomahub.liteflow.script.exception;
|
||||
|
||||
/**
|
||||
* 脚本SPI插件加载异常
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.11
|
||||
*/
|
||||
public class ScriptSpiException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
private String message;
|
||||
|
||||
public ScriptSpiException(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