bug #ICZ1N3 解决2.15.0中把chain作为子流程传入时,子流程里获取不了requestData的问题

This commit is contained in:
everywhere.z
2025-09-22 00:45:18 +08:00
parent c68086a63f
commit 0068406dbe
8 changed files with 143 additions and 1 deletions

View File

@@ -351,7 +351,7 @@ public abstract class NodeComponent{
}
public <T> T getRequestData() {
return getSlot().getChainReqData(getCurrChainId());
return getSlot().getChainReqData(getChainId());
}
public boolean isRollback() {

View File

@@ -0,0 +1,41 @@
package com.yomahub.liteflow.test.requestData;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import javax.annotation.Resource;
/**
* springboot环境EL常规的例子测试
*
* @author Bryan.Zhang
* @author luo yi
*/
@TestPropertySource(value = "classpath:/requestData/application.properties")
@SpringBootTest(classes = RequestDataSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.requestData.cmp" })
public class RequestDataSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
// 最简单的情况
@Test
public void testReqData1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "hello");
Assertions.assertTrue(response.isSuccess());
DefaultContext context = response.getFirstContextBean();
String arg = context.getData("arg");
Assertions.assertEquals("hello", arg);
}
}

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.requestData.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
System.out.println("ACmp executed!");
}
}

View File

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

View File

@@ -0,0 +1,27 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.requestData.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.slot.DefaultContext;
import org.springframework.stereotype.Component;
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
String requestData = this.getRequestData();
DefaultContext context = this.getFirstContextBean();
context.setData("arg", requestData);
System.out.println("CCmp executed!");
}
}

View File

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

View File

@@ -0,0 +1 @@
liteflow.rule-source=requestData/flow.xml

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE flow PUBLIC "liteflow" "liteflow.dtd">
<flow>
<chain name="chain1">
THEN(a,b,chain2);
</chain>
<chain name="chain2">
THEN(c,d);
</chain>
</flow>