feature #IBW9PC 上下文表达式搜索&设置,摆脱对上下文的依赖

This commit is contained in:
everywhere.z
2025-04-14 11:00:17 +08:00
parent 193b318b6e
commit 07e90c3725
4 changed files with 41 additions and 0 deletions

View File

@@ -34,4 +34,7 @@ public class DefaultContext {
putDataMap(key, t); putDataMap(key, t);
} }
public ConcurrentHashMap<String, Object> getDataMap() {
return dataMap;
}
} }

View File

@@ -97,4 +97,16 @@ public class SearchContextSpringbootTest extends BaseTest {
Assertions.assertEquals("test info", context.getData("test")); Assertions.assertEquals("test info", context.getData("test"));
} }
// 测试获取DefaultContext
@Test
public void testSearchContext6() throws Exception {
DefaultContext context = new DefaultContext();
context.setData("k1", "v1");
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg", context);
Assertions.assertTrue(response.isSuccess());
context = response.getContextBean(DefaultContext.class);
Assertions.assertEquals("v1", context.getData("test"));
}
} }

View File

@@ -0,0 +1,22 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.searchContext.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("a6")
public class A6Cmp extends NodeComponent {
@Override
public void process() {
String str = this.getContextValue("dataMap.k1");
this.setContextValue("setData", "test", str);
}
}

View File

@@ -20,4 +20,8 @@
<chain name="chain5"> <chain name="chain5">
THEN(a5); THEN(a5);
</chain> </chain>
<chain name="chain6">
THEN(a6);
</chain>
</flow> </flow>