mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 04:02:09 +08:00
feature #IBW9PC 上下文表达式搜索&设置,摆脱对上下文的依赖
This commit is contained in:
@@ -34,4 +34,7 @@ public class DefaultContext {
|
||||
putDataMap(key, t);
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, Object> getDataMap() {
|
||||
return dataMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +97,16 @@ public class SearchContextSpringbootTest extends BaseTest {
|
||||
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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,8 @@
|
||||
<chain name="chain5">
|
||||
THEN(a5);
|
||||
</chain>
|
||||
|
||||
<chain name="chain6">
|
||||
THEN(a6);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user