bug #I4PA2A 在NodeComponent的isAccess中获取tag失败

This commit is contained in:
bryan31
2022-01-04 18:48:58 +08:00
parent 25730a27fc
commit 5693ca199d
7 changed files with 76 additions and 6 deletions

View File

@@ -108,14 +108,13 @@ public class Node implements Executable,Cloneable{
Slot slot = DataBus.getSlot(slotIndex);
try {
//把tag和condNodeMap赋给NodeComponent
//这里为什么要这么做因为tag和condNodeMap从某种意义上来说是属于某个chain本身范围并非全局的
instance.setTag(tag);
instance.setCondNodeMap(condNodeMap);
//判断是否可执行所以isAccess经常作为一个组件进入的实际判断要素用作检查slot里的参数的完备性
if (instance.isAccess()) {
//把tag和condNodeMap赋给NodeComponent
//这里为什么要这么做因为tag和condNodeMap从某种意义上来说是属于某个chain本身范围并非全局的
instance.setTag(tag);
instance.setCondNodeMap(condNodeMap);
//这里开始进行重试的逻辑和主逻辑的运行
int retryCount = instance.getRetryCount();
List<Class<? extends Exception>> forExceptions = Arrays.asList(instance.getRetryForExceptions());

View File

@@ -56,4 +56,12 @@ public class NodeTagSpringbootJsonTest extends BaseTest {
Assert.assertEquals(3, testSet.size());
}
}
//测试tag是否能在isAccess中起效
@Test
public void testTag4() throws Exception{
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getSlot().printStep());
}
}

View File

@@ -56,4 +56,12 @@ public class NodeTagSpringbootXmlTest extends BaseTest {
Assert.assertEquals(3, testSet.size());
}
}
//测试tag是否能在isAccess中起效
@Test
public void testTag4() throws Exception{
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getSlot().printStep());
}
}

View File

@@ -0,0 +1,25 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("f")
public class FCmp extends NodeComponent {
@Override
public void process() {
System.out.println("FCmp executed!");
}
@Override
public boolean isAccess() {
return Boolean.parseBoolean(this.getTag());
}
}

View File

@@ -0,0 +1,20 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("g")
public class GCmp extends NodeComponent {
@Override
public void process() {
System.out.println("GCmp executed!");
}
}

View File

@@ -19,6 +19,12 @@
{"type": "then", "value": "b1"},
{"type": "when", "value": "b[1],b[2],b[3]"}
]
},
{
"name": "chain4",
"condition": [
{"type": "then", "value": "f[false],g"}
]
}
]
}

View File

@@ -12,4 +12,8 @@
<then value="b1"/>
<when value="b[1],b[2],b[3]"/>
</chain>
<chain name="chain4">
<then value="f[false],g"/>
</chain>
</flow>