加入格式化代码插件,并提交格式化后的代码
This commit is contained in:
parent
1f13db48fc
commit
ec50e3a0af
|
@ -0,0 +1 @@
|
|||
java-baseline=8
|
|
@ -1,6 +1,7 @@
|
|||
package com.yomahub.liteflow.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
|
@ -10,4 +11,5 @@ import java.lang.annotation.*;
|
|||
public @interface AliasFor {
|
||||
|
||||
String value() default "";
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.annotation;
|
|||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
|
@ -13,4 +14,5 @@ import java.lang.annotation.*;
|
|||
public @interface LiteflowCmpDefine {
|
||||
|
||||
NodeTypeEnum value() default NodeTypeEnum.COMMON;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ public @interface LiteflowMethod {
|
|||
LiteFlowMethodEnum value();
|
||||
|
||||
/**
|
||||
* 节点ID,用于区分节点
|
||||
* 默认为空 则按照Spring模式下BeanName为准。
|
||||
* 节点ID,用于区分节点 默认为空 则按照Spring模式下BeanName为准。
|
||||
* @return
|
||||
*/
|
||||
String nodeId() default "";
|
||||
|
@ -28,4 +27,5 @@ public @interface LiteflowMethod {
|
|||
* @return AnnotationNodeTypeEnum
|
||||
*/
|
||||
NodeTypeEnum nodeType() default NodeTypeEnum.COMMON;
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,5 @@ public @interface LiteflowRetry {
|
|||
int retry() default 0;
|
||||
|
||||
Class<? extends Exception>[] forExceptions() default { Exception.class };
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@ import java.lang.reflect.AnnotatedElement;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 注解工具类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class AnnoUtil {
|
||||
|
@ -47,8 +49,10 @@ public class AnnoUtil {
|
|||
private static <A extends Annotation> Object getDefaultValue(Class<A> annotationType, String property) {
|
||||
try {
|
||||
return annotationType.getMethod(property).getDefaultValue();
|
||||
}catch (Exception e){
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ package com.yomahub.liteflow.aop;
|
|||
import com.yomahub.liteflow.slot.Slot;
|
||||
|
||||
/**
|
||||
* 全局组件拦截器接口
|
||||
* 实现这个接口并注入到spring上下文即可
|
||||
* 全局组件拦截器接口 实现这个接口并注入到spring上下文即可
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public interface ICmpAroundAspect {
|
||||
|
@ -30,4 +30,5 @@ public interface ICmpAroundAspect {
|
|||
* @param slot
|
||||
*/
|
||||
void afterProcess(String nodeId, Slot slot);
|
||||
|
||||
}
|
||||
|
|
|
@ -132,15 +132,19 @@ public class LiteFlowNodeBuilder {
|
|||
return this;
|
||||
}
|
||||
try {
|
||||
List<String> scriptList = PathContentParserHolder.loadContextAware().parseContent(ListUtil.toList(filePath));
|
||||
List<String> scriptList = PathContentParserHolder.loadContextAware()
|
||||
.parseContent(ListUtil.toList(filePath));
|
||||
String script = CollUtil.getFirst(scriptList);
|
||||
setScript(script);
|
||||
|
||||
// 添加脚本文件监听
|
||||
List<String> fileAbsolutePath = PathContentParserHolder.loadContextAware().getFileAbsolutePath(ListUtil.toList(filePath));
|
||||
List<String> fileAbsolutePath = PathContentParserHolder.loadContextAware()
|
||||
.getFileAbsolutePath(ListUtil.toList(filePath));
|
||||
MonitorFile.getInstance().addMonitorFilePaths(fileAbsolutePath);
|
||||
} catch (Exception e) {
|
||||
String errMsg = StrUtil.format("An exception occurred while building the node[{}],{}", this.node.getId(), e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
String errMsg = StrUtil.format("An exception occurred while building the node[{}],{}", this.node.getId(),
|
||||
e.getMessage());
|
||||
throw new NodeBuildException(errMsg);
|
||||
}
|
||||
return this;
|
||||
|
@ -156,14 +160,17 @@ public class LiteFlowNodeBuilder {
|
|||
try {
|
||||
// 用于处理脚本 node
|
||||
if (this.node.getType().isScript()) {
|
||||
FlowBus.addScriptNode(this.node.getId(), this.node.getName(), this.node.getType(), this.node.getScript(), this.node.getLanguage());
|
||||
FlowBus.addScriptNode(this.node.getId(), this.node.getName(), this.node.getType(),
|
||||
this.node.getScript(), this.node.getLanguage());
|
||||
}
|
||||
// 用于处理普通 node
|
||||
else {
|
||||
FlowBus.addNode(this.node.getId(), this.node.getName(), this.node.getType(), this.node.getClazz());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errMsg = StrUtil.format("An exception occurred while building the node[{}],{}", this.node.getId(), e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
String errMsg = StrUtil.format("An exception occurred while building the node[{}],{}", this.node.getId(),
|
||||
e.getMessage());
|
||||
LOG.error(errMsg, e);
|
||||
throw new NodeBuildException(errMsg);
|
||||
}
|
||||
|
@ -184,4 +191,5 @@ public class LiteFlowNodeBuilder {
|
|||
throw new NodeBuildException(CollUtil.join(errorList, ",", "[", "]"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Chain基于代码形式的组装器
|
||||
* EL表达式规则专属组装器
|
||||
* Chain基于代码形式的组装器 EL表达式规则专属组装器
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.8.0
|
||||
|
@ -35,12 +34,10 @@ public class LiteFlowChainELBuilder {
|
|||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LiteFlowChainELBuilder.class);
|
||||
|
||||
|
||||
private Chain chain;
|
||||
|
||||
/**
|
||||
* //这是主体的Condition
|
||||
* //声明这个变量,而不是用chain.getConditionList的目的,是为了辅助平滑加载
|
||||
* //这是主体的Condition //声明这个变量,而不是用chain.getConditionList的目的,是为了辅助平滑加载
|
||||
* //虽然FlowBus里面的map都是CopyOnWrite类型的,但是在buildCondition的时候,为了平滑加载,所以不能事先把chain.getConditionList给设为空List
|
||||
* //所以在这里做一个缓存,等conditionList全部build完毕后,再去一次性替换chain里面的conditionList
|
||||
*/
|
||||
|
@ -100,7 +97,8 @@ public class LiteFlowChainELBuilder {
|
|||
public LiteFlowChainELBuilder setChainName(String chainName) {
|
||||
if (FlowBus.containChain(chainName)) {
|
||||
this.chain = FlowBus.getChain(chainName);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.chain.setChainName(chainName);
|
||||
}
|
||||
return this;
|
||||
|
@ -109,7 +107,8 @@ public class LiteFlowChainELBuilder {
|
|||
public LiteFlowChainELBuilder setChainId(String chainId) {
|
||||
if (FlowBus.containChain(chainId)) {
|
||||
this.chain = FlowBus.getChain(chainId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.chain.setChainId(chainId);
|
||||
}
|
||||
return this;
|
||||
|
@ -144,18 +143,19 @@ public class LiteFlowChainELBuilder {
|
|||
// 为什么只寻找第一层,而不往下寻找了呢?
|
||||
// 因为这是一个规范,如果在后面的层级中出现pre和finally,语义上也不好理解,所以pre和finally只能定义在第一层
|
||||
// 如果硬是要在后面定义,则执行的时候会忽略,相关代码已做了判断
|
||||
/*for (Executable executable : condition.getExecutableList()) {
|
||||
if (executable instanceof PreCondition) {
|
||||
this.preConditionList.add((PreCondition) executable);
|
||||
} else if (executable instanceof FinallyCondition) {
|
||||
this.finallyConditionList.add((FinallyCondition) executable);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* for (Executable executable : condition.getExecutableList()) { if
|
||||
* (executable instanceof PreCondition) {
|
||||
* this.preConditionList.add((PreCondition) executable); } else if (executable
|
||||
* instanceof FinallyCondition) {
|
||||
* this.finallyConditionList.add((FinallyCondition) executable); } }
|
||||
*/
|
||||
|
||||
// 把主要的condition加入
|
||||
this.conditionList.add(condition);
|
||||
return this;
|
||||
} catch (QLException e) {
|
||||
}
|
||||
catch (QLException e) {
|
||||
// EL 底层会包装异常,这里是曲线处理
|
||||
if (Objects.equals(e.getCause().getMessage(), DataNotFoundException.MSG)) {
|
||||
// 构建错误信息
|
||||
|
@ -163,14 +163,14 @@ public class LiteFlowChainELBuilder {
|
|||
throw new ELParseException(msg);
|
||||
}
|
||||
throw new ELParseException(e.getCause().getMessage());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ELParseException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EL表达式校验
|
||||
*
|
||||
* @param elStr EL表达式
|
||||
* @return true 校验成功 false 校验失败
|
||||
*/
|
||||
|
@ -178,7 +178,8 @@ public class LiteFlowChainELBuilder {
|
|||
try {
|
||||
LiteFlowChainELBuilder.createChain().setEL(elStr);
|
||||
return Boolean.TRUE;
|
||||
} catch (ELParseException e) {
|
||||
}
|
||||
catch (ELParseException e) {
|
||||
LOG.error(e.getMessage());
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
|
@ -209,11 +210,11 @@ public class LiteFlowChainELBuilder {
|
|||
|
||||
/**
|
||||
* 解析 EL 表达式,查找未定义的 id 并构建错误信息
|
||||
*
|
||||
* @param elStr el 表达式
|
||||
*/
|
||||
private String buildDataNotFoundExceptionMsg(String elStr) {
|
||||
String msg = String.format("[node/chain is not exist or node/chain not register]\n EL: %s", StrUtil.trim(elStr));
|
||||
String msg = String.format("[node/chain is not exist or node/chain not register]\n EL: %s",
|
||||
StrUtil.trim(elStr));
|
||||
try {
|
||||
InstructionSet parseResult = EXPRESS_RUNNER.getInstructionSetFromLocalCache(elStr);
|
||||
if (parseResult == null) {
|
||||
|
@ -229,7 +230,9 @@ public class LiteFlowChainELBuilder {
|
|||
List<String> nodeIds = CollUtil.map(FlowBus.getNodeMap().values(), Node::getId, true);
|
||||
for (String attrName : outAttrNames) {
|
||||
if (!chainIds.contains(attrName) && !nodeIds.contains(attrName)) {
|
||||
msg = String.format("[%s] is not exist or [%s] is not registered, you need to define a node or chain with id [%s] and register it \n EL: ", attrName, attrName, attrName);
|
||||
msg = String.format(
|
||||
"[%s] is not exist or [%s] is not registered, you need to define a node or chain with id [%s] and register it \n EL: ",
|
||||
attrName, attrName, attrName);
|
||||
|
||||
// 去除 EL 表达式中的空格和换行符
|
||||
String sourceEl = StrUtil.removeAll(elStr, CharUtil.SPACE, CharUtil.LF, CharUtil.CR);
|
||||
|
@ -242,21 +245,25 @@ public class LiteFlowChainELBuilder {
|
|||
}
|
||||
int commaLeftIndex = sourceEl.indexOf(StrUtil.COMMA + attrName);
|
||||
if (commaLeftIndex != -1) {
|
||||
// 需要加上 "EL: " 的长度 4,再加上 "^" 的长度 1,再加上 "," 的长度 1,indexOf 从 0 开始,所以还需要加 1
|
||||
// 需要加上 "EL: " 的长度 4,再加上 "^" 的长度 1,再加上 "," 的长度 1,indexOf 从 0
|
||||
// 开始,所以还需要加 1
|
||||
return msg + sourceEl + "\n" + StrUtil.fill("^", CharUtil.SPACE, commaLeftIndex + 7, true);
|
||||
}
|
||||
// 还有一种特殊情况,就是 EL 表达式中的节点使用 node("a")
|
||||
int nodeIndex = sourceEl.indexOf(String.format("node(\"%s\")", attrName));
|
||||
if (nodeIndex != -1) {
|
||||
// 需要加上 "EL: " 的长度 4,再加上 “node("” 长度 6,再加上 "^" 的长度 1,indexOf 从 0 开始,所以还需要加 1
|
||||
// 需要加上 "EL: " 的长度 4,再加上 “node("” 长度 6,再加上 "^" 的长度 1,indexOf 从 0
|
||||
// 开始,所以还需要加 1
|
||||
return msg + sourceEl + "\n" + StrUtil.fill("^", CharUtil.SPACE, commaLeftIndex + 12, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ public class AnyOperator extends BaseOperator<WhenCondition> {
|
|||
whenCondition.setAny(any);
|
||||
return whenCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,15 +9,13 @@ import com.yomahub.liteflow.flow.element.Node;
|
|||
import com.yomahub.liteflow.flow.element.condition.LoopCondition;
|
||||
|
||||
/**
|
||||
* EL规则中的BREAK的操作符
|
||||
* 有两种用法
|
||||
* FOR...DO...BREAK
|
||||
* WHILE...DO...BREAK
|
||||
* EL规则中的BREAK的操作符 有两种用法 FOR...DO...BREAK WHILE...DO...BREAK
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public class BreakOperator extends BaseOperator<LoopCondition> {
|
||||
|
||||
@Override
|
||||
public LoopCondition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEqTwo(objects);
|
||||
|
@ -30,9 +28,11 @@ public class BreakOperator extends BaseOperator<LoopCondition> {
|
|||
Node breakNode = OperatorHelper.convert(objects[1], Node.class);
|
||||
if (ListUtil.toList(NodeTypeEnum.BREAK, NodeTypeEnum.BREAK_SCRIPT).contains(breakNode.getType())) {
|
||||
condition.setBreakNode(breakNode);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new QLException("The parameter must be node-break item");
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,12 +6,13 @@ import com.yomahub.liteflow.flow.element.Executable;
|
|||
import com.yomahub.liteflow.flow.element.condition.CatchCondition;
|
||||
|
||||
/**
|
||||
* EL规则中的CATCH的操作符
|
||||
* 用法:CATCH...DO...
|
||||
* EL规则中的CATCH的操作符 用法:CATCH...DO...
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.10.0
|
||||
*/
|
||||
public class CatchOperator extends BaseOperator<CatchCondition> {
|
||||
|
||||
@Override
|
||||
public CatchCondition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEq(objects, 1);
|
||||
|
@ -23,4 +24,5 @@ public class CatchOperator extends BaseOperator<CatchCondition> {
|
|||
|
||||
return catchCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,4 +24,5 @@ public class DataOperator extends BaseOperator<Node> {
|
|||
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,4 +24,5 @@ public class DefaultOperator extends BaseOperator<SwitchCondition> {
|
|||
|
||||
return switchCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,16 +9,13 @@ import com.yomahub.liteflow.flow.element.condition.Condition;
|
|||
import com.yomahub.liteflow.flow.element.condition.LoopCondition;
|
||||
|
||||
/**
|
||||
* EL规则中的DO的操作符
|
||||
* 有三种用法
|
||||
* FOR...DO...BREAK
|
||||
* WHILE...DO...BREAK
|
||||
* CATCH...DO
|
||||
* EL规则中的DO的操作符 有三种用法 FOR...DO...BREAK WHILE...DO...BREAK CATCH...DO
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public class DoOperator extends BaseOperator<Condition> {
|
||||
|
||||
@Override
|
||||
public Condition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEqTwo(objects);
|
||||
|
@ -30,7 +27,8 @@ public class DoOperator extends BaseOperator<Condition> {
|
|||
Executable doExecutableItem = OperatorHelper.convert(objects[1], Executable.class);
|
||||
condition.setDoItem(doExecutableItem);
|
||||
return condition;
|
||||
}else if(objects[0] instanceof LoopCondition){
|
||||
}
|
||||
else if (objects[0] instanceof LoopCondition) {
|
||||
String errorMsg = "The caller must be LoopCondition item";
|
||||
// DO关键字有可能用在FOR后面,也有可能用于WHILE后面,所以这里要进行判断是不是这两种类型的超类LoopCondition
|
||||
LoopCondition condition = OperatorHelper.convert(objects[0], LoopCondition.class, errorMsg);
|
||||
|
@ -38,9 +36,11 @@ public class DoOperator extends BaseOperator<Condition> {
|
|||
Executable doExecutableItem = OperatorHelper.convert(objects[1], Executable.class);
|
||||
condition.setDoExecutor(doExecutableItem);
|
||||
return condition;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
String errorMsg = "The caller must be LoopCondition or CatchCondition item";
|
||||
throw new QLException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,11 +45,13 @@ public class ElifOperator extends BaseOperator<IfCondition> {
|
|||
if (loopIfCondition.getFalseCaseExecutableItem() == null) {
|
||||
loopIfCondition.setFalseCaseExecutableItem(ifConditionItem);
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loopIfCondition = (IfCondition) loopIfCondition.getFalseCaseExecutableItem();
|
||||
}
|
||||
}
|
||||
|
||||
return ifCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,11 +30,13 @@ public class ElseOperator extends BaseOperator<IfCondition> {
|
|||
if (loopIfCondition.getFalseCaseExecutableItem() == null) {
|
||||
loopIfCondition.setFalseCaseExecutableItem(elseExecutableItem);
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
loopIfCondition = (IfCondition) loopIfCondition.getFalseCaseExecutableItem();
|
||||
}
|
||||
}
|
||||
|
||||
return ifCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,4 +24,5 @@ public class FinallyOperator extends BaseOperator<FinallyCondition> {
|
|||
}
|
||||
return finallyCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.yomahub.liteflow.flow.element.condition.ForCondition;
|
|||
* @since 2.9.0
|
||||
*/
|
||||
public class ForOperator extends BaseOperator<ForCondition> {
|
||||
|
||||
@Override
|
||||
public ForCondition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEq(objects, 1);
|
||||
|
@ -29,7 +30,8 @@ public class ForOperator extends BaseOperator<ForCondition> {
|
|||
if (!ListUtil.toList(NodeTypeEnum.FOR, NodeTypeEnum.FOR_SCRIPT).contains(node.getType())) {
|
||||
throw new QLException("The parameter must be for-node item");
|
||||
}
|
||||
}else if(objects[0] instanceof Integer){
|
||||
}
|
||||
else if (objects[0] instanceof Integer) {
|
||||
Integer forCount = OperatorHelper.convert(objects[0], Integer.class);
|
||||
node = new Node();
|
||||
NodeForComponent nodeForComponent = new NodeForComponent() {
|
||||
|
@ -41,7 +43,8 @@ public class ForOperator extends BaseOperator<ForCondition> {
|
|||
nodeForComponent.setSelf(nodeForComponent);
|
||||
nodeForComponent.setNodeId(StrUtil.format("LOOP_{}", forCount));
|
||||
node.setInstance(nodeForComponent);
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
throw new QLException("The parameter must be Node item");
|
||||
}
|
||||
|
||||
|
@ -49,4 +52,5 @@ public class ForOperator extends BaseOperator<ForCondition> {
|
|||
forCondition.setForNode(node);
|
||||
return forCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,4 +24,5 @@ public class IdOperator extends BaseOperator<Condition> {
|
|||
|
||||
return condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,4 +42,5 @@ public class IfOperator extends BaseOperator<IfCondition> {
|
|||
ifCondition.setFalseCaseExecutableItem(falseCaseExecutableItem);
|
||||
return ifCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,4 +24,5 @@ public class IgnoreErrorOperator extends BaseOperator<WhenCondition> {
|
|||
|
||||
return condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.yomahub.liteflow.flow.element.Node;
|
|||
import com.yomahub.liteflow.flow.element.condition.IteratorCondition;
|
||||
|
||||
public class IteratorOperator extends BaseOperator<IteratorCondition> {
|
||||
|
||||
@Override
|
||||
public IteratorCondition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEq(objects, 1);
|
||||
|
@ -23,4 +24,5 @@ public class IteratorOperator extends BaseOperator<IteratorCondition> {
|
|||
|
||||
return iteratorCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,21 +26,33 @@ public class NodeOperator extends BaseOperator<Node> {
|
|||
|
||||
if (FlowBus.containNode(nodeId)) {
|
||||
return FlowBus.getNode(nodeId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
if (StrUtil.isNotBlank(liteflowConfig.getSubstituteCmpClass())) {
|
||||
Node substituteNode = FlowBus.getNodeMap().values().stream().filter(node
|
||||
-> node.getInstance().getClass().getName().equals(liteflowConfig.getSubstituteCmpClass())).findFirst().orElse(null);
|
||||
Node substituteNode = FlowBus.getNodeMap()
|
||||
.values()
|
||||
.stream()
|
||||
.filter(node -> node.getInstance()
|
||||
.getClass()
|
||||
.getName()
|
||||
.equals(liteflowConfig.getSubstituteCmpClass()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (ObjectUtil.isNotNull(substituteNode)) {
|
||||
return substituteNode;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String error = StrUtil.format("This node[{}] cannot be found", nodeId);
|
||||
throw new QLException(error);
|
||||
}
|
||||
} else {
|
||||
String error = StrUtil.format("This node[{}] cannot be found, or you can configure an substitute node", nodeId);
|
||||
}
|
||||
else {
|
||||
String error = StrUtil.format("This node[{}] cannot be found, or you can configure an substitute node",
|
||||
nodeId);
|
||||
throw new QLException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,4 +23,5 @@ public class PreOperator extends BaseOperator<PreCondition> {
|
|||
}
|
||||
return preCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,4 +30,5 @@ public class SwitchOperator extends BaseOperator<SwitchCondition> {
|
|||
|
||||
return switchCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,4 +26,5 @@ public class TagOperator extends BaseOperator<Node> {
|
|||
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,4 +23,5 @@ public class ThenOperator extends BaseOperator<ThenCondition> {
|
|||
}
|
||||
return thenCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ public class ThreadPoolOperator extends BaseOperator<WhenCondition> {
|
|||
|
||||
return whenCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ public class ToOperator extends BaseOperator<SwitchCondition> {
|
|||
}
|
||||
return switchCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.yomahub.liteflow.flow.element.condition.WhenCondition;
|
|||
|
||||
/**
|
||||
* EL规则中的WHEN的操作符
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -22,4 +23,5 @@ public class WhenOperator extends BaseOperator<WhenCondition> {
|
|||
}
|
||||
return whenCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.yomahub.liteflow.flow.element.condition.WhileCondition;
|
|||
* @since 2.9.0
|
||||
*/
|
||||
public class WhileOperator extends BaseOperator<WhileCondition> {
|
||||
|
||||
@Override
|
||||
public WhileCondition build(Object[] objects) throws Exception {
|
||||
OperatorHelper.checkObjectSizeEq(objects, 1);
|
||||
|
@ -28,4 +29,5 @@ public class WhileOperator extends BaseOperator<WhileCondition> {
|
|||
whileCondition.setWhileNode(node);
|
||||
return whileCondition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,19 +19,21 @@ public abstract class BaseOperator<T extends Executable> extends Operator {
|
|||
// 检查 node 和 chain 是否已经注册
|
||||
OperatorHelper.checkNodeAndChainExist(objects);
|
||||
return build(objects);
|
||||
} catch (QLException e) {
|
||||
}
|
||||
catch (QLException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ELParseException("errors occurred in EL parsing");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 EL 条件
|
||||
*
|
||||
* @param objects objects
|
||||
* @return Condition
|
||||
* @throws Exception Exception
|
||||
*/
|
||||
public abstract T build(Object[] objects) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,不等于1
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -27,7 +26,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,不等于 size
|
||||
*
|
||||
* @param objects objects
|
||||
* @param size 参数数量
|
||||
* @throws QLException QLException
|
||||
|
@ -41,7 +39,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,大于 0
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -53,7 +50,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,大于 2
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -66,7 +62,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,等于 2
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -76,7 +71,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,等于 3
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -86,7 +80,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,等于 size
|
||||
*
|
||||
* @param objects objects
|
||||
* @param size 参数数量
|
||||
* @throws QLException QLException
|
||||
|
@ -101,7 +94,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查参数数量,等于 size1 或 size2
|
||||
*
|
||||
* @param objects objects
|
||||
* @param size1 参数数量1
|
||||
* @param size2 参数数量2
|
||||
|
@ -116,10 +108,8 @@ public class OperatorHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* 转换 object 为指定的类型
|
||||
* 如果是Node类型的则进行copy
|
||||
* 为什么要进行copy呢?因为原先的Node都是存放在FlowBus的NodeMap中的。有些属性在EL中不是全局的,属于当前这个chain的。
|
||||
* 所以要进行copy动作
|
||||
* 转换 object 为指定的类型 如果是Node类型的则进行copy
|
||||
* 为什么要进行copy呢?因为原先的Node都是存放在FlowBus的NodeMap中的。有些属性在EL中不是全局的,属于当前这个chain的。 所以要进行copy动作
|
||||
*/
|
||||
public static <T> T convert(Object object, Class<T> clazz) throws QLException {
|
||||
String errorMsg = StrUtil.format("The parameter must be {} item", clazz.getSimpleName());
|
||||
|
@ -127,8 +117,7 @@ public class OperatorHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* 转换 object 为指定的类型,自定义错误信息
|
||||
* 如果是Node类型的则进行copy
|
||||
* 转换 object 为指定的类型,自定义错误信息 如果是Node类型的则进行copy
|
||||
*/
|
||||
public static <T> T convert(Object object, Class<T> clazz, String errorMsg) throws QLException {
|
||||
try {
|
||||
|
@ -136,11 +125,13 @@ public class OperatorHelper {
|
|||
if (clazz.equals(Node.class)) {
|
||||
Node node = (Node) object;
|
||||
return (T) node.copy();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return (T) object;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new QLException("An error occurred while copying an object");
|
||||
}
|
||||
|
||||
|
@ -149,7 +140,6 @@ public class OperatorHelper {
|
|||
|
||||
/**
|
||||
* 检查 node 和 chain 是否已经注册
|
||||
*
|
||||
* @param objects objects
|
||||
* @throws QLException QLException
|
||||
*/
|
||||
|
@ -160,4 +150,5 @@ public class OperatorHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,4 +90,5 @@ public class ChainPropBean {
|
|||
this.conditionType = conditionType;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -102,4 +102,5 @@ public class NodePropBean {
|
|||
this.language = language;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,4 +74,5 @@ public interface ChainConstant {
|
|||
String DEFAULT = "DEFAULT";
|
||||
|
||||
String CATCH = "CATCH";
|
||||
|
||||
}
|
||||
|
|
|
@ -4,5 +4,7 @@ package com.yomahub.liteflow.common;
|
|||
* @author Yun
|
||||
*/
|
||||
public class LocalDefaultFlowConstant {
|
||||
|
||||
public static final String DEFAULT = "default";
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.lang.annotation.*;
|
|||
|
||||
/**
|
||||
* 用于标注上下文bean的别名,以便在脚本或者组件中通过别名来获取上下文对象
|
||||
*
|
||||
* @since 2.9.7
|
||||
* @author Tingliang Wang
|
||||
*/
|
||||
|
@ -14,6 +15,7 @@ import java.lang.annotation.*;
|
|||
@Documented
|
||||
@Inherited
|
||||
public @interface ContextBean {
|
||||
|
||||
@AliasFor("name")
|
||||
String value() default "";
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ public class ComponentInitializer {
|
|||
// @LiteflowComponent标注只在spring体系下生效,这里用了spi机制取到相应环境下的实现类
|
||||
nodeComponent.setName(name);
|
||||
if (!type.isScript() && StrUtil.isBlank(nodeComponent.getName())) {
|
||||
nodeComponent.setName(LiteflowComponentSupportHolder.loadLiteflowComponentSupport().getCmpName(nodeComponent));
|
||||
nodeComponent
|
||||
.setName(LiteflowComponentSupportHolder.loadLiteflowComponentSupport().getCmpName(nodeComponent));
|
||||
}
|
||||
|
||||
// 先从组件上取@RetryCount标注,如果没有,则看全局配置,全局配置如果不配置的话,默认是0
|
||||
|
@ -57,7 +58,8 @@ public class ComponentInitializer {
|
|||
if (liteFlowRetryAnnotation != null) {
|
||||
nodeComponent.setRetryCount(liteFlowRetryAnnotation.retry());
|
||||
nodeComponent.setRetryForExceptions(liteFlowRetryAnnotation.forExceptions());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nodeComponent.setRetryCount(liteflowConfig.getRetryCount());
|
||||
}
|
||||
nodeComponent.setNodeExecutorClass(buildNodeExecutorClass(liteflowConfig));
|
||||
|
@ -69,9 +71,11 @@ public class ComponentInitializer {
|
|||
Class<?> nodeExecutorClass;
|
||||
try {
|
||||
nodeExecutorClass = Class.forName(liteflowConfig.getNodeExecutorClass());
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
return (Class<? extends NodeExecutor>) nodeExecutorClass;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ public class FlowExecutor {
|
|||
ParserClassNameSpi parserClassNameSpi = it.next();
|
||||
ruleSource = "el_xml:" + parserClassNameSpi.getSpiClassName();
|
||||
liteflowConfig.setRuleSource(ruleSource);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// ruleSource为空,而且没有spi形式的扩展,那么说明真的没有ruleSource
|
||||
// 这种情况有可能是基于代码动态构建的
|
||||
return;
|
||||
|
@ -107,7 +108,8 @@ public class FlowExecutor {
|
|||
List<String> sourceRulePathList;
|
||||
if (ReUtil.contains(PREFIX_FORMAT_CONFIG_REGEX, ruleSource)) {
|
||||
sourceRulePathList = ListUtil.toList(ruleSource);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String afterHandleRuleSource = ruleSource.replace(StrUtil.SPACE, StrUtil.EMPTY);
|
||||
sourceRulePathList = ListUtil.toList(afterHandleRuleSource.split(",|;"));
|
||||
}
|
||||
|
@ -129,11 +131,14 @@ public class FlowExecutor {
|
|||
// 解析文件
|
||||
parser.parseMain(ListUtil.toList(path));
|
||||
}
|
||||
} catch (CyclicDependencyException e) {
|
||||
}
|
||||
catch (CyclicDependencyException e) {
|
||||
LOG.error(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
String errorMsg = StrUtil.format("init flow executor cause error for path {},reason:{}", path, e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
String errorMsg = StrUtil.format("init flow executor cause error for path {},reason:{}", path,
|
||||
e.getMessage());
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new FlowExecutorNotInitException(errorMsg);
|
||||
}
|
||||
|
@ -153,27 +158,34 @@ public class FlowExecutor {
|
|||
if (parser != null) {
|
||||
// 解析文件
|
||||
parser.parseMain(rulePathList);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new ConfigErrorException("parse error, please check liteflow config property");
|
||||
}
|
||||
} catch (CyclicDependencyException e) {
|
||||
}
|
||||
catch (CyclicDependencyException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
LOG.error(e.getMessage());
|
||||
throw e;
|
||||
} catch (ChainDuplicateException e) {
|
||||
}
|
||||
catch (ChainDuplicateException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
String errorMsg = StrUtil.format("init flow executor cause error for path {},reason: {}", rulePathList, e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
String errorMsg = StrUtil.format("init flow executor cause error for path {},reason: {}", rulePathList,
|
||||
e.getMessage());
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new FlowExecutorNotInitException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是ruleSource方式的,最后判断下有没有解析出来,如果没有解析出来则报错
|
||||
if (StrUtil.isBlank(liteflowConfig.getRuleSourceExtData()) && MapUtil.isEmpty(liteflowConfig.getRuleSourceExtDataMap())) {
|
||||
if (StrUtil.isBlank(liteflowConfig.getRuleSourceExtData())
|
||||
&& MapUtil.isEmpty(liteflowConfig.getRuleSourceExtDataMap())) {
|
||||
if (FlowBus.getChainMap().isEmpty()) {
|
||||
String errMsg = StrUtil.format("no valid rule config found in rule path [{}]", liteflowConfig.getRuleSource());
|
||||
String errMsg = StrUtil.format("no valid rule config found in rule path [{}]",
|
||||
liteflowConfig.getRuleSource());
|
||||
throw new ConfigErrorException(errMsg);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +200,8 @@ public class FlowExecutor {
|
|||
try {
|
||||
addMonitorFilePaths(rulePathList);
|
||||
MonitorFile.getInstance().create();
|
||||
}catch (Exception e){
|
||||
}
|
||||
catch (Exception e) {
|
||||
String errMsg = StrUtil.format("file monitor init error for path:{}", rulePathList);
|
||||
throw new MonitorFileInitErrorException(errMsg);
|
||||
}
|
||||
|
@ -257,14 +270,15 @@ public class FlowExecutor {
|
|||
|
||||
// 调用一个流程并返回Future<LiteflowResponse>,允许多上下文的传入
|
||||
public Future<LiteflowResponse> execute2Future(String chainId, Object param, Class<?>... contextBeanClazzArray) {
|
||||
return ExecutorHelper.loadInstance().buildMainExecutor(liteflowConfig.getMainExecutorClass()).submit(()
|
||||
-> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazzArray, null));
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazzArray, null));
|
||||
}
|
||||
|
||||
|
||||
public Future<LiteflowResponse> execute2Future(String chainId, Object param, Object... contextBeanArray) {
|
||||
return ExecutorHelper.loadInstance().buildMainExecutor(liteflowConfig.getMainExecutorClass()).submit(()
|
||||
-> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, null, contextBeanArray));
|
||||
return ExecutorHelper.loadInstance()
|
||||
.buildMainExecutor(liteflowConfig.getMainExecutorClass())
|
||||
.submit(() -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, null, contextBeanArray));
|
||||
}
|
||||
|
||||
// 调用一个流程,返回默认的上下文,适用于简单的调用
|
||||
|
@ -273,32 +287,26 @@ public class FlowExecutor {
|
|||
LiteflowResponse response = this.execute2Resp(chainId, param, DefaultContext.class);
|
||||
if (!response.isSuccess()) {
|
||||
throw response.getCause();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return response.getFirstContextBean();
|
||||
}
|
||||
}
|
||||
|
||||
private LiteflowResponse execute2Resp(String chainId,
|
||||
Object param,
|
||||
Class<?>[] contextBeanClazzArray,
|
||||
private LiteflowResponse execute2Resp(String chainId, Object param, Class<?>[] contextBeanClazzArray,
|
||||
Object[] contextBeanArray) {
|
||||
Slot slot = doExecute(chainId, param, contextBeanClazzArray, contextBeanArray, null, InnerChainTypeEnum.NONE);
|
||||
return LiteflowResponse.newMainResponse(slot);
|
||||
}
|
||||
|
||||
private LiteflowResponse invoke2Resp(String chainId,
|
||||
Object param,
|
||||
Integer slotIndex, InnerChainTypeEnum innerChainType) {
|
||||
private LiteflowResponse invoke2Resp(String chainId, Object param, Integer slotIndex,
|
||||
InnerChainTypeEnum innerChainType) {
|
||||
Slot slot = doExecute(chainId, param, null, null, slotIndex, innerChainType);
|
||||
return LiteflowResponse.newInnerResponse(chainId, slot);
|
||||
}
|
||||
|
||||
private Slot doExecute(String chainId,
|
||||
Object param,
|
||||
Class<?>[] contextBeanClazzArray,
|
||||
Object[] contextBeanArray,
|
||||
Integer slotIndex,
|
||||
InnerChainTypeEnum innerChainType) {
|
||||
private Slot doExecute(String chainId, Object param, Class<?>[] contextBeanClazzArray, Object[] contextBeanArray,
|
||||
Integer slotIndex, InnerChainTypeEnum innerChainType) {
|
||||
if (FlowBus.needInit()) {
|
||||
init(true);
|
||||
}
|
||||
|
@ -308,7 +316,8 @@ public class FlowExecutor {
|
|||
// 这里可以根据class分配,也可以根据bean去分配
|
||||
if (ArrayUtil.isNotEmpty(contextBeanClazzArray)) {
|
||||
slotIndex = DataBus.offerSlotByClass(ListUtil.toList(contextBeanClazzArray));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
slotIndex = DataBus.offerSlotByBean(ListUtil.toList(contextBeanArray));
|
||||
}
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
|
@ -320,7 +329,6 @@ public class FlowExecutor {
|
|||
throw new NoAvailableSlotException("there is no available slot");
|
||||
}
|
||||
|
||||
|
||||
Slot slot = DataBus.getSlot(slotIndex);
|
||||
if (ObjectUtil.isNull(slot)) {
|
||||
throw new NoAvailableSlotException(StrUtil.format("the slot[{}] is not exist", slotIndex));
|
||||
|
@ -344,9 +352,11 @@ public class FlowExecutor {
|
|||
if (ObjectUtil.isNotNull(param)) {
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.setRequestData(param);
|
||||
} else if (innerChainType.equals(InnerChainTypeEnum.IN_SYNC)) {
|
||||
}
|
||||
else if (innerChainType.equals(InnerChainTypeEnum.IN_SYNC)) {
|
||||
slot.setChainReqData(chainId, param);
|
||||
} else if (innerChainType.equals(InnerChainTypeEnum.IN_ASYNC)) {
|
||||
}
|
||||
else if (innerChainType.equals(InnerChainTypeEnum.IN_ASYNC)) {
|
||||
slot.setChainReqData2Queue(chainId, param);
|
||||
}
|
||||
}
|
||||
|
@ -356,28 +366,36 @@ public class FlowExecutor {
|
|||
chain = FlowBus.getChain(chainId);
|
||||
|
||||
if (ObjectUtil.isNull(chain)) {
|
||||
String errorMsg = StrUtil.format("[{}]:couldn't find chain with the id[{}]", slot.getRequestId(), chainId);
|
||||
String errorMsg = StrUtil.format("[{}]:couldn't find chain with the id[{}]", slot.getRequestId(),
|
||||
chainId);
|
||||
throw new ChainNotFoundException(errorMsg);
|
||||
}
|
||||
// 执行chain
|
||||
chain.execute(slotIndex);
|
||||
} catch (ChainEndException e) {
|
||||
}
|
||||
catch (ChainEndException e) {
|
||||
if (ObjectUtil.isNotNull(chain)) {
|
||||
String warnMsg = StrUtil.format("[{}]:chain[{}] execute end on slot[{}]", slot.getRequestId(), chain.getChainName(), slotIndex);
|
||||
String warnMsg = StrUtil.format("[{}]:chain[{}] execute end on slot[{}]", slot.getRequestId(),
|
||||
chain.getChainName(), slotIndex);
|
||||
LOG.warn(warnMsg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (ObjectUtil.isNotNull(chain)) {
|
||||
String errMsg = StrUtil.format("[{}]:chain[{}] execute error on slot[{}]", slot.getRequestId(), chain.getChainName(), slotIndex);
|
||||
String errMsg = StrUtil.format("[{}]:chain[{}] execute error on slot[{}]", slot.getRequestId(),
|
||||
chain.getChainName(), slotIndex);
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.error(errMsg, e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOG.error(errMsg);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOG.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -386,10 +404,12 @@ public class FlowExecutor {
|
|||
// 如果是隐式流程,则需要设置到隐式流程的exception属性里
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.setException(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
slot.setSubException(chainId, e);
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.printStep();
|
||||
DataBus.releaseSlot(slotIndex);
|
||||
|
@ -410,7 +430,6 @@ public class FlowExecutor {
|
|||
|
||||
/**
|
||||
* 添加监听文件路径
|
||||
*
|
||||
* @param pathList 文件路径
|
||||
*/
|
||||
private void addMonitorFilePaths(List<String> pathList) throws Exception {
|
||||
|
@ -418,4 +437,5 @@ public class FlowExecutor {
|
|||
List<String> fileAbsolutePath = PathContentParserHolder.loadContextAware().getFileAbsolutePath(pathList);
|
||||
MonitorFile.getInstance().addMonitorFilePaths(fileAbsolutePath);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,4 +32,5 @@ public class FlowExecutorHolder {
|
|||
public static void clean() {
|
||||
flowExecutor = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,8 @@ import java.util.List;
|
|||
import java.util.function.BooleanSupplier;
|
||||
|
||||
/**
|
||||
* 流程初始化的钩子类,所有的钩子都放在这里
|
||||
* 目前钩子主要是放一些第三方中间件的规则监听
|
||||
* 放的钩子要求都是无入参无返回的,所以这里是BooleanSupplier
|
||||
* 流程初始化的钩子类,所有的钩子都放在这里 目前钩子主要是放一些第三方中间件的规则监听 放的钩子要求都是无入参无返回的,所以这里是BooleanSupplier
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.4
|
||||
*/
|
||||
|
@ -30,4 +29,5 @@ public class FlowInitHook {
|
|||
public static void cleanHook() {
|
||||
supplierList.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,12 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
|||
|
||||
/**
|
||||
* 循环跳出节点逻辑抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public abstract class NodeBreakComponent extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
boolean breakFlag = processBreak();
|
||||
|
@ -18,4 +20,5 @@ public abstract class NodeBreakComponent extends NodeComponent{
|
|||
}
|
||||
|
||||
public abstract boolean processBreak() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 普通组件抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public abstract class NodeComponent {
|
||||
|
@ -64,8 +65,7 @@ public abstract class NodeComponent{
|
|||
private final TransmittableThreadLocal<Node> refNodeTL = new TransmittableThreadLocal<>();
|
||||
|
||||
/**
|
||||
*******************以下的属性为线程附加属性********************
|
||||
* 线程属性是指每一个request的值都是不一样的
|
||||
******************* 以下的属性为线程附加属性******************** 线程属性是指每一个request的值都是不一样的
|
||||
* 这里NodeComponent是单例,所以要用ThreadLocal来修饰
|
||||
*/
|
||||
|
||||
|
@ -89,7 +89,6 @@ public abstract class NodeComponent{
|
|||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
|
||||
|
||||
try {
|
||||
// 前置处理
|
||||
self.beforeProcess();
|
||||
|
@ -102,7 +101,8 @@ public abstract class NodeComponent{
|
|||
|
||||
// 步骤状态设为true
|
||||
cmpStep.setSuccess(true);
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch (Exception e) {
|
||||
// 步骤状态设为false,并加入异常
|
||||
cmpStep.setSuccess(false);
|
||||
cmpStep.setException(e);
|
||||
|
@ -111,18 +111,22 @@ public abstract class NodeComponent{
|
|||
// 这里要注意,失败方法本身抛出错误,只打出堆栈,往外抛出的还是主要的异常
|
||||
try {
|
||||
self.onError();
|
||||
}catch (Exception ex){
|
||||
String errMsg = StrUtil.format("[{}]:component[{}] onError method happens exception",slot.getRequestId(),this.getDisplayName());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
String errMsg = StrUtil.format("[{}]:component[{}] onError method happens exception",
|
||||
slot.getRequestId(), this.getDisplayName());
|
||||
LOG.error(errMsg);
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
// 后置处理
|
||||
self.afterProcess();
|
||||
|
||||
stopWatch.stop();
|
||||
final long timeSpent = stopWatch.getTotalTimeMillis();
|
||||
LOG.debug("[{}]:component[{}] finished in {} milliseconds",slot.getRequestId(),this.getDisplayName(),timeSpent);
|
||||
LOG.debug("[{}]:component[{}] finished in {} milliseconds", slot.getRequestId(), this.getDisplayName(),
|
||||
timeSpent);
|
||||
|
||||
// 往CmpStep中放入时间消耗信息
|
||||
cmpStep.setTimeSpent(timeSpent);
|
||||
|
@ -170,7 +174,8 @@ public abstract class NodeComponent{
|
|||
Boolean isEnd = isEndTL.get();
|
||||
if (ObjectUtil.isNull(isEnd)) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return isEndTL.get();
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +318,8 @@ public abstract class NodeComponent{
|
|||
public String getDisplayName() {
|
||||
if (StrUtil.isEmpty(this.name)) {
|
||||
return this.nodeId;
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
return StrUtil.format("{}({})", this.nodeId, this.name);
|
||||
}
|
||||
}
|
||||
|
@ -370,4 +376,5 @@ public abstract class NodeComponent{
|
|||
public LiteflowResponse invoke2RespInAsync(String chainId, Object param) {
|
||||
return FlowExecutorHolder.loadInstance().invoke2RespInAsync(chainId, param, this.getSlotIndex());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
|||
|
||||
/**
|
||||
* FOR计数节点抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
|
@ -19,4 +20,5 @@ public abstract class NodeForComponent extends NodeComponent{
|
|||
}
|
||||
|
||||
public abstract int processFor() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
|||
|
||||
/**
|
||||
* IF节点抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.8.5
|
||||
*/
|
||||
|
@ -17,4 +18,5 @@ public abstract class NodeIfComponent extends NodeComponent{
|
|||
}
|
||||
|
||||
public abstract boolean processIf() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Iterator;
|
|||
|
||||
/**
|
||||
* ITERATOR迭代器循环组件抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.7
|
||||
*/
|
||||
|
@ -21,4 +22,5 @@ public abstract class NodeIteratorComponent extends NodeComponent{
|
|||
}
|
||||
|
||||
public abstract Iterator<?> processIterator() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
|||
|
||||
/**
|
||||
* 条件路由节点抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public abstract class NodeSwitchComponent extends NodeComponent {
|
||||
|
|
|
@ -5,10 +5,12 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
|
|||
|
||||
/**
|
||||
* WHILE条件节点抽象类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public abstract class NodeWhileComponent extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
boolean whileFlag = processWhile();
|
||||
|
@ -18,4 +20,5 @@ public abstract class NodeWhileComponent extends NodeComponent{
|
|||
}
|
||||
|
||||
public abstract boolean processWhile() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本BREAK节点
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public class ScriptBreakComponent extends NodeBreakComponent implements ScriptComponent {
|
||||
|
||||
@Override
|
||||
public boolean processBreak() throws Exception {
|
||||
ScriptExecuteWrap wrap = new ScriptExecuteWrap();
|
||||
|
@ -19,11 +21,14 @@ public class ScriptBreakComponent extends NodeBreakComponent implements ScriptCo
|
|||
wrap.setSlotIndex(this.getSlotIndex());
|
||||
wrap.setTag(this.getTag());
|
||||
wrap.setCmpData(this.getCmpData(Map.class));
|
||||
return (boolean) ScriptExecutorFactory.loadInstance().getScriptExecutor(this.getRefNode().getLanguage()).execute(wrap);
|
||||
return (boolean) ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(this.getRefNode().getLanguage())
|
||||
.execute(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本组件类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.0
|
||||
*/
|
||||
|
@ -32,4 +33,5 @@ public class ScriptCommonComponent extends NodeComponent implements ScriptCompon
|
|||
log.info("load script for component[{}]", getDisplayName());
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,26 +7,30 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本接口
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public interface ScriptComponent {
|
||||
|
||||
/**
|
||||
* 用于维护脚本类型和脚本 cmp 的映射关系
|
||||
*/
|
||||
Map<NodeTypeEnum, Class<?>> ScriptComponentClassMap = new HashMap<NodeTypeEnum, Class<?>>() {{
|
||||
Map<NodeTypeEnum, Class<?>> ScriptComponentClassMap = new HashMap<NodeTypeEnum, Class<?>>() {
|
||||
{
|
||||
put(NodeTypeEnum.SCRIPT, ScriptCommonComponent.class);
|
||||
put(NodeTypeEnum.SWITCH_SCRIPT, ScriptSwitchComponent.class);
|
||||
put(NodeTypeEnum.IF_SCRIPT, ScriptIfComponent.class);
|
||||
put(NodeTypeEnum.FOR_SCRIPT, ScriptForComponent.class);
|
||||
put(NodeTypeEnum.WHILE_SCRIPT, ScriptWhileComponent.class);
|
||||
put(NodeTypeEnum.BREAK_SCRIPT, ScriptBreakComponent.class);
|
||||
}};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 加载脚本
|
||||
* @param script
|
||||
*/
|
||||
void loadScript(String script, String language);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本FOR节点
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public class ScriptForComponent extends NodeForComponent implements ScriptComponent {
|
||||
|
||||
@Override
|
||||
public int processFor() throws Exception {
|
||||
ScriptExecuteWrap wrap = new ScriptExecuteWrap();
|
||||
|
@ -19,11 +21,14 @@ public class ScriptForComponent extends NodeForComponent implements ScriptCompon
|
|||
wrap.setSlotIndex(this.getSlotIndex());
|
||||
wrap.setTag(this.getTag());
|
||||
wrap.setCmpData(this.getCmpData(Map.class));
|
||||
return (int) ScriptExecutorFactory.loadInstance().getScriptExecutor(this.getRefNode().getLanguage()).execute(wrap);
|
||||
return (int) ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(this.getRefNode().getLanguage())
|
||||
.execute(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本IF节点
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.8.5
|
||||
*/
|
||||
public class ScriptIfComponent extends NodeIfComponent implements ScriptComponent {
|
||||
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
ScriptExecuteWrap wrap = new ScriptExecuteWrap();
|
||||
|
@ -19,11 +21,14 @@ public class ScriptIfComponent extends NodeIfComponent implements ScriptComponen
|
|||
wrap.setSlotIndex(this.getSlotIndex());
|
||||
wrap.setTag(this.getTag());
|
||||
wrap.setCmpData(this.getCmpData(Map.class));
|
||||
return (boolean)ScriptExecutorFactory.loadInstance().getScriptExecutor(this.getRefNode().getLanguage()).execute(wrap);
|
||||
return (boolean) ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(this.getRefNode().getLanguage())
|
||||
.execute(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本条件节点
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.0
|
||||
*/
|
||||
|
@ -20,11 +21,14 @@ public class ScriptSwitchComponent extends NodeSwitchComponent implements Script
|
|||
wrap.setSlotIndex(this.getSlotIndex());
|
||||
wrap.setTag(this.getTag());
|
||||
wrap.setCmpData(this.getCmpData(Map.class));
|
||||
return (String)ScriptExecutorFactory.loadInstance().getScriptExecutor(this.getRefNode().getLanguage()).execute(wrap);
|
||||
return (String) ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(this.getRefNode().getLanguage())
|
||||
.execute(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 脚本WHILE节点
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.0
|
||||
*/
|
||||
|
@ -20,11 +21,14 @@ public class ScriptWhileComponent extends NodeWhileComponent implements ScriptCo
|
|||
wrap.setSlotIndex(this.getSlotIndex());
|
||||
wrap.setTag(this.getTag());
|
||||
wrap.setCmpData(this.getCmpData(Map.class));
|
||||
return (boolean) ScriptExecutorFactory.loadInstance().getScriptExecutor(this.getRefNode().getLanguage()).execute(wrap);
|
||||
return (boolean) ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(this.getRefNode().getLanguage())
|
||||
.execute(wrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadScript(String script, String language) {
|
||||
ScriptExecutorFactory.loadInstance().getScriptExecutor(language).load(getNodeId(), script);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
/**
|
||||
* 声明式组件的代理核心生成类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.14
|
||||
*/
|
||||
|
@ -58,15 +59,14 @@ public class ComponentProxy {
|
|||
Class<?> beanClazz;
|
||||
if (LiteFlowProxyUtil.isCglibProxyClass(bean.getClass())) {
|
||||
beanClazz = LiteFlowProxyUtil.getUserClass(bean.getClass());
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
beanClazz = bean.getClass();
|
||||
}
|
||||
// 得到当前bean里所覆盖的LiteflowMethod(一定是被@LiteFlowMethod修饰的),自己定义的不算
|
||||
Map<String, List<Method>> methodListMap = Arrays.stream(beanClazz.getMethods()).filter(
|
||||
m -> m.getAnnotation(LiteflowMethod.class) != null
|
||||
).collect(Collectors.groupingBy(
|
||||
m -> m.getAnnotation(LiteflowMethod.class).nodeId()
|
||||
));
|
||||
Map<String, List<Method>> methodListMap = Arrays.stream(beanClazz.getMethods())
|
||||
.filter(m -> m.getAnnotation(LiteflowMethod.class) != null)
|
||||
.collect(Collectors.groupingBy(m -> m.getAnnotation(LiteflowMethod.class).nodeId()));
|
||||
|
||||
return methodListMap.entrySet().stream().map(entry -> {
|
||||
// 获取当前节点的原有注解,如:LiteFlowRetry 之类的规则注解
|
||||
|
@ -77,11 +77,13 @@ public class ComponentProxy {
|
|||
// 获取当前bean 真实的nodeId
|
||||
String activeNodeId = isMethodCreate ? entry.getKey() : nodeId;
|
||||
// 获取当前节点所有的@LiteflowRetry @LiteflowMethod注解对
|
||||
List<Tuple> tupleList = entry.getValue().stream().map(m ->
|
||||
new Tuple(m.getAnnotation(LiteflowRetry.class), m.getAnnotation(LiteflowMethod.class))
|
||||
).collect(Collectors.toList());
|
||||
List<Tuple> tupleList = entry.getValue()
|
||||
.stream()
|
||||
.map(m -> new Tuple(m.getAnnotation(LiteflowRetry.class), m.getAnnotation(LiteflowMethod.class)))
|
||||
.collect(Collectors.toList());
|
||||
// 获取当前节点的所有LiteFlowMethod注解
|
||||
List<LiteflowMethod> methodList = tupleList.stream().map(tuple -> ((LiteflowMethod)tuple.get(1)))
|
||||
List<LiteflowMethod> methodList = tupleList.stream()
|
||||
.map(tuple -> ((LiteflowMethod) tuple.get(1)))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
// nodeType去重
|
||||
|
@ -93,13 +95,13 @@ public class ComponentProxy {
|
|||
// 相同nodeId里只能定义同一种的类型的NodeComponent
|
||||
boolean legal = classes.size() == 1;
|
||||
if (!legal) {
|
||||
throw new LiteFlowException("The cmpClass of the same nodeId must be the same,you declared nodeId:" + activeNodeId + ",cmpClass:" + classes);
|
||||
throw new LiteFlowException("The cmpClass of the same nodeId must be the same,you declared nodeId:"
|
||||
+ activeNodeId + ",cmpClass:" + classes);
|
||||
}
|
||||
// 当前节点实际LiteflowRetry注解
|
||||
AtomicReference<LiteflowRetry> liteflowRetryAtomicReference = new AtomicReference<>(null);
|
||||
// 相同nodeId只能有一个LiteflowRetry定义方法,且必须再Process方法上
|
||||
boolean illegal = tupleList.stream().anyMatch(
|
||||
tuple -> {
|
||||
boolean illegal = tupleList.stream().anyMatch(tuple -> {
|
||||
LiteflowRetry liteflowRetry = tuple.get(0);
|
||||
LiteflowMethod liteflowMethod = tuple.get(1);
|
||||
boolean existRetry = liteflowRetry != null;
|
||||
|
@ -110,10 +112,10 @@ public class ComponentProxy {
|
|||
}
|
||||
// 如果存在existRetry注解,但是不是在Process方法上,则为非法
|
||||
return existRetry && !isProcess;
|
||||
}
|
||||
);
|
||||
});
|
||||
if (illegal) {
|
||||
throw new LiteFlowException("the retry annotation (@LiteflowRetry) must be declared on the PROCESS method");
|
||||
throw new LiteFlowException(
|
||||
"the retry annotation (@LiteflowRetry) must be declared on the PROCESS method");
|
||||
}
|
||||
// 生成nodeCmp的类型,默认为全局定义的clazz
|
||||
Class<?> cmpClazz;
|
||||
|
@ -138,11 +140,10 @@ public class ComponentProxy {
|
|||
// 生成的对象也加了上被代理对象拥有的注解
|
||||
// 被拦截的对象也根据被代理对象根据@LiteFlowMethod所标注的进行了动态判断
|
||||
Object instance = new ByteBuddy().subclass(cmpClazz)
|
||||
.name(StrUtil.format("{}.ByteBuddy${}${}",
|
||||
ClassUtil.getPackage(beanClazz),
|
||||
activeNodeId,
|
||||
.name(StrUtil.format("{}.ByteBuddy${}${}", ClassUtil.getPackage(beanClazz), activeNodeId,
|
||||
SerialsUtil.generateShortUUID()))
|
||||
.method(ElementMatchers.namedOneOf(methodList.stream().map(m -> m.value().getMethodName()).toArray(String[]::new)))
|
||||
.method(ElementMatchers
|
||||
.namedOneOf(methodList.stream().map(m -> m.value().getMethodName()).toArray(String[]::new)))
|
||||
.intercept(InvocationHandlerAdapter.of(new AopInvocationHandler(bean)))
|
||||
.annotateType(beanClassAnnotation)
|
||||
.make()
|
||||
|
@ -153,7 +154,8 @@ public class ComponentProxy {
|
|||
// 重设nodeId
|
||||
nodeComponent.setNodeId(activeNodeId);
|
||||
return nodeComponent;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new LiteFlowException(e);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -181,7 +183,8 @@ public class ComponentProxy {
|
|||
}).filter(m -> {
|
||||
// 过滤不属于当前NodeComponent的方法
|
||||
LiteflowMethod liteFlowMethod = m.getAnnotation(LiteflowMethod.class);
|
||||
return StrUtil.isEmpty(liteFlowMethod.nodeId())|| Objects.equals(liteFlowMethod.nodeId(),((NodeComponent) proxy).getNodeId());
|
||||
return StrUtil.isEmpty(liteFlowMethod.nodeId())
|
||||
|| Objects.equals(liteFlowMethod.nodeId(), ((NodeComponent) proxy).getNodeId());
|
||||
}).map(m -> {
|
||||
LiteflowMethod liteFlowMethod = m.getAnnotation(LiteflowMethod.class);
|
||||
return new LiteFlowMethodBean(liteFlowMethod.value().getMethodName(), m);
|
||||
|
@ -189,26 +192,32 @@ public class ComponentProxy {
|
|||
|
||||
// 获取当前调用方法,是否在被代理的对象方法里面(根据@LiteFlowMethod这个标注去判断)
|
||||
// 如果在里面,则返回那个LiteFlowMethodBean,不在则返回null
|
||||
LiteFlowMethodBean liteFlowMethodBean = liteFlowMethodBeanList.stream().filter(
|
||||
liteFlowMethodBean1 -> liteFlowMethodBean1.getMethodName().equals(method.getName())
|
||||
).findFirst().orElse(null);
|
||||
LiteFlowMethodBean liteFlowMethodBean = liteFlowMethodBeanList.stream()
|
||||
.filter(liteFlowMethodBean1 -> liteFlowMethodBean1.getMethodName().equals(method.getName()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// 如果被代理的对象里有此标注标的方法,则调用此被代理的对象里的方法,如果没有,则调用父类里的方法
|
||||
// 进行检查,检查被代理的bean里是否有且仅有NodeComponent这个类型的参数
|
||||
boolean checkFlag = liteFlowMethodBean.getMethod().getParameterTypes().length == 1
|
||||
&& Arrays.asList(liteFlowMethodBean.getMethod().getParameterTypes()).contains(NodeComponent.class);
|
||||
if (!checkFlag) {
|
||||
String errMsg = StrUtil.format("Method[{}.{}] must have NodeComponent parameter(and only one parameter)", bean.getClass().getName(), liteFlowMethodBean.getMethod().getName());
|
||||
String errMsg = StrUtil.format(
|
||||
"Method[{}.{}] must have NodeComponent parameter(and only one parameter)",
|
||||
bean.getClass().getName(), liteFlowMethodBean.getMethod().getName());
|
||||
LOG.error(errMsg);
|
||||
throw new ComponentMethodDefineErrorException(errMsg);
|
||||
}
|
||||
|
||||
try {
|
||||
return liteFlowMethodBean.getMethod().invoke(bean, proxy);
|
||||
}catch (Exception e){
|
||||
}
|
||||
catch (Exception e) {
|
||||
InvocationTargetException targetEx = (InvocationTargetException) e;
|
||||
throw targetEx.getTargetException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,4 +31,5 @@ public class LiteFlowMethodBean {
|
|||
public void setMethod(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,10 +9,11 @@ package com.yomahub.liteflow.enums;
|
|||
|
||||
/**
|
||||
* 组件步骤类型
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public enum CmpStepTypeEnum {
|
||||
START,
|
||||
END,
|
||||
SINGLE;
|
||||
|
||||
START, END, SINGLE;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,10 @@ package com.yomahub.liteflow.enums;
|
|||
* @author Yun
|
||||
*/
|
||||
public enum ConditionTypeEnum {
|
||||
TYPE_THEN("then","then"),
|
||||
TYPE_WHEN("when","when"),
|
||||
TYPE_SWITCH("switch", "switch"),
|
||||
|
||||
TYPE_IF("if", "if"),
|
||||
TYPE_PRE("pre","pre"),
|
||||
TYPE_FINALLY("finally","finally"),
|
||||
TYPE_THEN("then", "then"), TYPE_WHEN("when", "when"), TYPE_SWITCH("switch", "switch"),
|
||||
|
||||
TYPE_IF("if", "if"), TYPE_PRE("pre", "pre"), TYPE_FINALLY("finally", "finally"),
|
||||
|
||||
TYPE_FOR("for", "for"),
|
||||
|
||||
|
@ -18,9 +15,10 @@ public enum ConditionTypeEnum {
|
|||
|
||||
TYPE_ITERATOR("iterator", "iterator"),
|
||||
|
||||
TYPE_CATCH("catch", "catch")
|
||||
;
|
||||
TYPE_CATCH("catch", "catch");
|
||||
|
||||
private String type;
|
||||
|
||||
private String name;
|
||||
|
||||
ConditionTypeEnum(String type, String name) {
|
||||
|
@ -52,4 +50,5 @@ public enum ConditionTypeEnum {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,11 @@ package com.yomahub.liteflow.enums;
|
|||
|
||||
/**
|
||||
* 可执行节点枚举
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public enum ExecuteTypeEnum {
|
||||
|
||||
CHAIN, CONDITION, NODE
|
||||
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ package com.yomahub.liteflow.enums;
|
|||
* @since 2.5.0
|
||||
*/
|
||||
public enum FlowParserTypeEnum {
|
||||
TYPE_XML("xml", "xml"),
|
||||
TYPE_YML("yml", "yml"),
|
||||
TYPE_JSON("json", "json"),
|
||||
TYPE_EL_XML("el_xml", "el_xml"),
|
||||
TYPE_EL_JSON("el_json", "el_json"),
|
||||
TYPE_EL_YML("el_yml", "el_yml")
|
||||
;
|
||||
|
||||
TYPE_XML("xml", "xml"), TYPE_YML("yml", "yml"), TYPE_JSON("json", "json"), TYPE_EL_XML("el_xml", "el_xml"),
|
||||
TYPE_EL_JSON("el_json", "el_json"), TYPE_EL_YML("el_yml", "el_yml");
|
||||
|
||||
private String type;
|
||||
|
||||
private String name;
|
||||
|
||||
FlowParserTypeEnum(String type, String name) {
|
||||
|
|
|
@ -2,14 +2,17 @@ package com.yomahub.liteflow.enums;
|
|||
|
||||
/**
|
||||
* 隐式流程类型
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.8.5
|
||||
*/
|
||||
public enum InnerChainTypeEnum {
|
||||
|
||||
// 不是隐式chain
|
||||
NONE,
|
||||
// 在串行环境中执行
|
||||
IN_SYNC,
|
||||
// 在并行环境中执行
|
||||
IN_ASYNC
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
package com.yomahub.liteflow.enums;
|
||||
|
||||
public enum LiteFlowMethodEnum {
|
||||
PROCESS("process", true),
|
||||
PROCESS_SWITCH("processSwitch", true),
|
||||
PROCESS_IF("processIf", true),
|
||||
PROCESS_FOR("processFor", true),
|
||||
PROCESS_WHILE("processWhile", true),
|
||||
PROCESS_BREAK("processBreak", true),
|
||||
|
||||
PROCESS("process", true), PROCESS_SWITCH("processSwitch", true), PROCESS_IF("processIf", true),
|
||||
PROCESS_FOR("processFor", true), PROCESS_WHILE("processWhile", true), PROCESS_BREAK("processBreak", true),
|
||||
|
||||
PROCESS_ITERATOR("processIterator", true),
|
||||
|
||||
IS_ACCESS("isAccess", false),
|
||||
|
||||
IS_END("isEnd", false),
|
||||
IS_CONTINUE_ON_ERROR("isContinueOnError", false),
|
||||
IS_END("isEnd", false), IS_CONTINUE_ON_ERROR("isContinueOnError", false),
|
||||
|
||||
GET_NODE_EXECUTOR_CLASS("getNodeExecutorClass", false),
|
||||
|
||||
|
@ -49,4 +45,5 @@ public enum LiteFlowMethodEnum {
|
|||
public void setMainMethod(boolean mainMethod) {
|
||||
isMainMethod = mainMethod;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public enum NodeTypeEnum {
|
|||
private static final Logger LOG = LoggerFactory.getLogger(NodeTypeEnum.class);
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean isScript;
|
||||
|
@ -143,17 +144,18 @@ public enum NodeTypeEnum {
|
|||
LiteflowMethod liteflowMethod = AnnotationUtil.getAnnotation(method, LiteflowMethod.class);
|
||||
if (liteflowMethod != null) {
|
||||
return StrUtil.isNotBlank(liteflowMethod.nodeId());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (mixDefined) {
|
||||
LOG.warn("[[[WARNING!!!]]]The @liteflowMethod in the class[{}] defined by @liteflowCmpDefine should not configure the nodeId again!",
|
||||
LOG.warn(
|
||||
"[[[WARNING!!!]]]The @liteflowMethod in the class[{}] defined by @liteflowCmpDefine should not configure the nodeId again!",
|
||||
clazz.getName());
|
||||
}
|
||||
|
||||
|
||||
// 在返回之前,还要对方法级别的@LiteflowMethod进行检查,如果存在方法上的类型与类上的不一致时,给予警告信息
|
||||
AtomicReference<Method> differenceTypeMethod = new AtomicReference<>();
|
||||
boolean hasDifferenceNodeType = Arrays.stream(clazz.getDeclaredMethods()).anyMatch(method -> {
|
||||
|
@ -162,17 +164,20 @@ public enum NodeTypeEnum {
|
|||
if (!liteflowMethod.nodeType().equals(liteflowCmpDefine.value())) {
|
||||
differenceTypeMethod.set(method);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// 表示存在不一样的类型
|
||||
if (hasDifferenceNodeType) {
|
||||
LOG.warn("[[[WARNING!!!]]]The nodeType in @liteflowCmpDefine declared on the class[{}] does not match the nodeType in @liteflowMethod declared on the method[{}]!",
|
||||
LOG.warn(
|
||||
"[[[WARNING!!!]]]The nodeType in @liteflowCmpDefine declared on the class[{}] does not match the nodeType in @liteflowMethod declared on the method[{}]!",
|
||||
clazz.getName(), differenceTypeMethod.get().getName());
|
||||
}
|
||||
|
||||
|
@ -180,9 +185,12 @@ public enum NodeTypeEnum {
|
|||
}
|
||||
|
||||
// 再尝试声明式组件这部分的推断
|
||||
LiteflowMethod liteflowMethod = Arrays.stream(clazz.getDeclaredMethods()).map(
|
||||
method -> AnnotationUtil.getAnnotation(method, LiteflowMethod.class)
|
||||
).filter(Objects::nonNull).filter(lfMethod -> lfMethod.value().isMainMethod()).findFirst().orElse(null);
|
||||
LiteflowMethod liteflowMethod = Arrays.stream(clazz.getDeclaredMethods())
|
||||
.map(method -> AnnotationUtil.getAnnotation(method, LiteflowMethod.class))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(lfMethod -> lfMethod.value().isMainMethod())
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (liteflowMethod != null) {
|
||||
nodeType = liteflowMethod.nodeType();
|
||||
|
@ -190,4 +198,5 @@ public enum NodeTypeEnum {
|
|||
}
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,9 @@ package com.yomahub.liteflow.enums;
|
|||
|
||||
public enum ScriptTypeEnum {
|
||||
|
||||
GROOVY("groovy", "groovy"),
|
||||
QLEXPRESS("qlexpress", "qlexpress"),
|
||||
JS("javascript", "js"),
|
||||
PYTHON("python", "python"),
|
||||
LUA("luaj", "lua")
|
||||
;
|
||||
GROOVY("groovy", "groovy"), QLEXPRESS("qlexpress", "qlexpress"), JS("javascript", "js"), PYTHON("python", "python"),
|
||||
LUA("luaj", "lua");
|
||||
|
||||
private String engineName;
|
||||
|
||||
private String displayName;
|
||||
|
@ -41,4 +38,5 @@ public enum ScriptTypeEnum {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 类型错误异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class CatchErrorException extends RuntimeException {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 链端异常
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class ChainEndException extends RuntimeException {
|
||||
|
@ -24,4 +25,5 @@ public class ChainEndException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 链端不存在
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class ChainNotFoundException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class ChainNotFoundException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 流程规则主要执行器类
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.3
|
||||
*/
|
||||
|
@ -25,4 +26,5 @@ public class ComponentCannotRegisterException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 组件方法定义错误异常
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class ComponentMethodDefineErrorException extends RuntimeException {
|
||||
|
@ -24,4 +25,5 @@ public class ComponentMethodDefineErrorException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 组件不可访问异常
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
public class ComponentNotAccessException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class ComponentNotAccessException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 组件代理错误异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class ComponentProxyErrorException extends RuntimeException {
|
||||
|
@ -24,4 +25,5 @@ public class ComponentProxyErrorException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 配置错误异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class ConfigErrorException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class ConfigErrorException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 循环依赖异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class CyclicDependencyException extends RuntimeException {
|
||||
|
@ -24,4 +25,5 @@ public class CyclicDependencyException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 未找到数据异常
|
||||
*
|
||||
* @author tangkc
|
||||
*/
|
||||
public class DataNotFoundException extends RuntimeException {
|
||||
|
||||
public static final String MSG = "DataNotFoundException";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -30,4 +32,5 @@ public class DataNotFoundException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* EL 解析异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class ELParseException extends RuntimeException {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.yomahub.liteflow.exception;
|
||||
|
||||
|
||||
/**
|
||||
* 空条件值异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class EmptyConditionValueException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
|
@ -23,4 +24,5 @@ public class EmptyConditionValueException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 错误支持路径异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class ErrorSupportPathException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class ErrorSupportPathException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ public class ExecutableItemNotFoundException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 流程执行者未初始化
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class FlowExecutorNotInitException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class FlowExecutorNotInitException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 流程系统异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class FlowSystemException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class FlowSystemException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 如果目标不能是 Pre 或 Finally 异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class IfTargetCannotBePreOrFinallyException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 类型错误异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class IfTypeErrorException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* Json 进程异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class JsonProcessException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class JsonProcessException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
package com.yomahub.liteflow.exception;
|
||||
|
||||
/**
|
||||
* LiteFlow架内部逻辑发生错误抛出的异常
|
||||
* (自定义此异常方便开发者在做全局异常处理时分辨异常类型)
|
||||
* LiteFlow架内部逻辑发生错误抛出的异常 (自定义此异常方便开发者在做全局异常处理时分辨异常类型)
|
||||
*
|
||||
* @author zendwang
|
||||
* @since 2.8.3
|
||||
*/
|
||||
|
@ -16,7 +16,6 @@ public class LiteFlowException extends RuntimeException {
|
|||
|
||||
/**
|
||||
* 构建一个异常
|
||||
*
|
||||
* @param message 异常描述信息
|
||||
*/
|
||||
public LiteFlowException(String message) {
|
||||
|
@ -35,7 +34,6 @@ public class LiteFlowException extends RuntimeException {
|
|||
|
||||
/**
|
||||
* 构建一个异常
|
||||
*
|
||||
* @param cause 异常对象
|
||||
*/
|
||||
public LiteFlowException(Throwable cause) {
|
||||
|
@ -44,7 +42,6 @@ public class LiteFlowException extends RuntimeException {
|
|||
|
||||
/**
|
||||
* 构建一个异常
|
||||
*
|
||||
* @param message 异常信息
|
||||
* @param cause 异常对象
|
||||
*/
|
||||
|
@ -69,4 +66,5 @@ public class LiteFlowException extends RuntimeException {
|
|||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 文件监听异常
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.10.0
|
||||
*/
|
||||
|
@ -25,4 +26,5 @@ public class MonitorFileInitErrorException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 重复解析器异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class MultipleParsersException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class MultipleParsersException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 无可用插槽异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoAvailableSlotException extends RuntimeException {
|
||||
|
@ -23,4 +24,5 @@ public class NoAvailableSlotException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 没有节点异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoForNodeException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 节点不为真异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoIfTrueNodeException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 没有节点异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoIteratorNodeException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 无切换目标节点异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoSwitchTargetNodeException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 没有 While 节点异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NoWhileNodeException extends RuntimeException {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.yomahub.liteflow.exception;
|
||||
|
||||
|
||||
/**
|
||||
* 节点构建异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NodeBuildException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
|
@ -23,4 +24,5 @@ public class NodeBuildException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 找不到节点类异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NodeClassNotFoundException extends RuntimeException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 节点类型无法猜测异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NodeTypeCanNotGuessException extends RuntimeException {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.exception;
|
|||
|
||||
/**
|
||||
* 节点类型不支持异常
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.0
|
||||
*/
|
||||
|
@ -25,4 +26,5 @@ public class NodeTypeNotSupportException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.yomahub.liteflow.exception;
|
||||
|
||||
|
||||
/**
|
||||
* 不支持条件异常
|
||||
*
|
||||
* @author Yun
|
||||
*/
|
||||
public class NotSupportConditionException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 异常信息 */
|
||||
|
@ -23,4 +24,5 @@ public class NotSupportConditionException extends RuntimeException {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue