mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
将chain中的pre节点剥离至flowExecutor
This commit is contained in:
@@ -383,7 +383,8 @@ public class FlowExecutor {
|
||||
String errorMsg = StrUtil.format("[{}]:couldn't find chain with the id[{}]", slot.getRequestId(), chainId);
|
||||
throw new ChainNotFoundException(errorMsg);
|
||||
}
|
||||
|
||||
// 执行前置
|
||||
chain.executePre(slotIndex);
|
||||
// 执行chain
|
||||
chain.execute(slotIndex);
|
||||
} catch (ChainEndException e) {
|
||||
|
||||
@@ -80,11 +80,7 @@ public class Chain implements Executable {
|
||||
throw new FlowSystemException("no conditionList in this chain[" + chainName + "]");
|
||||
}
|
||||
for (Condition condition : conditionList) {
|
||||
if (condition instanceof PreCondition){
|
||||
for (Executable executableItem : condition.getNodeList()) {
|
||||
executableItem.execute(slotIndex);
|
||||
}
|
||||
} else if (condition instanceof ThenCondition) {
|
||||
if (condition instanceof ThenCondition) {
|
||||
for (Executable executableItem : condition.getNodeList()) {
|
||||
executableItem.execute(slotIndex);
|
||||
}
|
||||
@@ -94,10 +90,20 @@ public class Chain implements Executable {
|
||||
}
|
||||
}
|
||||
|
||||
// 执行pre节点
|
||||
public void executePre(Integer slotIndex) throws Exception {
|
||||
//先把pre的节点过滤出来
|
||||
List<Condition> preConditionList =filterCondition(ConditionTypeEnum.TYPE_PRE);
|
||||
for (Condition finallyCondition : preConditionList){
|
||||
for(Executable executableItem : finallyCondition.getNodeList()){
|
||||
executableItem.execute(slotIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void executeFinally(Integer slotIndex) throws Exception {
|
||||
//先把finally的节点过滤出来
|
||||
List<Condition> finallyConditionList = conditionList.stream().filter(condition ->
|
||||
condition.getConditionType().equals(ConditionTypeEnum.TYPE_FINALLY)).collect(Collectors.toList());
|
||||
List<Condition> finallyConditionList =filterCondition(ConditionTypeEnum.TYPE_FINALLY);
|
||||
for (Condition finallyCondition : finallyConditionList){
|
||||
for(Executable executableItem : finallyCondition.getNodeList()){
|
||||
executableItem.execute(slotIndex);
|
||||
@@ -105,6 +111,13 @@ public class Chain implements Executable {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据节点condition类型过去出节点列表
|
||||
private List<Condition> filterCondition(ConditionTypeEnum conditionTypeEnum) {
|
||||
assert conditionTypeEnum != null;
|
||||
return conditionList.stream().filter(condition ->
|
||||
condition.getConditionType().equals(conditionTypeEnum)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecuteTypeEnum getExecuteType() {
|
||||
return ExecuteTypeEnum.CHAIN;
|
||||
|
||||
Reference in New Issue
Block a user