使用Fork中的Script实现多路路由选择
在阅读本文之前,建议先阅读一下《JBPM源码解读之:Fork》以了解Fork中Script的配置方法及处理方式:
按照Fork对Script的规范Script必须包含一个具有write权限的变量,而且该变量必须实现java.util.Collection接口。
<?xml version="1.0" encoding="UTF-8"?>
附上单元测试代码:
import junit.framework.TestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class TestFork extends TestCase {
private ProcessDefinition processDefinition;
@Before
public void setUp() throws Exception {
String xmlPath = "jbpmTest/fork/jpdl/fork.xml";
processDefinition = ProcessDefinition.parseXmlResource(xmlPath);
}
@After
public void tearDown() throws Exception {
}
@Test
public void test() {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
// processInstance.getContextInstance().setVariable("scenario", new Integer(1));
// processInstance.getContextInstance().setVariable("scenario", new Integer(2));
processInstance.getContextInstance().setVariable("scenario", new Integer(3));
processInstance.signal();
}
}
zhuan
最新推荐文章于 2025-08-04 20:43:02 发布