JBPM4 学习笔记 转
关于JBPM工作流
- 2. JBPM
jBPM,全称是Java Business Process Management,是一种基于J2EE的轻量级工作流管理系统。JBPM使用Hibernate进行数据库操作,也就是说只要Hibernate支持的数据库它都可以使用,数据库主要是存放流程的定义,流程实例的信息,还有用户的信息等。
Jbpm工作流适用于:
n 项目流程比较多,流程复杂的项目。
n 系统运行和维护、升级时,流程可能需要修改、调整和跟踪、控制的项目。
全称是jBoss jPBM Process Definition Language,这种一种构建于jBPM架构之上的流程语言之一。jPDL提供了图形化处理的界面,跟VB语言差不多,拖拖拽拽就能做出个东西来,非常直观。这里面提供了很多图形化节点:
start和end节点在每个jBPM项目中都会用到,分别为开始节点和结束节点;
- //如果是读取默认的jbpm.cfg.xml文件
- ProcessEngine engine = Configuration.getProcessEngine();
- //如果不是读取默认的jbpm.cfg.xml文件
- ProcessEngine engine = new Configuration()
- .setResource("ccjbpm.cfg.xml")
- .buildProcessEngine();
- RepositoryService repositoryService = processEngine.getRepositoryService();
- repositoryService.createDeployment()
- .addResourceFromClasspath("cn/javass/jbpm4/hello/hello.jpdl.xml")
- .deploy();
- ProcessEngine processEngine = Configuration.getProcessEngine();
- RepositoryService repositoryService = processEngine.getRepositoryService();
- List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list();
- for (ProcessDefinition pd:pdList){
- System.out.println("id:"+pd.getId());
- System.out.println("name:"+pd.getName());
- System.out.println("version:"+pd.getVersion());
- System.out.println("deploymentId:"+pd.getDeploymentId());
- System.out.println("---------------");
- }
- ProcessEngine processEngine = Configuration.getProcessEngine();
- ExecutionService executionService = processEngine.getExecutionService();
- Map map = new HashMap();
- map.put("pm","ProjectManager");
- map.put("dm", "DepartmentManager ");
- map.put("ceo", "Manager");
- executionService.startProcessInstanceByKey("MyProcess",map);
- ProcessEngine processEngine = Configuration.getProcessEngine();
- ExecutionService executionService = processEngine.getExecutionService();
- List<ProcessInstance> piList = executionService.createProcessInstanceQuery().list();
- for (ProcessInstance pi : piList) {
- System.out.println("id:"+pi.getId());
- System.out.println("activeActivityNames:“+pi.findActiveActivityNames());
- System.out.println("state:"+pi.getState());
- System.out.println("-----------------");
- ProcessEngine processEngine = Configuration.getProcessEngine();
- TaskService taskService = processEngine.getTaskService();
- List<Task> list = taskService.createTaskQuery().list();
- for(Task t : list){
- System.out.println("activityName="+t.getActivityName()+",user="
- +t.getAssignee()+",id="+t.getId());
- ProcessEngine processEngine = Configuration.getProcessEngine();
- TaskService taskService = processEngine.getTaskService();
- String taskId = “70003”;//这个是流程运行中生成的任务id
- Map map = new HashMap();
- map.put("dmResult", 1);
- map.put("days", 15);
- taskService.completeTask(taskId,map);
- ProcessEngine engine = Configuration.getProcessEngine();
- HistoryService hs = engine.getHistoryService();
- List<HistoryProcessInstance> list = hs.createHistoryProcessInstanceQuery().list();
- for(HistoryProcessInstance hpi : list){
- System.out.println("state="+hpi.getState()+" ,pdid=“+hpi.getProcessDefinitionId()+
- ",piid="+hpi.getProcessInstanceId()+",startTime="+hpi.getStartTime());
- }
- ExecutionService exe = engine.getExecutionService();
- Execution e = exe.createProcessInstanceQuery()
- .processInstanceId(piid).uniqueResult()
- .findActiveExecutionIn(“state活动名称");
- exe.signalExecutionById(e.getId());
- <decision name="evaluate document">
- <handler class="org.jbpm.examples.decision.handler.ContentEvaluation" />
- <transition name="good" to="submit document" />
- <transition name="bad" to="try again" />
- <transition name="ugly" to="give up" />
- </decision>
- public class ContentEvaluation implements DecisionHand
- public String decide(OpenExecution execution) {
- String content = (String) execution.getVariable("content");
- if (content.equals("you're great")) {
- return "good";
- }
- if (content.equals("you gotta improve")) {
- return "bad";
- }
- return "ugly";
- }
- }
- <decision>
- <transition name="good" to="submit document" />
- <transition name="bad" to="try again" />
- <transition name="ugly" to="give up" />
- </decision>
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("content", "good");
- ProcessInstance processInstance =
- executionService.startProcessInstanceByKey("DecisionExpression", variables);
- <decision name="evaluate document">
- <transition to="submit document">
- <condition expr="#{content=="good"}" />
- </transition>
- <transition to="try again">
- <condition expr="#{content=="not so good"}" />
- </transition>
- <transition to="give up" />
- </decision>
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("content", "good");
- ProcessInstance processInstance =
- executionService.startProcessInstanceByKey("DecisionConditions", variables);
- <task name="review" assignee="#{order.owner}" > 《或者assignee="johndoe"》
- <transition to="wait" />
- </task>
- public class Order implements Serializable {
- String owner;
- public Order(String owner) {
- this.owner = owner;
- }
- public String getOwner() {
- return owner;
- }
- public void setOwner(String owner) {
- this.owner = owner;
- }
- }
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("order", new Order("johndoe"));
- ProcessInstance processInstance = executionService
- .startProcessInstanceByKey("TaskAssignee", variables);
- List<Task> taskList = taskService.findPersonalTasks("johndoe");
- <task name="review" candidate-groups="sales" >
- <transition to="wait" />
- </task>
- IdentityService identityService = processEngine.getIdentityService();
- identityService.createGroup("sales");
- identityService.createUser(“zhang", “zhang", “san");
- identityService.createUser(“li", “li", “si");
- identityService.createMembership(“zhang", "sales");
- identityService.createMembership(“li", "sales");
- taskService.findGroupTasks("zhang");
- taskService.findGroupTasks("li");
- <task name="review" g="96,16,127,52">
- <assignment-handler class="org.jbpm.examples.task.assignmenthandler.AssignTask">
- <field name="assignee">
- <string value="johndoe" />
- </field>
- </assignment-handler>
- <transition to="wait" />
- </task>
- public class AssignTask implements AssignmentHandler{
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) { this.name = name; }
- public void assign(Assignable assignable, OpenExecution execution)
- throws Exception {
- assignable.setAssignee(name);
- }
- }
- <java g="246,135,92,52" name="java1" class="cn.javass.test.java.MyJava"
- method="sayHello" var="manager">
- <field name="user1"><object expr="#{user1}"/></field>
- <field name="user2"><string value="user2"/></field>
- <arg><string value="xyz"/></arg>
- <arg><object expr="#{abc}"/></arg>
- <transition to="task1"/>
- </java>
- public class MyJava{
- private String user1;
- private String user2;
- …user1和user2的setter
- public String sayHello(String arg1,String arg2){
- System.out.println("user1=="+user1);
- System.out.println("user2=="+user2);
- System.out.println("arg1=="+arg1);
- System.out.println("arg2=="+arg2);
- return “Hello";
- }
- }
- <sql g="192,438,92,52" name="sql1" unique="true" var="sqlV">
- <query>
- select * from tbl_user where uuid=:uuid
- </query>
- <parameters>
- <object name="uuid" expr="#{uuid}"></object>
- </parameters>
- <transition to="hql1"/>
- </sql>
- <hql name="hql1" g="404,457,92,52" unique="true" var="hqlV">
- <query>
- select o from Parent o where o.id=:id
- </query>
- <parameters>
- <string name="id" value="22"/>
- </parameters>
- <transition to="task2"/>
- </hql>
- <foreach name="foreach1" in="D1,D2,D3" var="nowDep">
- <transition to="task5"/>
- </foreach>
- <task name="task5">
- <transition to="join1"/>
- </task>
- <join name="join1" multiplicity="3">
- <transition to="task6"/>
- </join>
- <on event="start">
- <event-listener class="org.jbpm.examples.eventlistener.LogListener">
- <field name="msg"><string value="start on process definition"/></field>
- </event-listener>
- </on>
- <start>
- <transition to="wait"/>
- </start>
- <state name="wait">
- <on event="start">
- <event-listener class="org.jbpm.examples.eventlistener.LogListener">
- <field name="msg"><string value="start on activity wait"/></field>
- </event-listener>
- </on>
- <on event="end">
- <event-listener class="org.jbpm.examples.eventlistener.LogListener">
- <field name="msg"><string value="end on activity wait"/></field>
- </event-listener>
- </on>
- <transition to="park">
- <event-listener class="org.jbpm.examples.eventlistener.LogListener">
- <field name="msg"><string value="take transition"/></field>
- </event-listener>
- </transition>
- </state>
- public class MyEventListener implements EventListener{
- public void notify(EventListenerExecution exection) throws Exception {
- System.out.println("走出Decistion");
- }
- }
JBPM4 学习笔记 转的更多相关文章
- js学习笔记:webpack基础入门(一)
之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...
- PHP-自定义模板-学习笔记
1. 开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2. 整体架构图 ...
- PHP-会员登录与注册例子解析-学习笔记
1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...
- 2014年暑假c#学习笔记目录
2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...
- JAVA GUI编程学习笔记目录
2014年暑假JAVA GUI编程学习笔记目录 1.JAVA之GUI编程概述 2.JAVA之GUI编程布局 3.JAVA之GUI编程Frame窗口 4.JAVA之GUI编程事件监听机制 5.JAVA之 ...
- seaJs学习笔记2 – seaJs组建库的使用
原文地址:seaJs学习笔记2 – seaJs组建库的使用 我觉得学习新东西并不是会使用它就够了的,会使用仅仅代表你看懂了,理解了,二不代表你深入了,彻悟了它的精髓. 所以不断的学习将是源源不断. 最 ...
- CSS学习笔记
CSS学习笔记 2016年12月15日整理 CSS基础 Chapter1 在console输入escape("宋体") ENTER 就会出现unicode编码 显示"%u ...
- HTML学习笔记
HTML学习笔记 2016年12月15日整理 Chapter1 URL(scheme://host.domain:port/path/filename) scheme: 定义因特网服务的类型,常见的为 ...
- DirectX Graphics Infrastructure(DXGI):最佳范例 学习笔记
今天要学习的这篇文章写的算是比较早的了,大概在DX11时代就写好了,当时龙书11版看得很潦草,并没有注意这篇文章,现在看12,觉得是跳不过去的一篇文章,地址如下: https://msdn.micro ...
随机推荐
- 使用npm发布、查看、引用、删除自己的包[小白推荐]
前言 怎么使用npm发布自己的组件包呢?博主看了不少相关的文章,都没有一个好的讲述.要么丢三落四,要么就是复杂到外行人根本看不懂,甚至无从下手.于是,在博主的潜心钻研下,终于成功了!所以,我打算写一 ...
- Spring 依赖注入原理
所谓依赖注入就是指:在运行期,由外部容器动态地将依赖对象注入到组件中.当spring容器启动后,spring容器初始化,创建并管理bean对象,以及销毁它.所以我们只需从容器直接获取Bean对象就行, ...
- Codeforces 1062B Math(质因数分解)
题意: 给一个数n,可以将它乘任意数,或者开方,问你能得到的最小数是多少,并给出最小操作次数 思路: 能将这个数变小的操作只能是开方,所以构成的最小数一定是 $n = p_1*p_2*p_3*\dot ...
- webpack chunkFilename 非入口文件的命名规则 [转]
官网的文档只理解了filename是主入口的文件名,chunkFilename是非主入口的文件名 filename应该比较好理解,就是对应于entry里面生成出来的文件名.比如: { entry: { ...
- [MP3]MP3固件持续分享(2019.1.25)
转载自我的博客:https://blog.ljyngup.com/archives/179.html/ 所有的固件到我的博客就可以下载哦 最后更新于2019.2.1 前言 这篇文章会持续更新不同型号的 ...
- Part1-解线性方程组
自己一边听课一边记得,参考网上广为流传的那本<MIT线性代数笔记>,转成Latex上传太麻烦,直接截图上传了,需要电子版的可以私信我.
- JVM解毒——类加载子系统
带着问题,尤其是面试问题的学习才是最高效的.加油,奥利给! 点赞+收藏 就学会系列,文章收录在 GitHub JavaEgg ,N线互联网开发必备技能兵器谱 直击面试 看你简历写得熟悉JVM,那你说说 ...
- [WPF 自定义控件]在MenuItem上使用RadioButton
1. 需求 上图这种包含多选(CheckBox)和单选(RadioButton)的菜单十分常见,可是在WPF中只提供了多选的MenuItem.顺便一提,要使MenuItem可以多选,只需要将MenuI ...
- light oj 1214 - Large Division 大数除法
1214 - Large Division Given two integers, a and b, you should check whether a is divisible by b or n ...
- Arm开发板+Qt学习之路-开发板显示 /bin/sh: ./hello: Permission denied
将pc上交叉编译完成的可执行文件hello,通过串口传输到开发板上后,执行./hello显示 /bin/sh: ./hello: Permission denied 解决方案:在开发板上执行 chm ...