策略调用增加参数

增加策略调用的无级嵌套
This commit is contained in:
bryan.zhang
2017-12-18 20:25:13 +08:00
parent eefbe197d8
commit 809b063425
11 changed files with 165 additions and 8 deletions

View File

@@ -64,8 +64,8 @@ public class FlowExecutor {
return execute(chainId, param, slotClazz,null,false);
}
public <T> T invoke(String chainId,Class<? extends Slot> slotClazz,Integer slotIndex){
return execute(chainId,null, slotClazz,slotIndex,true);
public void invoke(String chainId,Object param,Class<? extends Slot> slotClazz,Integer slotIndex){
execute(chainId, param, slotClazz,slotIndex,true);
}
public <T> T execute(String chainId,Object param,Class<? extends Slot> slotClazz,Integer slotIndex,boolean isInnerChain){
@@ -95,8 +95,10 @@ public class FlowExecutor {
throw new NoAvailableSlotException("the slot is not exist");
}
if(!isInnerChain && param != null) {
if(!isInnerChain) {
slot.setRequestData(param);
}else {
slot.setChainReqData(chainId, param);
}
List<Condition> conditionList = chain.getConditionList();

View File

@@ -34,6 +34,8 @@ public abstract class AbsSlot implements Slot{
private final String NODE_OUTPUT_PREFIX = "output_";
private final String CHAIN_REQ_PREFIX = "chain_req_";
private Deque<CmpStep> executeSteps = new ArrayDeque<CmpStep>();
protected ConcurrentHashMap<String, Object> dataMap = new ConcurrentHashMap<String, Object>();
@@ -70,6 +72,14 @@ public abstract class AbsSlot implements Slot{
dataMap.put(RESPONSE, t);
}
public <T> T getChainReqData(String chainId) {
return (T)dataMap.get(CHAIN_REQ_PREFIX + chainId);
}
public <T> void setChainReqData(String chainId, T t) {
dataMap.put(CHAIN_REQ_PREFIX + chainId, t);
}
public <T> T getData(String key){
return (T)dataMap.get(key);
}

View File

@@ -24,6 +24,10 @@ public interface Slot {
public <T> T getResponseData();
public <T> void setChainReqData(String chainId, T t);
public <T> T getChainReqData(String chainId);
public <T> void setResponseData(T t);
public <T> T getData(String key);