Sfoglia il codice sorgente

enhancement #I6LWYM 深层次优化Condition维度的代码

everywhere.z 2 anni fa
parent
commit
ffb030e02e

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/DoOperator.java

@@ -26,7 +26,7 @@ public class DoOperator extends BaseOperator<LoopCondition> {
 
         //获得需要执行的可执行表达式
         Executable doExecutableItem = OperatorHelper.convert(objects[1], Executable.class);
-        condition.setExecutableList(ListUtil.toList(doExecutableItem));
+        condition.setDoExecutor(doExecutableItem);
 
         return condition;
     }

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ElifOperator.java

@@ -35,7 +35,7 @@ public class ElifOperator extends BaseOperator<IfCondition> {
 
 		//构建一个内部的IfCondition
 		IfCondition ifConditionItem = new IfCondition();
-		ifConditionItem.setExecutableList(ListUtil.toList(ifNode));
+		ifConditionItem.setIfNode(ifNode);
 		ifConditionItem.setTrueCaseExecutableItem(trueCaseExecutableItem);
 
 		//因为可能会有多个ELIF,所以每一次拿到的caller总是最开始大的if,需要遍历到没有falseCaseExecutable的地方。

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/IfOperator.java

@@ -37,7 +37,7 @@ public class IfOperator extends BaseOperator<IfCondition> {
         }
 
         IfCondition ifCondition = new IfCondition();
-        ifCondition.setExecutableList(ListUtil.toList(ifNode));
+        ifCondition.setIfNode(ifNode);
         ifCondition.setTrueCaseExecutableItem(trueCaseExecutableItem);
         ifCondition.setFalseCaseExecutableItem(falseCaseExecutableItem);
         return ifCondition;

+ 43 - 4
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/Condition.java

@@ -7,12 +7,17 @@
  */
 package com.yomahub.liteflow.flow.element.condition;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.yomahub.liteflow.enums.ExecuteTypeEnum;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.enums.ConditionTypeEnum;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Condition的抽象类
@@ -25,7 +30,9 @@ public abstract class Condition implements Executable{
 	/**
 	 * 可执行元素的集合
 	 */
-	private List<Executable> executableList = new ArrayList<>();
+	private final Map<String, List<Executable>> executableGroup = new HashMap<>();
+
+	private final String DEFAULT_GROUP = "DEFAULT";
 
 
 	/**
@@ -45,15 +52,44 @@ public abstract class Condition implements Executable{
 	}
 
 	public List<Executable> getExecutableList() {
+		return getExecutableList(DEFAULT_GROUP);
+	}
+
+	public List<Executable> getExecutableList(String groupKey) {
+		List<Executable> executableList = this.executableGroup.get(groupKey);
+		if (CollUtil.isEmpty(executableList)){
+			executableList = new ArrayList<>();
+		}
 		return executableList;
 	}
 
+	public Executable getExecutableOne(String groupKey) {
+		List<Executable> list = getExecutableList(groupKey);
+		if (CollUtil.isEmpty(list)){
+			return null;
+		}else{
+			return list.get(0);
+		}
+	}
+
 	public void setExecutableList(List<Executable> executableList) {
-		this.executableList = executableList;
+		this.executableGroup.put(DEFAULT_GROUP, executableList);
 	}
 
 	public void addExecutable(Executable executable) {
-		this.executableList.add(executable);
+		addExecutable(DEFAULT_GROUP, executable);
+	}
+
+	public void addExecutable(String groupKey, Executable executable) {
+		if (ObjectUtil.isNull(executable)){
+			return;
+		}
+		List<Executable> executableList = this.executableGroup.get(groupKey);
+		if (CollUtil.isEmpty(executableList)){
+			this.executableGroup.put(groupKey, ListUtil.toList(executable));
+		}else{
+			this.executableGroup.get(groupKey).add(executable);
+		}
 	}
 
 	public abstract ConditionTypeEnum getConditionType();
@@ -68,7 +104,6 @@ public abstract class Condition implements Executable{
 
 	/**
 	 * 
-	 * @return
 	 * @deprecated 请使用 {@link #setCurrChainId(String)}
 	 */
 	@Deprecated
@@ -84,4 +119,8 @@ public abstract class Condition implements Executable{
 	public void setCurrChainId(String currChainId) {
 		this.currChainId = currChainId;
 	}
+
+	public Map<String, List<Executable>> getExecutableGroup() {
+		return executableGroup;
+	}
 }

+ 9 - 5
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ForCondition.java

@@ -18,11 +18,12 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
  */
 public class ForCondition extends LoopCondition{
 
-    private Node forNode;
+    private final String FOR_ITEM = "FOR_ITEM";
 
     @Override
     public void execute(Integer slotIndex) throws Exception {
         Slot slot = DataBus.getSlot(slotIndex);
+        Node forNode = this.getForNode();
         if (ObjectUtil.isNull(forNode)){
             String errorInfo = StrUtil.format("[{}]:no for-node found", slot.getRequestId());
             throw new NoForNodeException(errorInfo);
@@ -38,13 +39,16 @@ public class ForCondition extends LoopCondition{
         forNode.execute(slotIndex);
 
         //这里可能会有spring代理过的bean,所以拿到user原始的class
-        Class<?> originalForCountClass = LiteFlowProxyUtil.getUserClass(this.forNode.getInstance().getClass());
+        Class<?> originalForCountClass = LiteFlowProxyUtil.getUserClass(forNode.getInstance().getClass());
         //获得循环次数
         int forCount = slot.getForResult(originalForCountClass.getName());
 
         //获得要循环的可执行对象
         Executable executableItem = this.getDoExecutor();
 
+        //获取Break节点
+        Node breakNode = this.getBreakNode();
+
         //循环执行
         for (int i = 0; i < forCount; i++) {
             executableItem.setCurrChainId(this.getCurrChainId());
@@ -56,7 +60,7 @@ public class ForCondition extends LoopCondition{
                 breakNode.setCurrChainId(this.getCurrChainId());
                 setLoopIndex(breakNode, i);
                 breakNode.execute(slotIndex);
-                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(this.breakNode.getInstance().getClass());
+                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(breakNode.getInstance().getClass());
                 boolean isBreak = slot.getBreakResult(originalBreakClass.getName());
                 if (isBreak){
                     break;
@@ -71,10 +75,10 @@ public class ForCondition extends LoopCondition{
     }
 
     public Node getForNode() {
-        return forNode;
+        return (Node) this.getExecutableOne(FOR_ITEM);
     }
 
     public void setForNode(Node forNode) {
-        this.forNode = forNode;
+        this.addExecutable(FOR_ITEM, forNode);
     }
 }

+ 17 - 8
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IfCondition.java

@@ -20,9 +20,11 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
  */
 public class IfCondition extends Condition {
 
-    private Executable trueCaseExecutableItem;
+    private final String IF_ITEM = "IF_ITEM";
 
-    private Executable falseCaseExecutableItem;
+    private final String TRUE_CASE_GROUP = "TRUE_CASE";
+
+    private final String FALSE_CASE_GROUP = "FALSE_CASE";
 
     @Override
     public void execute(Integer slotIndex) throws Exception {
@@ -42,6 +44,9 @@ public class IfCondition extends Condition {
             //拿到If执行过的结果
             boolean ifResult = slot.getIfResult(originalClass.getName());
 
+            Executable trueCaseExecutableItem = this.getTrueCaseExecutableItem();
+            Executable falseCaseExecutableItem = this.getFalseCaseExecutableItem();
+
             if (ifResult) {
                 //trueCaseExecutableItem这个不能为空,否则执行什么呢
                 if (ObjectUtil.isNull(trueCaseExecutableItem)) {
@@ -56,7 +61,7 @@ public class IfCondition extends Condition {
                 }
 
                 //执行trueCaseExecutableItem
-                trueCaseExecutableItem.setCurrChainName(this.getCurrChainName());
+                trueCaseExecutableItem.setCurrChainId(this.getCurrChainId());
                 trueCaseExecutableItem.execute(slotIndex);
             } else {
                 //falseCaseExecutableItem可以为null,但是不为null时就执行否的情况
@@ -83,22 +88,26 @@ public class IfCondition extends Condition {
     }
 
     public Executable getTrueCaseExecutableItem() {
-        return trueCaseExecutableItem;
+        return this.getExecutableOne(TRUE_CASE_GROUP);
     }
 
     public void setTrueCaseExecutableItem(Executable trueCaseExecutableItem) {
-        this.trueCaseExecutableItem = trueCaseExecutableItem;
+        this.addExecutable(TRUE_CASE_GROUP, trueCaseExecutableItem);
     }
 
     public Executable getFalseCaseExecutableItem() {
-        return falseCaseExecutableItem;
+        return this.getExecutableOne(FALSE_CASE_GROUP);
     }
 
     public void setFalseCaseExecutableItem(Executable falseCaseExecutableItem) {
-        this.falseCaseExecutableItem = falseCaseExecutableItem;
+        this.addExecutable(FALSE_CASE_GROUP, falseCaseExecutableItem);
+    }
+
+    public void setIfNode(Node ifNode){
+        this.addExecutable(IF_ITEM, ifNode);
     }
 
     public Node getIfNode() {
-        return (Node) this.getExecutableList().get(0);
+        return (Node) this.getExecutableOne(IF_ITEM);
     }
 }

+ 10 - 5
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IteratorCondition.java

@@ -14,11 +14,13 @@ import java.util.Iterator;
 
 public class IteratorCondition extends LoopCondition{
 
-    private Node iteratorNode;
+    private final String ITERATOR_ITEM = "ITERATOR_ITEM";
 
     @Override
     public void execute(Integer slotIndex) throws Exception {
         Slot slot = DataBus.getSlot(slotIndex);
+        Node iteratorNode = this.getIteratorNode();
+
         if (ObjectUtil.isNull(iteratorNode)){
             String errorInfo = StrUtil.format("[{}]:no iterator-node found", slot.getRequestId());
             throw new NoIteratorNodeException(errorInfo);
@@ -34,13 +36,16 @@ public class IteratorCondition extends LoopCondition{
         iteratorNode.execute(slotIndex);
 
         //这里可能会有spring代理过的bean,所以拿到user原始的class
-        Class<?> originalForCountClass = LiteFlowProxyUtil.getUserClass(this.iteratorNode.getInstance().getClass());
+        Class<?> originalForCountClass = LiteFlowProxyUtil.getUserClass(iteratorNode.getInstance().getClass());
         //获得迭代器
         Iterator<?> it = slot.getIteratorResult(originalForCountClass.getName());
 
         //获得要循环的可执行对象
         Executable executableItem = this.getDoExecutor();
 
+        //获取Break节点
+        Node breakNode = this.getBreakNode();
+
         int index = 0;
         while(it.hasNext()){
             Object itObj = it.next();
@@ -58,7 +63,7 @@ public class IteratorCondition extends LoopCondition{
                 setLoopIndex(breakNode, index);
                 setCurrLoopObject(breakNode, itObj);
                 breakNode.execute(slotIndex);
-                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(this.breakNode.getInstance().getClass());
+                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(breakNode.getInstance().getClass());
                 boolean isBreak = slot.getBreakResult(originalBreakClass.getName());
                 if (isBreak){
                     break;
@@ -74,10 +79,10 @@ public class IteratorCondition extends LoopCondition{
     }
 
     public Node getIteratorNode() {
-        return iteratorNode;
+        return (Node) this.getExecutableOne(ITERATOR_ITEM);
     }
 
     public void setIteratorNode(Node iteratorNode) {
-        this.iteratorNode = iteratorNode;
+        this.addExecutable(ITERATOR_ITEM, iteratorNode);
     }
 }

+ 19 - 31
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/LoopCondition.java

@@ -4,6 +4,8 @@ import com.yomahub.liteflow.flow.element.Chain;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.flow.element.Node;
 
+import java.util.List;
+import java.util.Map;
 import java.util.function.Consumer;
 
 /**
@@ -15,32 +17,31 @@ import java.util.function.Consumer;
  */
 public abstract class LoopCondition extends Condition {
 
-    protected Node breakNode;
+    private final String DO_ITEM = "DO_ITEM";
 
-    public Node getBreakNode() {
-        return breakNode;
+    private final String BREAK_ITEM = "BREAK_ITEM";
+
+    protected Node getBreakNode() {
+        return (Node) this.getExecutableOne(BREAK_ITEM);
     }
 
     public void setBreakNode(Node breakNode) {
-        this.breakNode = breakNode;
+        this.addExecutable(BREAK_ITEM, breakNode);
+    }
+
+    protected Executable getDoExecutor() {
+        return this.getExecutableOne(DO_ITEM);
+    }
+
+    public void setDoExecutor(Executable executable) {
+        this.addExecutable(DO_ITEM, executable);
     }
 
     protected void setLoopIndex(Executable executableItem, int index){
         if (executableItem instanceof Chain){
             ((Chain)executableItem).getConditionList().forEach(condition -> setLoopIndex(condition, index));
-        }else if(executableItem instanceof IfCondition) {
-            ((Condition) executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
-            setLoopIndex(((IfCondition) executableItem).getTrueCaseExecutableItem(), index);
-            setLoopIndex(((IfCondition) executableItem).getFalseCaseExecutableItem(), index);
-        }else if(executableItem instanceof SwitchCondition) {
-            ((Condition) executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
-            ((SwitchCondition) executableItem).getTargetList().forEach(executable -> setLoopIndex(executable, index));
-        }else if(executableItem instanceof ThenCondition) {
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
-            ((ThenCondition) executableItem).getPreConditionList().forEach(executable -> setLoopIndex(executable, index));
-            ((ThenCondition) executableItem).getFinallyConditionList().forEach(executable -> setLoopIndex(executable, index));
         }else if(executableItem instanceof Condition){
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
+            ((Condition) executableItem).getExecutableGroup().forEach((key, value) -> value.forEach(executable -> setLoopIndex(executable, index)));
         }else if(executableItem instanceof Node){
             ((Node)executableItem).setLoopIndex(index);
         }
@@ -49,25 +50,12 @@ public abstract class LoopCondition extends Condition {
     protected void setCurrLoopObject(Executable executableItem, Object obj){
         if (executableItem instanceof Chain){
             ((Chain)executableItem).getConditionList().forEach(condition -> setCurrLoopObject(condition, obj));
-        }else if(executableItem instanceof IfCondition) {
-            ((Condition) executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
-            setCurrLoopObject(((IfCondition) executableItem).getTrueCaseExecutableItem(), obj);
-            setCurrLoopObject(((IfCondition) executableItem).getFalseCaseExecutableItem(), obj);
-        }else if(executableItem instanceof SwitchCondition) {
-            ((Condition) executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
-            ((SwitchCondition) executableItem).getTargetList().forEach(executable -> setCurrLoopObject(executable, obj));
-        }else if(executableItem instanceof ThenCondition) {
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
-            ((ThenCondition) executableItem).getPreConditionList().forEach(executable -> setCurrLoopObject(executable, obj));
-            ((ThenCondition) executableItem).getFinallyConditionList().forEach(executable -> setCurrLoopObject(executable, obj));
         }else if(executableItem instanceof Condition){
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
+            ((Condition) executableItem).getExecutableGroup().forEach((key, value) -> value.forEach(executable -> setCurrLoopObject(executable, obj)));
         }else if(executableItem instanceof Node){
             ((Node)executableItem).setCurrLoopObject(obj);
         }
     }
 
-    protected Executable getDoExecutor() {
-        return this.getExecutableList().get(0);
-    }
+
 }

+ 23 - 17
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java

@@ -25,30 +25,36 @@ import java.util.List;
 public class SwitchCondition extends Condition{
 
 
-    private final List<Executable> targetList = new ArrayList<>();
+    private final String TARGET_ITEM = "TARGET_ITEM";
 
-    private final String TAG_PREFIX = "tag";
-    private final String TAG_FLAG = ":";
+    private final String DEFAULT_ITEM = "DEFAULT_ITEM";
 
-    private Executable defaultExecutor;
+    private final String SWITCH_ITEM = "SWITCH_ITEM";
 
+    private final String TAG_PREFIX = "tag";
+    private final String TAG_FLAG = ":";
 
     @Override
     public void execute(Integer slotIndex) throws Exception {
         if (ListUtil.toList(NodeTypeEnum.SWITCH, NodeTypeEnum.SWITCH_SCRIPT).contains(this.getSwitchNode().getType())){
+            //获取switch node
+            Node switchNode = this.getSwitchNode();
+            //获取target List
+            List<Executable> targetList = this.getTargetList();
+
             //先去判断isAccess方法,如果isAccess方法都返回false,整个SWITCH表达式不执行
-            if (!this.getSwitchNode().isAccess(slotIndex)){
+            if (!switchNode.isAccess(slotIndex)){
                 return;
             }
 
             //先执行switch节点
-            this.getSwitchNode().setCurrChainId(this.getCurrChainId());
-            this.getSwitchNode().execute(slotIndex);
+            switchNode.setCurrChainId(this.getCurrChainId());
+            switchNode.execute(slotIndex);
 
             //根据switch节点执行出来的结果选择
             Slot slot = DataBus.getSlot(slotIndex);
             //这里可能会有spring代理过的bean,所以拿到user原始的class
-            Class<?> originalClass = LiteFlowProxyUtil.getUserClass(this.getSwitchNode().getInstance().getClass());
+            Class<?> originalClass = LiteFlowProxyUtil.getUserClass(switchNode.getInstance().getClass());
             String targetId = slot.getSwitchResult(originalClass.getName());
 
             Executable targetExecutor = null;
@@ -75,7 +81,7 @@ public class SwitchCondition extends Condition{
 
             if (ObjectUtil.isNull(targetExecutor)) {
                 //没有匹配到执行节点,则走默认的执行节点
-                targetExecutor = defaultExecutor;
+                targetExecutor = this.getDefaultExecutor();
             }
 
             if (ObjectUtil.isNotNull(targetExecutor)) {
@@ -103,26 +109,26 @@ public class SwitchCondition extends Condition{
     }
 
     public void addTargetItem(Executable executable){
-        this.targetList.add(executable);
+        this.addExecutable(TARGET_ITEM, executable);
     }
 
-    public void setSwitchNode(Node switchNode) {
-        this.getExecutableList().add(switchNode);
+    public List<Executable> getTargetList(){
+        return this.getExecutableList(TARGET_ITEM);
     }
 
-    public List<Executable> getTargetList(){
-        return targetList;
+    public void setSwitchNode(Node switchNode) {
+        this.addExecutable(SWITCH_ITEM, switchNode);
     }
 
     public Node getSwitchNode(){
-        return (Node) this.getExecutableList().get(0);
+        return (Node) this.getExecutableOne(SWITCH_ITEM);
     }
 
     public Executable getDefaultExecutor() {
-        return defaultExecutor;
+        return this.getExecutableOne(DEFAULT_ITEM);
     }
 
     public void setDefaultExecutor(Executable defaultExecutor) {
-        this.defaultExecutor = defaultExecutor;
+        this.addExecutable(DEFAULT_ITEM, defaultExecutor);
     }
 }

+ 18 - 14
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ThenCondition.java

@@ -12,9 +12,8 @@ import com.yomahub.liteflow.exception.ChainEndException;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.slot.DataBus;
 import com.yomahub.liteflow.slot.Slot;
-
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 串行器
@@ -22,15 +21,9 @@ import java.util.List;
  */
 public class ThenCondition extends Condition {
 
-	/**
-	 * 前置处理Condition
-	 */
-	private final List<PreCondition> preConditionList = new ArrayList<>();
+	private final String PRE_ITEM = "PRE_ITEM";
 
-	/**
-	 * 后置处理Condition
-	 */
-	private final List<FinallyCondition> finallyConditionList = new ArrayList<>();
+	private final String FINALLY_ITEM = "FINALLY_ITEM";
 
 	@Override
 	public ConditionTypeEnum getConditionType() {
@@ -39,6 +32,9 @@ public class ThenCondition extends Condition {
 
 	@Override
 	public void execute(Integer slotIndex) throws Exception {
+		List<PreCondition> preConditionList = this.getPreConditionList();
+		List<FinallyCondition> finallyConditionList = this.getFinallyConditionList();
+
 		try{
 			for (PreCondition preCondition : preConditionList){
 				preCondition.setCurrChainId(this.getCurrChainId());
@@ -74,19 +70,27 @@ public class ThenCondition extends Condition {
 	@Override
 	public void addExecutable(Executable executable) {
 		if (executable instanceof PreCondition){
-			preConditionList.add((PreCondition) executable);
+			this.addPreCondition((PreCondition) executable);
 		}else if (executable instanceof FinallyCondition){
-			finallyConditionList.add((FinallyCondition) executable);
+			this.addFinallyCondition((FinallyCondition) executable);
 		}else{
 			super.addExecutable(executable);
 		}
 	}
 
 	public List<PreCondition> getPreConditionList() {
-		return preConditionList;
+		return this.getExecutableList(PRE_ITEM).stream().map(executable -> (PreCondition) executable).collect(Collectors.toList());
+	}
+
+	public void addPreCondition(PreCondition preCondition){
+		this.addExecutable(PRE_ITEM, preCondition);
 	}
 
 	public List<FinallyCondition> getFinallyConditionList() {
-		return finallyConditionList;
+		return this.getExecutableList(FINALLY_ITEM).stream().map(executable -> (FinallyCondition) executable).collect(Collectors.toList());
+	}
+
+	public void addFinallyCondition(FinallyCondition finallyCondition){
+		this.addExecutable(FINALLY_ITEM, finallyCondition);
 	}
 }

+ 10 - 5
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhileCondition.java

@@ -18,11 +18,12 @@ import com.yomahub.liteflow.util.LiteFlowProxyUtil;
  */
 public class WhileCondition extends LoopCondition{
 
-    private Node whileNode;
+    private final String WHILE_ITEM = "WHILE_ITEM";
 
     @Override
     public void execute(Integer slotIndex) throws Exception {
         Slot slot = DataBus.getSlot(slotIndex);
+        Node whileNode = this.getWhileNode();
         if (ObjectUtil.isNull(whileNode)){
             String errorInfo = StrUtil.format("[{}]:no while-node found", slot.getRequestId());
             throw new NoWhileNodeException(errorInfo);
@@ -36,6 +37,9 @@ public class WhileCondition extends LoopCondition{
         //获得要循环的可执行对象
         Executable executableItem = this.getDoExecutor();
 
+        //获取Break节点
+        Node breakNode = this.getBreakNode();
+
         //循环执行
         int index = 0;
         while(getWhileResult(slotIndex)){
@@ -47,7 +51,7 @@ public class WhileCondition extends LoopCondition{
                 breakNode.setCurrChainId(this.getCurrChainId());
                 setLoopIndex(breakNode, index);
                 breakNode.execute(slotIndex);
-                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(this.breakNode.getInstance().getClass());
+                Class<?> originalBreakClass = LiteFlowProxyUtil.getUserClass(breakNode.getInstance().getClass());
                 boolean isBreak = slot.getBreakResult(originalBreakClass.getName());
                 if (isBreak){
                     break;
@@ -59,10 +63,11 @@ public class WhileCondition extends LoopCondition{
 
     private boolean getWhileResult(Integer slotIndex) throws Exception{
         Slot slot = DataBus.getSlot(slotIndex);
+        Node whileNode = this.getWhileNode();
         //执行while组件
         whileNode.setCurrChainId(this.getCurrChainId());
         whileNode.execute(slotIndex);
-        Class<?> originalWhileClass = LiteFlowProxyUtil.getUserClass(this.whileNode.getInstance().getClass());
+        Class<?> originalWhileClass = LiteFlowProxyUtil.getUserClass(whileNode.getInstance().getClass());
         return slot.getWhileResult(originalWhileClass.getName());
     }
 
@@ -72,10 +77,10 @@ public class WhileCondition extends LoopCondition{
     }
 
     public Node getWhileNode() {
-        return whileNode;
+        return (Node) this.getExecutableOne(WHILE_ITEM);
     }
 
     public void setWhileNode(Node whileNode) {
-        this.whileNode = whileNode;
+        this.addExecutable(WHILE_ITEM, whileNode);
     }
 }