【JBPM4】EL表达式的使用,实现JAVA与JPDL的交互
user.java实体类
private String kezhang;
private String zhuren;
/...完善set get 方法.../
创建流程实例
//创建流程引擎
ProcessEngine processEngine = Configuration.getProcessEngine();
//获得执行服务
ExecutionService executionService = processEngine.getExecutionService();
//创建流程变量
Map<String,Object> map = new HashMap<String,Object>();
User user = new User();
user.setKezhang("张三");
user.setZhuren("李四");
map.put("user", user);
//用KEY获取的实例为最新的流程实例
ProcessInstance processInstance = executionService.startProcessInstanceByKey("test",map);
print("流程实例ID",processInstance.getId());
JPDL中就可以得到map中user对象的属性值。
<?xml version="1.0" encoding="UTF-8"?>
<process key="test" name="test" xmlns="http://jbpm.org/4.4/jpdl">
<start g="255,35,48,48" name="start1">
<transition g="-63,-25" name="提交到科长" to="科长审批"/>
</start>
<task assignee="${user.kezhang}" g="230,148,92,52" name="科长审批">
<transition g="-63,-25" name="提交到主任" to="主任审批"/>
</task>
<task assignee="${user.zhuren}" g="233,263,92,52" name="主任审批">
<transition g="-62,-25" name="通过" to="end1"/>
</task>
<end g="259,379,48,48" name="end1"/>
</process>