小修正

This commit is contained in:
bryan.zhang
2017-12-04 14:27:07 +08:00
parent ab8b6102e6
commit aa6a347d52
7 changed files with 59 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ import com.thebeastshop.liteflow.entity.config.Node;
import com.thebeastshop.liteflow.entity.config.ThenCondition;
import com.thebeastshop.liteflow.entity.config.WhenCondition;
import com.thebeastshop.liteflow.entity.data.DataBus;
import com.thebeastshop.liteflow.exception.FlowException;
import com.thebeastshop.liteflow.flow.FlowBus;
import com.thebeastshop.liteflow.parser.FlowParser;
@@ -78,13 +79,15 @@ public class FlowExecutor {
if(component.isAccess()){
component.execute();
}else{
LOG.info("component[{}] do not gain access",component.getClass().getSimpleName());
LOG.error("component[{}] do not gain access",component.getClass().getSimpleName());
throw new FlowException("component ["+component.getClass().getSimpleName()+"] do not gain access");
}
}catch(Throwable t){
if(component.isContinueOnError()){
LOG.error("component[{}] cause error,but flow is still go on",t,component.getClass().getSimpleName());
}else{
throw new Exception(t);
LOG.error(t.getMessage(),t);
throw t;
}
}
}
@@ -100,7 +103,7 @@ public class FlowExecutor {
return DataBus.getSlot(slotIndex).getResponseData();
}catch(Exception e){
LOG.error("executor cause error",e);
return null;
throw new FlowException("executor cause error");
}finally{
DataBus.releaseSlot(slotIndex);
}

View File

@@ -0,0 +1,21 @@
package com.thebeastshop.liteflow.exception;
public class FlowException extends RuntimeException {
private static final long serialVersionUID = 1L;
/** 异常信息 */
private String message;
public FlowException(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -25,7 +25,7 @@ public class TestWithSpringMain {
public void test1() throws Exception {
ExecutorService executorService = Executors.newFixedThreadPool(10);
for(int i=0;i<100;i++){
for(int i=0;i<1;i++){
executorService.submit(new Thread(){
@Override
public void run() {

View File

@@ -13,7 +13,7 @@
<bean id="flowExecutor" class="com.thebeastshop.liteflow.core.FlowExecutor" init-method="init">
<property name="rulePath">
<list>
<value>flow.xml</value>
<value>config/flow.xml</value>
</list>
</property>
</bean>