jBPM Business Process Management (BPM) 套件:
Runtime Engine 引擎
Web-based Designer 基于WEB的设计器 Oryx Designer
Eclipse Plugin
Management Console 管理控制台
Miscellaneous 其它如流程仓库Guvnor
2.
执行流
流程描述 - 流程 - 活动 - 事务
流程实例
process instance
3.
jBPM5 基于BPMN 2.0流程语言
4.
安装eclipse jBPM 插件及使用教程
4.1
安装需求
JDK 1.5+
Ant 1.7+
4.2
下载 jBPM5 安装文件并解压
http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.0-Final/
4.3
安装Demo
ant install.demo
将执行如下任务
------
下载 JBoss AS
下载 Eclipse
下载 Drools Guvnor into JBoss AS
下载 Oryx Designer
下载 jBPM gwt-console
下载 jBPM Eclipse plugin
下载 Drools Eclipse plugin
4.4
启动Demo
ant start.demo
将执行如下任务
------
启动 H2 database
启动 JBoss AS
启动 Eclipse
启动 Human Task Service
4.5
导入例子工程
http://people.redhat.com/kverlaen/install-eclipse-jbpm.swf
4.6
WEB 管理控制台
http://localhost:8080/jbpm-console
账号:
krisv / krisv
4.7
流程仓库
[url]http://localhost:8080/drools-guvnor [/url]
4.8
停止Demo
ant stop.demo
4.9 官方论坛
http://community.jboss.org/en/jbpm?view=discussions
5. 流程对象
Events
Start Event (None, Conditional, Signal, Message, Timer)
End Event (None, Terminate, Error, Escalation, Signal, Message, Compensation)
Intermediate Catch Event (Signal, Timer, Conditional, Message)
Intermediate Throw Event (None, Signal, Escalation, Message, Compensation)
Non-interrupting Boundary Event (Escalation, Timer)
Interrupting Boundary Event (Escalation, Error, Timer, Compensation)
Activities
Script Task (Java or MVEL expression language)
Task
Service Task
User Task
Business Rule Task
Manual Task
Send Task
Receive Task
Reusable Sub-Process (Call Activity)
Embedded Sub-Process
Ad-Hoc Sub-Process
Data-Object
Gateways
Diverging
Exclusive (Java, MVEL or XPath expression language)
Inclusive (Java, MVEL or XPath expression language)
Parallel
Event-Based
Converging
Exclusive
Parallel
Lanes
Data
Java type language
Process properties
Embedded Sub-Process properties
Activity properties
Connecting objects
Sequence flow
6.
WS-HT service
人工任务(非自动化任务)
生命周期
1.
创建 - 准备 - Reserved - 处理 - 完成|失败
2.
(准备 - Reserved - 处理) - 挂起
3.
(创建 - 准备 - Reserved - 处理) - 错误|退出|忽略
7.
流程上下文
kcontext
org.drools.runtime.process.ProcessContext
8.
Action
9.
Node
10.
流程变量及作用域
11.
约束
代码约束
规则约束
12.
事件
流程内部事件
外部事件
13.
定时器
Timer Event
14.
会话:流程实例通过会话与流程引擎交互,会话通过knowledge base的引用查询流程定义.通过会话可以启动流程实例.
创建knowledge base
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("MyProcess.bpmn"), ResourceType.BPMN2); KnowledgeBase kbase = kbuilder.newKnowledgeBase();
创建Session
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); ProcessInstance processInstance = ksession.startProcess("com.sample.MyProcess");
添加或移除监听器
ProcessEventListener
15.
整合jBPM 和 MyEclipse8.6
1.
下载GEF
http://www.eclipse.org/downloads/download.php?file=/tools/gef/downloads/drops/3.5.2/R201002241200/GEF-ALL-3.5.2.zip&url=http://download.actuatechina.com/eclipse/tools/gef/downloads/drops/3.5.2/R201002241200/GEF-ALL-3.5.2.zip&mirror_id=385
2.
复制步骤4中已经下载的包
drools
---------
drools-5.2.0.M1-eclipse-all.zip
jbpm
---------
jbpm-5.0.0-eclipse-all.zip
3. 解压并安装插件-链接方式
Drools
---------
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\features
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\plugins
E:\bisoft\tools\myeclipse\myplugins\drools520\eclipse\plugins\lib\*.jar
注意上面的lib目录下的包是安装目录下的lib目录及子目录下的所有JAR包.为了方便,我都放到lib目录下.为什么这样做?因为drools的包依赖这些包,所以必须的.
jbpm
-------
E:\bisoft\tools\myeclipse\myplugins\jbpm5\eclipse\plugins
gef
-------
E:\bisoft\tools\myeclipse\myplugins\gef\eclipse\features
E:\bisoft\tools\myeclipse\myplugins\gef\eclipse\plugins
注意这里的GEF不能用前面步骤4的GEF SDK包,因为MyEclipse使用Eclipse3.5,因此要下载3.5对应的GEF SDK包.
链接文件
-------
E:\bisoft\tools\myeclipse\dropins\drools520.link
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\drools520
E:\bisoft\tools\myeclipse\dropins\gef.link
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\gef
E:\bisoft\tools\myeclipse\dropins\jbpm5.link
path=E:\\bisoft\\tools\\myeclipse\\myplugins\\jbpm5
4. 配置JBPM运行时
指向runtime目录
5. 导入例子
sample\evaluation
6. 配置JBOSS_HOME
指向jboss-5.1.0.GA
7. 复制build.xml到工程下,并修改
前面的两个属性根据实际情况修改.
8. 启动H2数据库, JBOSS, 人工服务
start.demo
9. 运行或调试ProcessTest
10. 如果你的BPMN文件没有对应的编辑器,可以运行这个类并将输出的信息复制到
myeclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info的最后, 然后删除configuration/org.eclipse.update目录并重启MyEclipse.
package com.sample; import java.io.File; import java.util.ArrayList; import java.util.List; @SuppressWarnings("unchecked") public class CreatePluginsConfig { public CreatePluginsConfig() { } public static void main(String[] args) { // 插件位置 String plugin = "E:\\bisoft\\tools\\myeclipse\\myplugins\\drools520"; new CreatePluginsConfig().print(plugin); } public void print(String path) { List list = getFileList(path); if (list == null) { return; } int length = list.size(); for (int i = 0; i < length; i++) { String result = ""; String thePath = getFormatPath(getString(list.get(i))); File file = new File(thePath); if (file.isDirectory()) { String fileName = file.getName(); if (fileName.indexOf("_") < 0) { print(thePath); continue; } String[] filenames = fileName.split("_"); String filename1 = filenames[0]; String filename2 = filenames[1]; result = filename1 + "," + filename2 + ",file:/" + path + "\\" + fileName + "\\,4,false"; System.out.println(result); } else if (file.isFile()) { String fileName = file.getName(); if (fileName.indexOf("_") < 0) { continue; } int last = fileName.lastIndexOf("_");// 最后一个下划线的位置 String filename1 = fileName.substring(0, last); String filename2 = fileName.substring(last + 1, fileName .length() - 4); result = filename1 + "," + filename2 + ",file:/" + path + "\\" + fileName + ",4,false"; System.out.println(result); } } } public List getFileList(String path) { path = getFormatPath(path); path = path + "/"; File filePath = new File(path); if (!filePath.isDirectory()) { return null; } String[] filelist = filePath.list(); List filelistFilter = new ArrayList(); for (int i = 0; i < filelist.length; i++) { String tempfilename = getFormatPath(path + filelist[i]); filelistFilter.add(tempfilename); } return filelistFilter; } public String getString(Object object) { if (object == null) { return ""; } return String.valueOf(object); } public String getFormatPath(String path) { path = path.replaceAll("\\\\", "/"); path = path.replaceAll("//", "/"); return path; } }
11.
结果
12.
stop.demo
这里有个缺陷, 没有停止人工服务. 因此必须到任务管理器去结束进程.
13.
完成.