mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
feature #I44FT8 支持脚本语言的组件,并支持动态刷新脚本(版本特性)
This commit is contained in:
26
liteflow-script-common/pom.xml
Normal file
26
liteflow-script-common/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<version>2.5.11</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>liteflow-script-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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