增加节点isEnd特性

This commit is contained in:
bryan.zhang
2017-12-07 14:04:06 +08:00
parent f2b7601044
commit ba8ac461cb
2 changed files with 18 additions and 7 deletions

View File

@@ -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);

View File

@@ -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) {