From ba8ac461cb20db03061749082d244d4007b6f58c Mon Sep 17 00:00:00 2001 From: "bryan.zhang" Date: Thu, 7 Dec 2017 14:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8A=82=E7=82=B9isEnd?= =?UTF-8?q?=E7=89=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/core/FlowExecutor.java | 4 ++++ .../liteflow/core/NodeComponent.java | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java b/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java index 60c42effc..136b78bbf 100644 --- a/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java +++ b/src/main/java/com/thebeastshop/liteflow/core/FlowExecutor.java @@ -92,6 +92,10 @@ public class FlowExecutor { component.setSlotIndex(slotIndex); if(component.isAccess()){ component.execute(); + if(component.isEnd()) { + LOG.info("component[{}] lead the chain to end",component.getClass().getSimpleName()); + break; + } }else{ String errorMsg = MessageFormat.format("component[{}] do not gain access", component.getClass().getSimpleName()); throw new ComponentNotAccessException(errorMsg); diff --git a/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java b/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java index 6a44ec9ec..ca07d8897 100644 --- a/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java +++ b/src/main/java/com/thebeastshop/liteflow/core/NodeComponent.java @@ -29,8 +29,6 @@ public abstract class NodeComponent { private String nodeId; - private boolean continueOnError; - public void execute() throws Exception{ StopWatch stopWatch = new StopWatch(); stopWatch.start(); @@ -69,16 +67,25 @@ public abstract class NodeComponent { protected abstract void process() throws Exception; + /** + * 是否进入该节点 + */ protected boolean isAccess(){ return true; } - public boolean isContinueOnError() { - return continueOnError; + /** + * 出错是否继续执行 + */ + protected boolean isContinueOnError() { + return false; } - - public void setContinueOnError(boolean continueOnError) { - this.continueOnError = continueOnError; + + /** + * 是否结束整个流程(不往下继续执行) + */ + protected boolean isEnd() { + return false; } public NodeComponent setSlotIndex(Integer slotIndex) {