http://www.jboss.org/feeds/post/jbpm_4_0_cr1_released
JBPM-2279 https://jira.jboss.org/jira/browse/JBPM-2279
今天参考Schema实践了一把,终于找到了能将上下文中参数传递到java节点中的方法,流程源文件(对源文件进行了少许修改,如有错误请自行调试)如下
1. 流程定义文件:
2. java节点文件:
package com.synnex.jbpm.test.java;
import java.util.List;
import org.apache.log4j.Logger;
import org.jbpm.pvm.internal.env.ExecutionContext;
public class TestOperator {
public boolean doCreate(String batchNo, List l){
try{
System.out.println("----------------------------------------------batchNo = " + batchNo);
System.out.println("----------------------------------------------list[1] = " +(String)l.get(0));
}catch(Exception e){
e.printStackTrace();
}
return true;
}
}
3. Main:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.ManagementService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Test test = new Test();
test.deploy();
test.start();
}
ProcessEngine processEngine = new Configuration()
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
TaskService taskService = processEngine.getTaskService();
HistoryService historyService = processEngine.getHistoryService();
ManagementService managementService = processEngine.getManagementService();
//发布流程
public void deploy(){
long deploymentDbid = repositoryService.createDeployment()
.addResourceFromClasspath("com/synnex/jbpm/test/processes/test.jpdl.xml")
.deploy();
System.out.println(deploymentDbid);
}
//启动流程
public void start(){
Map variables = new HashMap();
//设置两个变量,一个字符串,一个List,传给Java节点
List l = new ArrayList();
l.add("Hello, I am a String~");
variables.put("batchNo", "12");
variables.put("list", l);
ProcessInstance pi = executionService.startProcessInstanceByKey("test", variables);
}
}
2
顶
0
踩
分享到:
2009-06-08 17:49
浏览 4830
评论