jbpm6安装部署

合集下载

jbpm详细教程

jbpm详细教程

JBPM开发指南BSTEK2007年7月目录一、概述 (4)二、第一个流程 (5)2.1、开始前的准备 (5)2.2 、Hello World 例子 (6)三、学习JPDL (11)3.1 、简介 (11)3.2 、流程版本(Version) (11)3.3 、流程定义 (12)3.3.1 process-definition(流程定义) (12)3.3.2 node(自动节点) (13)3.3.3 start-state(开始状态) (13)3.3.4 end-state(结束节点) (14)3.3.5 state(状态) (14)3.3.6 task-node (任务节点) (15)3.3.7 fork(分支) (16)3.3.8 join(联合) (17)3.3.9 decision(决策) (18)3.3.10 transition(转换) (19)3.3.11 event(事件) (20)3.3.12 action(动作) (20)3.3.13 script(脚本) (22)3.3.14 expression(表达式) (23)3.3.15 variable(变量) (23)3.3.16 handler(句柄) (23)3.3.17 timer(定时器) (24)3.3.18 create-timer(创建定时器) (25)3.3.19 cancel-timer(取消定时器) (26)3.3.20 task(任务) (26)3.3.21 swimlane(泳道) (27)3.3.22 assignment(委派) (28)3.3.23 controller(控制器) (29)3.3.24 process-state 子流程 (29)3.3.25 sub-process 子流程 (30)3.3.26 condition 条件 (30)3.3.27 exception-handler 异常处理 (31)小结 (33)四、流程中任务的分配 (37)4.1 assignment-handler方式的任务分配 (38)4.2 swimlane方式的任务分配 (39)五、JBPM持久化 (42)5.1 特殊数据库支持 (42)5.2 JBPM数据库的安装 (42)5.2 JBPM流程发布 (45)5.2.1 搭建JBPM的WEB应用 (46)5.2.2 发布第一个流程 (48)六、日历(Scheduler) (54)6.1 Scheduler在C/S程序上的应用 (54)6.2 Scheduler 在Web上的应用 (57)6.3 Scheduler时间的分类 (60)七、异步执行 (63)八、JBPM流程建模与应用 (64)8.1 JBPM的建模工具 (64)8.1.1 建模工具的安装 (64)8.2 公司报销流程示例 (67)8.2.1 流程建模 (67)8.2.2 流程数据库搭建 (76)8.2.3 构建业务表 (79)8.2.4 搭建工程 (82)8.2.5 报销流程的发布 (83)8.2.6 应用程序搭建 (84)九、写在最后 ........................................................................................ 错误!未定义书签。

JBPM安装及请假流程实例

JBPM安装及请假流程实例

1、开垦环境拆修之阳早格格创做1)jdk 5大概者更下版本2)收援的数据库有hsqldb、mysql、oracle、postgresql、sybase,本证明以oracle动做数据库.3)GPD插件(jbpm正在IDE中的过程安排器), \install\src\gpd中的,本证明以eclipse3.6为例.1)挨开window preferences2)采用 JBoss jBPM --> jBPM 4 --> Runtime Locations3)面打 Add...4)正在Add Location 对于话框中,输进一个名字,比圆jbpm-4.0而后面打 Search...5)正在Browse For Folder 对于话框中,采用您的jbpm 根目录,而后面打 OK6)面打 OK 正在 Add Location 对于话框中1.3定义jBPM 用户库1)面打窗心 --> 属性(Windows --> Preferences)2)采用Java --> 创修路径--> 用户类库(Java --> Build Path --> User Libraries)3)面打新修(New)4)典型名字jBPM Libraries5)面打增加JARs(Add JARs...)6)找到jBPM 拆置步调下的lib 目录7)采用lib 下的所有jar 文献并面打挨开(Open)8)采用jBPM Libraries 动做出心9)沉新面打增加JARs(Add JARs)10)正在jBPM 的拆置步调的根目录下采用jbpm.jar 文献11)面打挨开(Open)12)正在jbpm.jar 下采用源码附件(Source attachment)动做出心14)正在源码附件的摆设(Source Attachment Configuration)对于话框中,面打目录(External Folder...)15)找到jBPM 拆置步调下的src 目录16)面打采用(Choose)17)面打二次'决定'(Ok)会关关所有对于话框1.4正在目录中增加jPDL4 模式如果您念间接编写XML 源码,最佳是正在您的XML 目录中指定一下模式(schema),那样当您正在编写过程源码的时间,不妨更佳的助闲您编写代码.1)面打窗心 --> 属性(Windows --> Preferences)2)采用XML --> 目录(XML --> CataLog)3)面打增加(Add)4)增加XML 目录(Add XML Catalog Entry)的窗心挨开5)面打map-icon 的图标底下的按钮并采用文献系统(File System)6)正在挨开的对于话框中,采用jBPM 拆置目录下src 文献夹中jpdl.xsd 文献7)面打挨开(Open)而且关关所有的对于话框2、真例教程道解那节咱们将使用修坐一个简朴请假过程名目2.1 修坐名目正在eclipse中新修一个Dynamic Web Project的名目jbpm4leave.2.2 加进jbpm用户库1)邮件面打新修的名目jbpm4leave—>Properties2.3 加进jbpm所需要的摆设文献大家不妨从jbpm-4.4解压后的文献下,正在路径\examples\src中找到以下文献,加进到名目工程的src中其中jbpm.hibernate.cfg.xml是摆设jbpm4.4的hibernate摆设文献,包罗数据源的摆设,战普遍的hibernate.cfg.xml摆设文献好已几.Jbpm.mailkit开头的文献,是用于邮件功能的摆设.2.4 新修简朴的请假过程左键面打src New Other,采用JBoss jBPM下的Jbpm 4 Process Definition,文献名写leave,版本号写4.4即可.3)用过程安排器挨开新修的leave.jpdl.xml.Open With jBPM jPDL4 Editor,,瞅睹如下效验3)安排请假过程正在那个简朴的请假过程中,包罗开初(start)、中断(end)、任务(task)、计划(decision)四种过程元素.过程安排如下:4)仔细安排过程中的各任务节面的流转条件①选中“申请”任务节面,正在properties(属性)中,General标签的Name(属性值)挖为“申请”,Assignment标签的Type采用assignee (介进者,采用那个,不妨指定该任务节面的间接介进者),Expression的属性值挖为#{owner}(即指定那个任务节面的间接介进者便是那个过程的开用者).②选中“经理审批”任务节面,正在properties(属性)中,General 标签的Name(属性值)挖为“经理审批”,Assignment标签的Type 采用candidate-groups(介进者,采用那个,不妨该任务节面有某个用户组去介进),Expression的属性值挖为manager(即指定那个任务节面的有manager那个用户组去完毕).③“老板审批”节面共“经理审批”任务节面树坐类似,不过Expression改为boss④树坐计划节面,选中,正在属性标签General中按如下所示挖Name(节面称呼),Expression(推断表白式,其中day是正在过程流转历程中的一个记录天数的属性,所有表白式的意义是天数大于3天需要老板审批,如果天数没有大于3天,经理审批通过后便间接中断过程,没有需要老板审批).⑤安排佳过程后,面打保存,IDE将自动为您死成一个png的过程图片,切记没有成正在xml源码界里举止保存,可则会死成没有完备的过程图片.⑥正在面打下圆的“Source”属性,即可瞅到过程定义文献的xml 源码一下是leave.jpdl.xml的源码:<?xml version="1.0"encoding="UTF-8"?><process name="leave"xmlns="/4.4/jpdl"><start g="198,15,48,48"name="start1"><transition to="申请"/></start><task assignee="#{owner}"form="request.jsp"g="175,94,92,52"name="申请"><transition to="经理审批"/></task><task candidate-groups="manager"form="manager.jsp"g="176,174,92,52"name="经理审批"><transition g="-32,-8"name="接受"to="exclusive1"/><transition g="120,199;121,122:-42,-18"name="采与"to="申请"/></task><decision expr="#{day > 3 ? '老板审批' : '中断'}"g="196,259,48,48"name="exclusive1"><transition g="-39,-10"name="中断"to="end1"/><transition g="344,283:-71,-17"name="老板审批"to="老板审批"/></decision><task candidate-groups="boss"form="boss.jsp"g="299,305,92,52"name="老板审批"><transition g="342,378:"to="end1"/></task><end g="196,354,48,48"name="end1"/></process>2.5 颁布过程Jbpm的过程颁布本去很简朴,只消使用jbpm已经启拆佳的要领举履止用,即可.咱们新修一个deploy.jsp的页里用户颁布过程.正在此道解使用zip文献挨包颁布过程.1)将之前修坐佳的leave.jpdl.xml战leave.png文献,所有挨包进leave.zip文献.2)deploy.jsp代码如下:<%@page language="java"contentType="text/html; charset=gb2312"%> <%@pageimport="java.io.File,java.io.FileInputStream,java.io.InputStream,java.util.zi p.ZipInputStream,java.util.*,org.jbpm.api.*,java.util.zip.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01Transitional//EN""/TR/html4/loose.dtd"><html><head><title>Insert title here</title></head><body><%request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");String deployFile = request.getParameter("processDef");if (deployFile != null && deployFile != "") {//必须使用的,过程引擎ProcessEngine processEngine = Configuration.getProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService();try {String file = deployFile;//将ZIP文献启转到IO流里InputStream is = new FileInputStream(new File(file)); ZipInputStream zis = new ZipInputStream(is);//将ZIP过程文献颁布到pvm(过程假造机中,他会把ZIP包中的xml文献战png图片保存到数据库中)repositoryService.createDeployment().addResourcesFromZipInputStream(zis).deploy();is.close();out.println("颁布过程乐成<br />");out.println("<a href='task-write.jsp'>返回</a><br />");} catch (Exception e) {e.printStackTrace();out.println("颁布过程波折");}}%><script type="text/javascript">function readFile(obj) {document.getElementById("file").value = obj.value;}</script><font color="red">可间接颁布zip文献</font><br/><form name="form1"method="post"action="deploy.jsp"><label>颁布过程文献<input type="file"name="processDef"onchange="readFile(this)"></label><label><input type="submit"name="Submit"value="提接"></label></form></body></html>3)尝试颁布乐成截止4)查看已颁布乐成的过程已经有的一个查看过程的页里,源码如下:<%@page language="java"contentType="text/html; charset=GB18030" pageEncoding="GB18030"%><%@include file="/head.jsp"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01Transitional//EN""/TR/html4/loose.dtd"><%String username = (String) session.getAttribute("username");//过程引擎ProcessEngine processEngine = Configuration.getProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService();//过程定义集中List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list();<html><head><meta http-equiv="Content-Type"content="text/html; charset=GB18030"> <title>Insert title here</title><style type="text/css">body {font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,sans-serif;color: #4f6b72;background: #E6EAE9;}a {color: #c75f3e;}#mytable {padding: 0;margin: 0;}caption {padding: 0 0 5px 0;width: 700px;font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; text-align: right;}th {font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72;border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;border-top: 1px solid #C1DAD7;letter-spacing: 2px;text-transform: uppercase;text-align: left;padding: 6px 6px 6px 12px;background: #CAE8EA;}th.nobg {border-top: 0;border-left: 0;border-right: 1px solid #C1DAD7;background: none;}border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;background: #fff;font-size: 11px;padding: 6px 6px 6px 12px;color: #4f6b72;}td.alt {background: #F5FAFA;color: #797268;}th.spec {border-left: 1px solid #C1DAD7;border-top: 0;background: #fff;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; }th.specalt {border-left: 1px solid #C1DAD7;border-top: 0;background: #f5fafa;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #797268;}body.td {font-size: 11px;}</style></head><body><TABLE width="100%"id="mytable"id="mytable"><caption>过程定义</caption><thead><tr><th class="spec">过程id</th><th>过程称呼</th><th>版本号</th><th>过程简略</th><th>开用过程</th></tr><tbody><%for (ProcessDefinition pd : pdList) {%><tr><th class="spec"><%=pd.getId()%></th><td class="alt"><%=pd.getName()%></td><td class="alt"><%=pd.getVersion()%></td><td class="alt"><a href="remove.jsp?id=<%=pd.getDeploymentId()%>">简略过程</a></td><td class="alt"><a href="start.jsp?id=<%=pd.getId()%>">开用过程</a></td></tr><%}%></tbody></table></body></html>5)查看过程颁布情况6)过程定义所安排到的表JBPM4_DEPLOYMENTJBPM4_DEPLOYPROP//存搁过程定义的版本号,使用的jbpm版本号,已经过程名JBPM4_JOB//存搁timer的定义JBPM4_LOB //存搁过程定义的xml战png图片文献2.6 开用过程1)开用过程,本去很简朴,需要赢得过程定义的ID,使用jbpm已经启拆佳的过程开用要领便不妨了.<%@page import="java.util.*,org.jbpm.api.*,java.util.*"%><%request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");try{//过程引擎//过程真例服务ExecutionService executionService = processEngine.getExecutionService();Map map = new HashMap();//拔出过程中存搁的数据,那里存搁过程开用者的名字,参数id是过程定义的IDmap.put("owner", session.getAttribute("username")); executionService.startProcessInstanceById(request.getParameter("id"), map);response.sendRedirect("task-personal-list.jsp");}catch(Exception e){e.printStackTrace();}%>2)查看代庖任务//<%@page language="java"contentType="text/html; charset=GB18030" pageEncoding="GB18030"%><%@page import="org.jbpm.api.*,org.jbpm.api.task.*"%><%@include file="/head.jsp"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01Transitional//EN""/TR/html4/loose.dtd"><%String username = (String) session.getAttribute("username");//过程引擎ProcessEngine processEngine = Configuration.getProcessEngine();//任务引擎TaskService taskService = processEngine.getTaskService();//目前用户代庖的任务集中List<Task> taskList2 = taskService.findPersonalTasks(username);%><html><head><meta http-equiv="Content-Type"content="text/html; charset=GB18030"> <title>Insert title here</title><style type="text/css">body {font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,sans-serif;color: #4f6b72;a {color: #c75f3e;}#mytable {padding: 0;margin: 0;}caption {padding: 0 0 5px 0;width: 700px;font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; text-align: right;}th {font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72;border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;border-top: 1px solid #C1DAD7;letter-spacing: 2px;text-transform: uppercase;text-align: left;padding: 6px 6px 6px 12px;background: #CAE8EA;}th.nobg {border-top: 0;border-left: 0;border-right: 1px solid #C1DAD7;background: none;}td {border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;background: #fff;font-size: 11px;padding: 6px 6px 6px 12px;color: #4f6b72;}td.alt {background: #F5FAFA;color: #797268;th.spec {border-left: 1px solid #C1DAD7;border-top: 0;background: #fff;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}th.specalt {border-left: 1px solid #C1DAD7;border-top: 0;background: #f5fafa;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #797268;}body.td {font-size: 11px;}</style></head><body><table width="100%"id="mytable"id="mytable"><caption>部分待办任务</caption><thead><tr><th class="spec">过程ID</th><th>目前节面</th><th>查看仔细疑息</th><th>查看过程图</th></tr></thead><tbody><%for (Task task : taskList2) {%><tr><td class="alt"><%=task.getId()%></td><td class="alt"><%=task.getName()%></td><td class="alt"><ahref="<%=task.getFormResourceName()%>?id=<%=task.getId()%>">查看仔细疑息</a></td><td class="alt"><a href="view.jsp?id=<%=task.getExecutionId() %>">查看过程图</a></td></tr><%}%></tbody></table></body></html>3)真止如图://过程列表//过程开用后,成为目前用户的待办任务2.7 过程操持(申请)由于咱们的过程如下,开用开用过程后,过程便加进了“申请”那个过程节面(注:过程开用后,会正在过程第一个节面所有人/所有组的代处世项中找到).所以,目前便要正在申请中举止操持.由于咱们正在定义过程时如下定义了:<task assignee="#{owner}"form="request.jsp"g="175,94,92,52"name="申请"><transition to="经理审批"/></task>定义了,“申请”那个节面是有过程开用者举止操持的,form指定操持“申请”那个节面的处理页里,用户不妨自己定义处理页里.Transition 指定申请过程的下一个出心.1)正在代处世项中,咱们有一止如下代码:<ahref="<%=task.getFormResourceName()%>?id=<%=task.getId()%>">查看仔细疑息</a>正在那里会传一个任务ID,所以正在request.jsp中必须要博得那个任务ID.<%@page language="java"contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01Transitional//EN""/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><%request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");%><fieldset><legend>申请</legend><form method="post"onsubmit="return validate()"><input type="hidden"name="taskId"value="${param.id}">申请人:<input type="text"name="owner"value="${sessionScope['username']}"/><br />请假时间:<input type="text"name="day"value=""onchange="change(this)"/><br/>请假本果:<textarea name="reason"></textarea><br/><input type="submit"/></form></fieldset><script type="text/javascript">function change(obj){var reg = /^[1-9]\d*$/;if (!reg.test(obj.value)){alert("天数必须为正整数!");obj.value="";obj.focus();returnfalse;}}function validate(){var obj = document.getElementsByName("day")[0].value;var reg = /^[1-9]\d*$/;if (!reg.test(obj)){alert("天数必须为正整数!");document.getElementsByName("day")[0].value="";document.getElementsByName("day")[0].focus();returnfalse;}else{document.forms[0].action="submit.jsp";document.forms[0].submit();returntrue;}}</script></body></html>前台隐现如下:挖写完真质后,页里将会提接到submit.jsp,将对于提接的数据举止处理,共时过程继承流转,所以正在提接的的页里中要处理二件事务:1、处理用户提接数据,将数据战过程真例举止绑定2、将过程继承流转,提接给下一个节面操持。

jbpm下载路径及安装说明

jbpm下载路径及安装说明
assertTrue(processInstance.isActive("state1"));
String pid = processInstance.getId();
//让state1活动继续往下执行,并进入结束活动,流程结束
//主要用来启动流程,执行流程
ExecutionService executionService = null;
protected void setUp() {
processEngine = new Configuration().buildProcessEngine();
3、左边Browse Software选择add site---->Add from Archive File;
4、Name写jbpm4.3,url是jbpm4.3解压缩目录下install-->src--->gpd-->jbpm-gpd-site.zip的文件路径,然后点击OK;
5、左边Browse Software下会出现Personal Sites,在底下有jbpm4.3的一个树,打开树底下7个分别右击选择add to profile;
}
protected void tearDown() {
repositoryService.deleteDeploymentCascade(deployId);
}
public void testEndHelloWorld() {
processInstance = executionService.signalExecutionById(pid);
ห้องสมุดไป่ตู้ assertTrue(processInstance.isEnded());

jBPM指南

jBPM指南

jBPM指南这个指南将向你展示如何用jpdl创建基本的流程以及如何使用API管理运行期的执行。

这个指南的形式是解释一组示例,每个示例集中于一个特殊的主题,并且包含大量的注释,这些例子也可以在jBPM下载包的目录src/java.examples中找到。

最好的学习方法就是建立一个工程,并且通过在给定例子上做不同的变化进行实验。

对eclipse用户来说可以如下方式开始:下载jbpm-3.0-[version].zip并且解压到自己的系统,然后执行菜单“File”-->“Import…”-->“Existing Project into Workspace”,然后点击“Next”,浏览找到jBPM根目录,点击“Finish”。

现在,在你的工作区中就有了一个jbpm.3工程,你可以在src/java.examples/…下找到本指南中的例子,当你打开这些例子时,你可以使用菜单“Run”-->“Run As…”-->“JUnit Test”运行它们。

jBPM包含一个用来创作例子中展示的XML的图形化设计器工具,你可以在“2.1 下载概述”中找到这个工具的下载说明,但是完成本指南不需要图形化设计器工具。

3.1 Hello World 示例一个流程定义就是一个有向图,它由节点和转换组成。

Hello world流程有三个节点,下面来看一下它们是怎样组装在一起的,我们以一个简单的流程作为开始,不用使用设计器工具,下图展示了hello world流程的图形化表示:图 3.1 hello world流程图public void testHelloWorldProcess() {// 这个方法展示了一个流程定义以及流程定义的执行。

// 这个流程定义有3个节点:一个没有命名的开始状态,// 一个状态“s”,和一个名称为“end”的结束状态。

// 下面这行是解析一段xml文本到ProcessDefinition对象(流程定义)。

JBPM 6 开发者指南 Chapter 5

JBPM 6 开发者指南 Chapter 5

Chapter 5. Creating a Process Project in the KIE WorkbenchEven if jBPM6 uses BPMN 2.0, an XML-based standard, to define its processes, it’s just not practical to write such files with a simple text editor. We need a way to define our process in a user-friendly environment that will aid both technical and non-technical people who know about the specifics of the steps involved in a process to define a process definition.The BPMN 2.0 specification not only defines the behavior syntax for our processes, but also the look and feel for the process diagrams as well. This chapter will show you a step- by-step approach to learn how to use the jBPM6 Web Process Designer that lives inside the KIE Workbench to define BPMN 2.0 files using a diagram-writing UI. In this chapter, we will learn:To define our processesTo test our processes with simulationsTo extend the BPMN 2.0 model to add our own types of tasksAn IDE to our knowledgeThe main purpose of BPMN 2.0 is to provide business process representations that can be understood without the need for technical skills. Its concepts are not technical at all. There are abstract representations for when tasks need to be performed, decisions should be taken, and information needs to flow from one point to another—not tied to any technical implementation at the business process definition level.The implementation, however, handles specific technical concepts that allow BPMN 2.0 to define connections to specific components in order to make it run on defined runtimes. These connections have several complex parts intrinsic to a technical implementation that require a deep understanding of IT. BPMN 2.0 needs to provide a way to work with these two perspectives, and this is why jBPM6 adds specific extensions provided by the tooling to configure all the specific components needed to define and run our process inside the jBPM6 runtime.In this way, we can say that the graphical representation of the diagram is a business perspective of the process designer, while the specifics of configuring its properties and validating the process rely on a more technical profile.A variety of process designersWhen we start using jBPM6, one of the most confusing things is the fact that we have three different process designers to choose from. For those who are new to jBPM6 or who have used previous versions of it, it can be very confusing. Let’s take a look at all the available options.The BPMN 2.0 Eclipse editorThis is a graphical modeling tool for the creation and editing of processes in BPMN 2.0 (shown in the following screenshot), distributed as a plugin in the Eclipse IDE. If you wish to edit your BPMN 2.0 files from your own IDE, it is perhaps the best alternative to do so. Have a look at the following screenshot:It has extended support for the BPMN 2.0 specification and for some jBPM6-specific characteristics. However, it is not fully integrated to jBPM6 runtime configurations, so some of the components that we might create with this editor might not be supported by the runtime afterwards. It is recommended to be used as a portable tool for IDEs to see process definitions exported from other designers (something we will see in more detail later in this chapter), but not for creating them from scratch.The Web Process DesignerThe jBPM6 Web Process Designer is an adaptation and almost complete reconstruction of an open source web editor capable of creating a full BPMN 2.0 diagram called Oryx. This project has been adapted, reconfigured, extended, and adapted again to the new web-based workbench applications provided for jBPM6 distribution into a completely new tool, and is now called the jBPM6 Web Process Designer. It is embedded in the workbench structuresof UberFire and works as another editor for projects in the KIE Workbench, asshown in the following screenshot:Today, the Web Process Designer is the official process editor that comes with the KIE Workbench. This designer is heavily maintained at the moment, with new features and bug fixes being implemented on a regular basis to keep track with all the jBPM6 changes. Because it is the designing tool most aligned with jBPM6 features, for the rest of this chapter, we are going to cover the usage of this editor.The jBPM Eclipse pluginThe jBPM Eclipse plugin was the first plugin supplied with the early versions of jBPM5. This plugin was a straightforward migration from the already existing Drools Flow Eclipse plugin. When Drools Flow was rebranded into jBPM5, the decision was to stop supporting the RuleFlow (RF) proprietary language for process definitions and embrace the new BPMN 2.0 standard instead. This editor is now officially discontinued. No new features have been introduced in it for a long time. You can still use this editor to create really simple processes, but its usage is strongly discouraged.Interacting with the Web Process DesignerThe KIE Workbench comes with the latest stable version of the Web Process Designer. After the JBoss instance is launched (see Chapter 4, Understanding the KIE Workbench), we will have to access the process designer by going to the Authoring | Project Authoring perspective and interact with an existing project to work with its process definitions (and other types of knowledge).In this section, we are going to explain how to create, modify, and delete processes in the KIE Workbench. After these three operations are explained, we will be ready to cover the different features provided by the Web Process Designer in detail as well as how we can use them to define some of the processes that have already been covered in previous chapters of this book.Creating new processesIn Chapter 4, Understanding the KIE Workbench, we had a glimpse of how to list the processes residing in a project folder. We used the playground repositories and project already provided by the KIE Workbench by default as a demo. But of course, before we can list the processes of a project, we need to create them. If we want to create a new process, we need to go to the New Item action toolbar option of the Project Authoring perspective and select the Business Process option.Before the new process is created, we need to provide some information using the pop-up window that is opened, shown in the following screenshot. It will provide us with a textbox for selecting a name for our process. It is also going to give us a Virtual File System (VFS) path for the folder where the process will be created.TipThe KIE Workbench will store all knowledge assets we create in a VFS, which for the current version is implemented in Git repositories.Please enter the resource name when this screen pops up.The name we choose for the business process must be unique among all the assets in the same folder, as it’s going to be used by the KIE Workbench to internally identify the process. Once we have selected a suitable name, sprintManagement, for our first process definition, we can create the new process by clicking on the Ok button. This will create an empty process definition and invoke the Web Process Designer so that we can start working.Implementing our first processNow that we know how to create and access our processes in the KIE Workbench, it’s time to create a new process using the Web Process Designer. The process we are going to implement is the sprint management process introduced in Chapter 3, Using BPMN 2.0 to Model Business Scenarios. We are going to use this process to learn not only about its specific implementation, but also to cover the different features present in the process editor.In the previous section, we created the sprintManagement process. The KIE Workbench will now display the Web Process Designer tool, and we can start using it. But before we start implementing the process, let’s do a quick revision of the different sections we have in the Web Process Designer as well as its features.The Web Process Designer sectionsThe Web Process Designer’s UI contains four main sections: a toolbar at the top, Shape Repository as an accordion panel on the left-hand side, an editing canvas at the center, and a Properties panel as an accordion panel on the right-hand side of the editor. Let’s analyze the main purpose of each one of these sections.The toolbarThe toolbar is the topmost part of the designer panel; it contains different options to allow us quick access to most of the features present in it as well as other useful options regarding the layout of the process and its elements. The toolbar also has some other important features that we are going to cover in this chapter, such as importing process definitions or running simulations. So, feel free to play around with what’s in the toolbar until you get used to the options that you have and where they are.The Shape Repository panelThe Shape Repository collapsible panel contains the palette of BPMN 2.0 elements used to construct business processes. In this palette, you will find all of the BPMN 2.0 elements (described in Chapter 3, Using BPMN 2.0 to Model Business Scenarios) grouped according to their type. Sometimes, having all of the available elements in the palette is not the best thing. After you have designed a couple of processes, you will notice thatmost of the time you are using only a subset of these elements. This is why in the Shape Repository panel, there are two different library sets: Full and Simple. You can switch from one perspective to the other by using the drop-down list present at the top of the Shape Repository panel. There is also a third option called RuleFlow, used to create files with the legacy description language for process definitions in jBPM6, but it is an outdated format that no longer has support in the project, so we will skip it in this book.At the bottom section of the Shape Repository panel, we’ll find the Workflow Patterns panel with some predefined process flow structures to help you design your own processes faster and in a standardized manner.The editing canvasThe editing canvas is perhaps the most important part of the Web Process Designer. It is where we are going to design our processes using the elements present in the Shape Repository panel.When we drag-and-drop an element from the Shape Repository panel into the editing canvas, the element is added; we can change its position by simply dragging-and-dropping it around the canvas. Each element in the canvas has a context menu that we can access by clicking on the element. Using this menu (shown in the next screenshot with all the different icons that will appear around a task when we click on it), we can do different things such as creating new linked elements without using Shape Repository, changing the type of the element, accessing the process dictionary, editing its associated task form (ifwe are in a User task), or seeing the portion of BPMN 2.0 generated by the element.Have a look at the following screenshot:By default, the editing canvas comes with a preloaded Start Event, so you could start writing a process without the need to access Shape Repository at all. Some elements, such as sequence flows, have dockings that you can use to bind those elements to some other shape in the editing canvas.In the upper-left corner of the editing canvas, we can see the process name, version, and ID. In the north, south, east, and west areas of the editing canvas, we can find little yellow arrows that will only appear when we move the mouse over their region. We can use these arrows to increase or decrease the total area of the editing canvas.The Properties panelWhen a BPMN 2.0 element is selected in the editing canvas, its properties are displayed in the right-hand side collapsible panel of the Web Process Designer. This Properties panel is very synced up with the properties supported by jBPM6, and to the greatest extent, to the core BPMN 2.0 specification.Not all the elements have the same properties set, which is why the Properties panel adapts its content to the element currently selected in the editing canvas. If multiple elements are selected in the editing canvas, only the properties that the selected elements have in common will be displayed. In that case, changing the value of a property will modify the property value in all of the selected elements.Properties can be of different data types: String, Boolean, complex, and so on. Depending on the type of the property being modified, the Properties panel can display different editors, such as a text area, a checkbox, a pop-up form, and so on.Sprint management process designNow that we have a better understanding of the tool, we can create a definition of the sprint management process introduced in Chapter 3, Using BPMN 2.0 to Model Business Scenarios. To explain the biggest variety of elements, we will use the third version of the process we defined, which is the most complex. Please refer to Chapter 3, Using BPMN 2.1to Model Business Scenarios, if you need to refresh any information about what the process definition contains. The idea is to know how to create the diagram shown in the following figure:We’ll continue working on the sprintManagement process definition. We will move the cursor over the predefined start node and select the Task option from its contextual menu (which should be the small rectangle with the rounded corners). This option will add a new task that is connected to the Start Event node in the editing canvas. We can repeat these steps, adding gateways (rhomboids) and sequence flows (arrows) when needed, by clicking on the rhomboid and rectangle icons on the context menu we previously described and by clicking-and-dragging on the arrow icon to create sequence flows connecting existing objects. Finally, we can create an End event node by clicking on the circle icon of the context menu with the thicker border.When getting to the point where we need catching events and boundary events, we can search for them in Shape Repository by clicking on the left-hand side accordion panel, selecting from the different menus available (Tasks, Gateways, Intermediate Catch Events, and so on), and dragging-and-dropping a specific element into the editing canvas. We can drop the boundary events on the border of each task (you will see that the border of the task becomes green to indicate you can drop the catching event as a boundary event). Later on, selecting those intermediate events will allow us to continue adding components from their respective contextual menus of each element in the editing canvas.Configuring the process propertiesWe will start our process definition configuration by populating the mandatory attributes of the process itself. To do this, we have to click on the background of the editing canvas and go to the Properties panel, located at the right-hand side of the designer in an accordion panel. Each process definition has the following jBPM6-related properties: Property DescriptionAdHoc This Boolean property identifies whether this process is ad hoc or not. Ad hoc processes are special processes where the internal nodes don’t have to be connected to each other, and the flow between the nodes is handled by an external component (either rules or specific user interactions). In our case, we will leave it as it is by default (false).Executable The BPMN 2.0 specification defines two types of processes—executable and nonexecutable. Of course, because the main idea of the process designer is to create executable BPMN 2.0 processes, the value of this property is true by default.Globals Using this property, we can define Drools global variables to share information amongst processes as well as among global services that can be later invoked inside the process.When we want to edit the value of this property, a drop-down menu appears, and when we try to open it, there will be a pop up containing an editor for global variables.ID This property identifies the ID attribute of the generated <process> BPMN 2.0 element. The ID of the process must be unique inside a KIE base, as it is used at runtime to identify a process definition.Imports Just as in Java, when we’re dealing with a process definition, we need to import all the different classes we want to use in our process.Variable Definitions This property defines the variables available in the process. Variables are important for maintaining internal values, sharing information between nodes, and getting some kind of result from the process execution.Now that we have a clear idea of the properties a process has, we can see some extra details about some of them.For example, the ID of the process has quite an important role. As it will identify the process definition inside a KIE base, we are going to depend on it to start a process or to define a Call Activity node (reusable subprocess). In our case, we will set the ID for this process as sprintManagement-V1.Finally, we need to define the process variables required by this definition by editing the Variable Definitions property of our process. When we click on the list box display of the property value, an editor will show us the dialog box as shown in the following screenshot, where we can add, remove, and define the name and type of our process variables. In the process we are designing, we need six variables: project, reqDescription, and developerId of type String; compiled and deployed of type Boolean; and storyPoints of type Integer. The final result should be as shown in thefollowing screenshot:Once we have the process configured, we need to review each of the nodes it has in order to configure their properties.Configuring the event nodesThe Start Event node represents the beginning of the process. From all the different Start Event types that we can use, we will use the None Start Event node, because in jBPM6, you have to use this type of Start Event when your process is going to be explicitly started using its ID, as the following line of code does:Ksession.startProcess("id.of.the.process");The properties present in this node relevant to the jBPM6 runtime are as follows:Given that this None Start Event node doesn’t have any properties that affect its behavior during execution, we are not going to modify any of them.After the Start Event node is invoked, a process execution will be started. During the process execution, we might capture two other types of events, Signal Intermediate Catch events (the circle with a triangle inside it at the bottom of the diagram) and Error Boundary events (the two circles with the lightning-like icon, located at the border of two of the tasks we defined).Intermediate Signal Event nodes have to wait for an event to arrive in order to continue their execution. Events can be broadcast from another process or from the Java application. Using them allows us to create more maintainable and robust processes. The properties we can configure a Signal Intermediate Catch event are as follows:This is the key name of the event type that the node is waiting for. It is just a string that SignalRefmust be used when you want to signal the event.In our scenario, the event we are going to be waiting for is the manual cancellation of the requirement, which is why we need to change the SignalRef property to reqCancelled.To do so, we select the event and then click on the Properties panel, where we will see the properties of the event selected. In this case, we don’t want to know anything else from the event, so we are not going to define any DataOutput or DataOutputAssociationsproperty in this node. The only other change we are going to make to this node is to add ameaningful name to it so that users reviewing this process can easily understand what event the node is waiting for. The value we are going to set for the Name property is: Req. Cancelled.The Error Boundary events that we defined for two of our tasks show that we want tohandle exceptions being thrown inside the execution of said tasks as part of the sequence of steps in this process. Just like the Signal events, they have DataOutput and DataOutputAssociations to capture the event being sent. In them, you define a single variable with any name that you can map to a process variable to keep the exception as avariable in subsequent nodes. For our case, we are not going to configure those properties. The one property we are going to configure is the ErrorRef property. In it, you must write the fully qualified name of the exception you expect to capture. In jBPM6, it must be a single specific type (not a generic super class of the exception, but the actual exception), and it must have a fully qualified name even if you added the exception type to the Imports property in the process properties. For our case, we will typeng.RuntimeException in said property.The last event nodes that we will configure in our process are the End Event nodes, whichrepresent the end of the execution path on the process. We can configure them for manydifferent purposes, but in our case, we will use only a type that will terminate the completeprocess instance (the Terminating End event), regardless of how many pending executionpaths may still exist for both execution paths that diverge from the first parallel gateway.Configuring the task nodesThe task nodes in BPMN 2.0 are where concrete actions take place. The steps that are required to achieve our process’ goal are going to be defined using task nodes.The BPMN 2.0 specification provides eight task types (Abstract task, Service task, Send task, Receive task, User task, Manual task, Business Rule task, and Script task), and jBPM6 supports all of them.We will focus on the valid set of properties that affect each of the different tasks supported by jBPM6, but we are not going to cover the detailed behavior of the tasks at runtime.In the Web Process Designer, all of the different types of tasks are implemented by just one element in the Shape Repository panel—Task. The TaskType property of each nodeis going to specify its concrete type. An empty value for TaskType (the default value in the Web Process Designer) identifies an abstract task.Each task type has a different set of attributes that we can use to configure it. The Web Process Designer will automatically show only the valid attributes for each specific task type. The following table explains the valid properties for each type:Abstract taskProperty DescriptionName The name for the task that will be shown in the box.DataInputSet The input variables of the node.DataOutputSet The output variables of the node.Assignments The assignments between the process variables and the input and output variables of the node.On Entry Actions A piece of Java code that is invoked before the node gets executed. All of the process variables are available in this piece of code. This is an extension of BPMN 2.0 provided by jBPM6, and not part of the standard.On Exit Actions A piece of Java code that is invoked after the node gets executed. All of the process variables are available in this piece of code. This is an extension of BPMN 2.0 provided by jBPM6, and not part of the standard.Abstract tasks are used by jBPM6 as an extension point for plugging in our business- related logic. DataInputSet, DataOutputSet, Assignments, On Entry Action, and On Exit Action are the properties common to all other types of tasks and have the same behavior for all of them. We will omit them in the next tables and concentrate exclusively on the extraproperties that each task type has:Property DescriptionIn jBPM6, the Drools rule engine performs rule execution. These two frameworks, jBPM6 and Drools, are so well integrated that the switch from one engine to the other is seamless for the user. Actually, the switch has never existed since both engines share the same core. The following table shows the Send task’s special properties:DataInputSet is especially important for the Send task, as it will map the message to be sent from the process variable.The following table shows the Receive task’s special properties:DataOutputSet is especially important for the Receive task, as it will map the message received.The following table shows the Script task’s special properties:Script taskProperty DescriptionScriptThis property defines the piece of code we want executed when the process execution reaches this node. Inside this piece of code, we have access to all of the process variables and the special variable kcontext . Script Language This defines the language used in the Scriptproperty. This language could be Java or MVEL, which is a scripting language that runs on top of the JVM.Business users do not commonly use Script tasks, but they are really helpful for technical people. By adding Script tasks to a process, we can easily modify the behavior of our processes without modifying any Java class. We can use this type of task to add logs, messages, or to perform data transformation tasks in our processes. As a rule of thumb, Script tasks shouldn’t contain business logic inside them. Abstract tasks, Human tasks, and Service tasks are better places to implement this kind of logic. Let’s start with the Service tasks as shown in the following table:RuleflowGroup This property is used to specify the group of rules that must be executed when the process execution reaches this node.Property DescriptionService Interface If the jBPM6 predefined handler for this task type is used (ServiceTaskHandler), this property should be the fully qualified name of the class we want to use as a service; and each time this task is executed, a new instance will be created through reflection.ServiceOperationThis property identifies the name of the method we want to invoke in the Interface object. User tasks are the ones that should be performed by humans:User taskProperty DescriptionActors A comma-separated list of actor IDs or an expression of the form #{<expression>} that evaluates to a string object. In the default Human task implementations of jBPM6, this property defines the possible owners of a task.Groups A comma separated list of group IDs or an expression of the form #{<expression>} that evaluates to a string object. In the default Human task implementations of jBPM6, this property defines the actor’s groups that can own this task.Task Name This is the name of the user task. In the default Human task implementations of jBPM6, this property defines the task name that should be displayed to the user.Comment In the default Human task implementations of jBPM6, this property defines a comment for the task. Priority In the default Human task implementations of jBPM6, this property defines the priority of the task.Skippable In the default Human task implementations of jBPM6, this property defines whether this task can be skipped or not.Notifications In the default Human task implementations of jBPM6, this property defines a set of time rules for sending specific e-mail notifications to other users or groups when a task has not been started or completed within a specific amount of time.Reassignment In the default Human task implementations of jBPM6, this property defines a set of time rules for automatically reassigning this task to another user or group when a task has not been started or completed within a specific amount of time.The properties of the User task are tightly related to the default Human task implementation of jBPM6. This implementation is going to be introduced and explained in Chapter 6, Human Interactions.Manual tasks have the same attributes explained for an Abstract task. The variables you can define in the DataInputSet and DataOutputSet properties depend on the handlers you register for Send, Receive, User, and Manual tasks. We have discussed work item handlers in Chapter 2, BPM Systems’Structure. User tasks will have work item handlers defined with the key Human Task, Manual tasks with the key Manual Task, Send tasks with the key Send Task, and Receive tasks with the key Receive Task—all configurable from the。

JBPM6学习

JBPM6学习

Eclipse的link方式安装JBPM6插件(JBPM学习之一)1. 首先下载最新的JAVA开发最受欢迎的Eclipse IDE工具,下载地址:/downloads/2. 然后去JBPM社区去下载最新的JBPM6,下载地址:/projects/jbpm/files/3. 下载后的JBPM6包的全称是:“jbpm-6.0.1.Final-installer-full.zip”,将其加压缩。

4. 在JBPM6解压缩包中寻找一个叫“org.drools.updatesite-6.0.1.Final.zip”的文件,应该在这个目录中:\jbpm-6.0.1.Final-installer-full\jbpm-installer\lib,也是一个压缩包。

5. 在Eclipse安装目录中创建一个名为:“eclipse_plugins”的插件目录,里面可以放各种插件。

5. 将“org.drools.updatesite-6.0.1.Final.zip”文件解压缩到刚刚创建好的“eclipse_plugins”目录起名为jbpm6。

6. 然后再Eclipse的安装目录下创建一个名为“links”的文件夹,必须叫这个名称。

7. 在“links”文件夹里面创建一个“jbpm6.link”的文件,然后再该文件中添加一行代码如:“path=D:\\Program Files\\eclipse-jee-kepler-R-win32\\eclipse_plugins\\jbpm6”,这个目录连接的就是你刚刚创建的eclipse的jbpm6插件目录,以后的插件都可以通过这种方案安装。

8. 好,jbpm6插件安装完成,删除Eclipse安装目录“D:\ProgramFiles\eclipse-jee-kepler-R-win32\eclipse\configuration”中的“org.eclipse.update”目录。

9. 重新启动Eclipse开发工具IDE.10. 重启后你会发现Eclipse首选项参数中多了一项:JBPM项,如下图,说明你成功了.安装JBPM6运行环境(JBPM6学习之二)安装Eclipse插件成功后,需要配置JBPM6的运行环境:1. 第一步先将下载的jbpm6目录中的“jbpm-6.0.1.Final-bin.zip”找到,并解压缩到D盘根目录备用。

JBPM安装及请假流程实例

JBPM安装及请假流程实例

1、开发环境搭建必须安装的软件1)5或者更高版本2)支持的数据库有hsqldb、mysql、oracle、postgresql、sybase,本说明以oracle作为数据库;3)GPD插件jbpm在IDE中的流程设计器, eclipse建议版本以上或者myeclipse建议版本以上安装插件所需的zip在解压后\install\src\gpd中的,本说明以为例;配置JBPM运行时1)打开window preferences2)选择JBoss jBPM --> jBPM 4 --> Runtime Locations3)点击Add...4)在Add Location 对话框中,输入一个名字,比如然后点击Search...5)在Browse For Folder 对话框中,选择你的jbpm 根目录,然后点击OK6)点击OK 在Add Location 对话框中定义jBPM 用户库1)点击窗口--> 属性Windows --> Preferences2)选择Java --> 创建路径--> 用户类库Java --> Build Path --> User Libraries3)点击新建New4)类型名字jBPM Libraries5)点击添加JARsAdd JARs...6)找到jBPM 安装程序下的lib 目录7)选择lib 下的所有jar 文件并点击打开Open8)选择jBPM Libraries 作为入口9)重新点击添加JARsAdd JARs10)在jBPM 的安装程序的根目录下选择文件11)点击打开Open12)在下选择源码附件Source attachment作为入口13)点击编辑Edit14)在源码附件的配置Source Attachment Configuration对话框中,点击目录External Folder...15)找到jBPM 安装程序下的src 目录16)点击选择Choose17)点击两次'确定'Ok会关闭所有对话框在目录中添加jPDL4 模式如果你想直接编辑XML 源码, 最好是在你的XML 目录中指定一下模式schema,这样当你在编辑流程源码的时候,可以更好的帮助你编写代码;1)点击窗口--> 属性Windows --> Preferences2)选择XML --> 目录XML --> CataLog3)点击添加Add4)添加XML 目录Add XML Catalog Entry的窗口打开5)点击map-icon 的图标下面的按钮并选择文件系统File System6)在打开的对话框中, 选择jBPM 安装目录下src 文件夹中文件7)点击打开Open并且关闭所有的对话框2、实例教程讲解这节我们将使用建立一个简单请假流程项目建立项目在eclipse中新建一个Dynamic Web Project的项目jbpm4leave;加入jbpm用户库1邮件点击新建的项目jbpm4leave—>Properties 2如下图说示加入用户库加入jbpm所需要的配置文件大家可以从解压后的文件下,在路径\examples\src中找到以下文件,加入到项目工程的src中其中是配置的hibernate配置文件,包括数据源的配置,和一般的配置文件差不多;开头的文件,是用于邮件功能的配置;新建简单的请假流程1新建一个的流程定义文件右键点击src→New→Other,选择JBoss jBPM下的Jbpm 4 Process Definition,文件名写leave,版本号写即可;3用流程设计器打开新建的;右键点击With jBPM jPDL4 Editor,,看见如下效果3设计请假流程在这个简单的请假流程中,包含开始start、结束end、任务task、决策decision四种流程元素; 流程设计如下:4详细设计流程中的各任务节点的流转条件①选中“申请”任务节点,在properties属性中,General标签的Name属性值填为“申请”,Assignment标签的Type选择assignee参与者,选择这个,可以指定该任务节点的直接参与者,Expression的属性值填为{owner}即指定这个任务节点的直接参与者就是这个流程的启动者;②选中“经理审批”任务节点,在properties属性中,General标签的Name属性值填为“经理审批”,Assignment标签的Type选择candidate-groups参与者,选择这个,可以该任务节点有某个用户组来参与,Expression的属性值填为manager即指定这个任务节点的有manager这个用户组来完成;③“老板审批”节点同“经理审批”任务节点设置类似,只是Expression改为boss④设置决策节点,选中,在属性标签General中按如下所示填写:Name节点名称,Expression判断表达式,其中day是在流程流转过程中的一个记录天数的属性,整个表达式的意思是天数大于3天需要老板审批,如果天数不大于3天,经理审批通过后就直接结束流程,不需要老板审批;⑤设计好流程后,点击保存,IDE将自动为你生成一个png的流程图片,切记不可在xml源码界面进行保存,否则会生成不完整的流程图片;⑥在点击下方的“Source”属性,即可看到流程定义文件的xml源码一下是的源码:< xml version=""encoding="UTF-8"><process name="leave"xmlns="jpdl"><start g="198,15,48,48"name="start1"><transition to="申请"/></start><task assignee="{owner}"form=""g="175,94,92,52"name="申请"> <transition to="经理审批"/></task><task candidate-groups="manager"form=""g="176,174,92,52"name="经理审批"><transition g="-32,-8"name="批准"to="exclusive1"/><transition g="120,199;121,122:-42,-18"name="驳回"to="申请"/> </task><decision expr="{day > 3'老板审批' : '结束'}"g="196,259,48,48"name="exclusive1"><transition g="-39,-10"name="结束"to="end1"/><transition g="344,283:-71,-17"name="老板审批"to="老板审批"/> </decision><task candidate-groups="boss"form=""g="299,305,92,52"name="老板审批"><transition g="342,378:"to="end1"/></task><end g="196,354,48,48"name="end1"/></process>至此工程的src文件下就有下面这些文件:发布流程Jbpm的流程发布其实很简单,只要使用jbpm已经封装好的方法进行使用,即可;我们新建一个的页面用户发布流程;在此讲解使用zip文件打包发布流程;1)将之前建立好的和文件,一起打包进文件;2)代码如下:<%page language="java"contentType="text/html; charset=gb2312"%> <%pageimport=""%><DOCTYPE html PUBLIC"-etRepositoryService;try {String file = deployFile;ddResourcesFromZipInputStreamzis.deploy;;;"发布流程成功<br />";"<a href=''>返回</a><br />";} catch Exception e {;"发布流程失败";}}%><script type="text/javascript">function readFileobj {"file".value = ;}</script><font color="red">可直接发布zip文件</font><br/><form name="form1"method="post"action=""><label>发布流程文件<input type="file"name="processDef"onchange="readFilethis"></label><label><input type="submit"name="Submit"value="提交"></label></form></body></html>3)测试发布成功结果4)查看已发布成功的流程已经有的一个查看流程的页面,源码如下:<%page language="java"contentType="text/html; charset=GB18030"pageEncoding="GB18030"%><%include file="/"%><DOCTYPE html PUBLIC"-etRepositoryService;reateProcessDefinitionQuery.list;%><html><head><meta http-equiv="Content-Type"content="text/html; charset=GB18030"> <title>Insert title here</title><style type="text/css">body {font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color: 4f6b72;background: E6EAE9;}a {color: c75f3e;mytable {padding: 0;margin: 0;}caption {padding: 0 0 5px 0;width: 700px;font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica,sans-serif;text-align: right;}th {font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color: 4f6b72;border-right: 1px solid C1DAD7;border-bottom: 1px solid C1DAD7;border-top: 1px solid C1DAD7;letter-spacing: 2px;text-transform: uppercase;text-align: left;padding: 6px 6px 6px 12px;background: CAE8EA;}{border-top: 0;border-left: 0;border-right: 1px solid C1DAD7;background: none;}td {border-right: 1px solid C1DAD7;border-bottom: 1px solid C1DAD7;background: fff;font-size: 11px;padding: 6px 6px 6px 12px;color: 4f6b72;}background: F5FAFA;color: 797268;}{border-left: 1px solid C1DAD7;border-top: 0;background: fff;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; }{border-left: 1px solid C1DAD7;border-top: 0;background: f5fafa;font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color: 797268;}{font-size: 11px;}</style></head><body><TABLE width="100%"id="mytable"id="mytable"><caption>流程定义</caption><thead><tr><th class="spec">流程id</th><th>流程名称</th><th>版本号</th><th>流程删除</th><th>启动流程</th></tr></thead><tbody><%for ProcessDefinition pd : pdList {%><tr><th class="spec"><%=%></th><td class="alt"><%=%></td><td class="alt"><%=%></td><td class="alt"><a href="id=<%=%>">删除流程</a></td><td class="alt"><a href="id=<%=%>">启动流程</a></td> </tr><%}%></tbody></table></body></html>5)查看流程发布情况6)流程定义所设计到的表JBPM4_DEPLOYMENTJBPM4_DEPLOYPROP ,"%><%"UTF-8";"UTF-8";try{etExecutionService;Map map = new HashMap;etParameter"id", map;"";}catch Exception e{;}%>2查看代办任务alue;var reg = /^1-9\d$/;if obj{alert"天数必须为正整数";"day"0.value="";"day"0.focus;return false;}else{0.action="";0.submit;return true;}}</script></body></html>前台显示如下:填写完内容后,页面将会提交到,将对提交的数据进行处理,同时流程继续流转,所以在提交的的页面中要处理两件事情:1、处理用户提交数据,将数据和流程实例进行绑定2、将流程继续流转,提交给下一个节点办理,"%><%page import="."%><%"UTF-8";"UTF-8";%><%ProcessEngine processEngine = ;TaskService taskService = ;String username = String "username";String taskId = "taskId";String owner = "owner";int day = "day";String reason = "reason";String sDBDriver = "";String sConnStr = "jdbc:oracle:thin::1521:orcl";Connection conn = null;PreparedStatement stmt = null;ResultSet rs = null;try{sDBDriver;conn = sConnStr,"scott","scott";false;"%> <%"UTF-8";"UTF-8";ProcessEngine processEngine = ;TaskService taskService = ;String taskId = "id";Task task = taskId;%><DOCTYPE html PUBLIC"-,"%><%page import="."%><%"UTF-8";"UTF-8";ProcessEngine processEngine = ;TaskService taskService = ;String username = String "username";String taskId = "taskId";String result = "result";"%><%ProcessEngine processEngine = ;TaskService taskService = ;String taskId = "id";Task task = taskId;%><DOCTYPE html PUBLIC"-,"%><%page import="."%><%"UTF-8";"UTF-8";ProcessEngine processEngine = ;TaskService taskService = ;String taskId = "taskId";String username = String "username";//操作数据库String sDBDriver = "";String sConnStr = "jdbc:oracle:thin::1521:orcl";Connection conn = null;PreparedStatement stmt = null;ResultSet rs = null;//String sql1 = "UPDATE jbpm4_hist_task task set = where =";//sql1;//username;//taskId;try{sDBDriver;conn = sConnStr,"scott","scott";false;//查询待办事项列表String sql1 = "UPDATE jbpm4_hist_task task set = where =";stmt = sql1;1,username;2,taskId;;;}catch Exception e{;try{;}catch Exception e1{;}}finally{if rs = null {;}if stmt = null {;}if conn = null {;}}taskId;"";%>//操作说明点击“完成”,将结束流程流转;这样就完成了一个简单流程的操作;3、数据库表简要说明的数据库表分成以下几类:1和系统相关:这个只有JBPM4_PROPERTY2和ProcessDefinition相关的表:有:JBPM4_DEPLOYMENT、JBPM4_DEPLOYPROP、JBPM4_LOB 3和开启一个instance相关:有JBPM4_EXECUTION、JBPM4_TASK、JBPM4_JOB、JBPM4_VARIABLE、JBPM4_SWIMLANE、JBPM_PARTICIPATION4和历史相关的表:JBPM4_HIS_ACTINST、JBPM4_HIS_DETAIL、JBPM4_HIS_PROCINST、JBPM4_HIS_TASK、JBPM4_HIS_VAR5和用户/组相关的表有:JBPM4_ID_USER、JBPM4_ID_GROUP、JBPM4_ID_MEMBERSHIP具体数据库的详细数据结果可以参看,随文所附的文件,使用powerdesigner打开;。

2020(BPM业务流程管理)JBBPM精要讲义及培训课件

2020(BPM业务流程管理)JBBPM精要讲义及培训课件

(BPM业务流程管理)JBBPM精要讲义及培训课件JBoss jBPM 3.0下一页JBoss jBPM 3.0Workflow and BPM 实践目录1. 介绍1.1. 综述1.2. The JBoss jBPM 新手工具箱1.3. The JBoss jBPM 流程图形设计器1.4. The JBoss jBPM 核心组件1.5. The JBoss jBPM 控制台web应用1.6. The JBoss jBPM 身份组件1.7. The JBoss jBPM 日程安排程序1.8. The JBoss jBPM 兼容数据库包1.9. The JBoss jBPM BPEL 扩展2. 开始2.1.下载一览2.1.1. jBPM 32.1.1.1. 新手工具箱2.1.1.2. 核心引擎和身份组件2.1.1.3. 数据库扩展2.1.2. jBPM 流程设计器2.1.2.1. Eclipse 更新站点2.1.2.2. Eclipse 特点2.1.3. jBPM BPEL 扩展2.2. The JBoss jBPM 项目目录2.3. 公开CVS访问3. 指南3.1. Hello World 例子3.2. 数据库例子3.3. 上下问(context) 例子: 流程变量3.4. 任务分派例子3.5. 定制动作Action例子4. 面向图的程序设计4.1. 缺少的一环4.2. 图解表示和开发过程4.3. 习惯方法4.4. 什么是面向图的程序设计4.5. 组建块5. 发布5.1. 运行时的相关部分5.1.1. Java运行环境5.1.2. jBPM 库5.1.3. 运行时需要的库5.2. 配置文件5.2.1. jbpm.properties5.2.2. Hibernate cfg xml file5.2.3. 业务日历配置文件5.2.4. 变量映射配置稳健5.2.5. 转换器配置文件5.2.6. 缺省模块配置文件5.2.7. 流程文档解析器配置文件5.3. 在Web应用程序中使用jBPM5.4. 在EJB 包容器中使用jBPM6. 永久化6.1. 永久化API6.2. 数据库配置6.3. 管理事务6.4. jBPM数据库6.4.1. Hibernate集成6.4.2. 开发数据库是hsqldb6.4.3. 其他数据库的支持6.4.4. 高速缓冲存储器6.5. Hibernate 定制7. 流程模型7.1. 综述7.2. 流程图(process Graph)7.3. 节点(Nodes)7.3.1. 节点(Node)职责7.3.2. 节点类型(Nodetype)任务(task-node)7.3.3. 节点类型(Nodetype) 状态(state)7.3.4. 节点类型(Nodetype) 判定(decision)7.3.5. 节点类型(Nodetype) 分叉(fork)7.3.6. 节点类型(Nodetype) 联合(join)7.3.7. 节点类型(Nodetype) 节点(node)7.4. 动作(Actions)7.4.1. 动作配置7.4.2. 动作引用7.4.3. 事件7.4.4. 事件传播7.4.5. Script7.4.6. 定制事件7.5. 超状态(superstate)7.5.1. 超状态变迁7.5.2. 超状态事件7.5.3. 分级名字7.6. 异常处理7.7. 流程组成7.8. 定制节点行为7.9. 图(Graph)执行8. 上下文(Context)8.1. 存取变量8.2. 变量的使用期限8.3. 变量永久化8.4. 变量范围8.4.1. 变量重载( overloading)8.4.2. 变量重写(overriding)8.5. 瞬间变量8.6. 定制变量永久化9. 任务管理9.1. 任务9.2. 任务实例9.2.1. 任务实例生命周期9.2.2. 任务实例及图执行9.3. 委派(Assignment)9.3.1. 委派接口9.3.2. 委派数据模型9.3.3. "推"模型9.3.4. "拉"模型9.4. 泳道(Swimlanes)9.5. 任务事件9.6. 任务定时器9.7. 任务控制器9.8. 定制任务实例9.9. 身份组件9.9.1. 身份模型9.9.2. 赋值表达式9.9.2.1. 第一个术语9.9.2.2. 下一个术语9.9.3. 删除身份组件10. 调度程序10.1. 定时器10.2. 调度程序发布11. 业务日历11.1. 持久时间11.2. 配置12. 记录12.1. 建立日志12.2. 日志检索12.3. 数据仓库13. jBPM 流程定义语言(JPDL)13.1. 流程档案13.1.1. 发布流程档案13.1.2. 流程版本(versioning)13.1.3. 流程转换(conversion)13.2. 代理13.2.1. jBPM类载入器13.2.2. 流程类载入器(class loader)13.2.3. 代理配置13.2.3.1. 配置类型field13.2.3.2. 配置类型bean13.2.3.3. 配置类型constructor13.2.3.4. 配置类型configuration-property13.3. JPDL xml schema13.3.1. process-definition(流程定义)13.3.2. node(节点)13.3.3. common node elements(常见节点元素)13.3.4. start-state(开始状态)13.3.5. end-state(结束状态)13.3.6. state(状态)13.3.7. task-node(任务节点) 13.3.8. process-state(流程状态) 13.3.9. super-state(超状态)13.3.10. fork(交叉)13.3.11. join(联合)13.3.12. decision(判定)13.3.13. event(事件)13.3.14. transition(转换)13.3.15. action(动作)13.3.16. script(脚本)13.3.17. expression(表达式) 13.3.18. variable(变量)13.3.19. handler(处理器)13.3.20. timer(定时器)13.3.21. create-timer(建立定时器) 13.3.22. cancel-timer(放弃定时器) 13.3.23. task(任务)13.3.24. swimlane(泳道)13.3.25. assignment(委派)13.3.26. controller(控制器)13.3.27. sub-process(子流程) 13.3.28. condition(条件)13.3.29. exception-handler(异常处理)14. 安全14.1. 要做的14.2. 验证14.3. 授权15. TDD for workflow15.1. Introducing TDD for workflow15.2. XML sources15.2.1. Parsing a process archive15.2.2. Parsing an xml file15.2.3. Parsing an xml String15.3. Testing sub processes16. 可插入架构下一步Chapter 1. 介绍第一章:介绍前一页后一页第一章:介绍JBoss jBPM 是一个复杂的可扩展的工作流管理系统. JBoss jBPM 有直观的流程语言来表示商业流程图的术语比如,任务,异步通讯的等待状态,定时器,自动操作等等.把这些操作绑在一起,, JBoss jBPM 就有了最强大和易扩展性的控制流机制.JBoss jBPM 只有最小的倚赖性可以很容易的作为java库来使用.当然它也可以用在吞吐量极为关键的J2EE 群应用服务器环境中.JBoss jBPM 可以同任何数据库配置可以部署在任何应用服务器上.1.1. 综述核心工作流和BPM 功能被封状作为一个简单的Java库.这个库包括在jBPM数据库中存储,更新和检索流程信息的服务Figure 1.1. JBoss jBPM 组件一览1.2. JBoss jBPM 新手工具箱新手工具箱是包含了jBPM所有组件包在一个可下载的包里.这个包包括:•jbpm-server , 预先配置的jboss 应用服务器.•jbpm-designer , jBPM流程图形化设计器的eclipse 插件 .•jbpm-db , jBPM 数据库兼容包(参看下面).•jbpm , 核心jbpm组件包括库和本手册.•jbpm-bpel , JBoss jBPM BPEL 扩展参考.预配置的JBoss 应用服务器有下列安装组件:核心jBPM 组件, 打包作为JBoss服务档案•一个包括所有jBPM 表格的完整数据库: 默认的hypersonic 数据库包含所有的jBPM 表格和已经定义的流程.•jBPM 控制台web应用程序这个可以用来为jBPM管理员.•jBPM调度程序所有定时器的执行. 调度程序在新手工具箱里配置成了一个servlet.这个Servlet会为产生一个线程来监视每个定时器的执行.•一个流程例子已经发布进了jBPM 数据库.1.3. JBoss jBPM 图形化流程设计器JBoss jBPM 也包括一个图形化的流程设计工具. 这个设计器是用来创作商业流程的JBoss jBPM 图形设计器是一个Eclipse插件. 独立安装版本的设计器工具已经在开发路线图里了.图形化设计工具最重要的特性是它同时支持业务分析员和技术开发人员. 这样就可以在业务流程建模和实际执行之间平滑转换.插件可用做为本地的update site(Eclipse 纯粹的zip文件),用做符合Eclipse软件更新机制的安装包. 当然你也可以把它展开到你的Eclipse的安装目录. 1.4.JBoss jBPM核心组件JBoss jBPM 核心组件是纯粹的Java(J2SE)软件,来处理流程定义和运行时的流程实例执行.JBoss jBPM 是一个Java库. 因此,它可以用在任何java环境比如web 应用程序,Swing应用程序,EJB,Web Service等等. jBPM 库可以被打包作为sateless session EJB(无状态会话EJB). 这可以用做集群的发布具有极高的吞吐量可伸缩性. 无状态会话EJB根据J2EE 1.3规范重新写过所以可以发布到任何应用服务器上.JBoss jBPM 核心组件被打包成一个简单的Java库文件.依赖你所使用的功能性, 库jbpm-3.0.jar及一些相关的第三方的库比如 . hibernate, dom4j 等等. 这些相关性在第五章发布有清晰的描述永久性方面, jBPM内部使用hibernate. 除了传统的O/R 映射外, hibernate也分析不同数据库系统的SQL方言,这使jBPM在当前所有的数据库上都可以移植.JBoss jBPM API 可以从项目中任意编写的Java软件访问,比如Web应用程序,EJB,或web Service组件,消息bean或其他java组件.1.5. JBoss jBPM控制台web应用程序jBPM 控制台web应用程序是为两个目的服务的.首先,它作为流程执行运行时间任务生成的中央用户接口. 其次, 它也是一个管理和监视控制台允许检查和操作运行中的流程实例.1.6. JBoss jBPM 身份组件JBoss jBPM可以集成进任何包含公司用户和组织信息的目录. 对项目来说从那里得到组织信息组件不是容易得到的, JBoss jBPM就包含这个组件. 身份组件使用的模型比通常的servlet,ejb和门户模型跟富有.更多信息可参考章节9.9, “身份组件”1.7. JBoss jBPM 调度程序JBoss jBPM 调度程序是用来监视和运行已经计划到时执行流程的定时器的组件.定时器组件被打包在核心jbpm库中, 但是它需要被发布到下面的任一环境中: 要不你把调度程序Servlet来产生监视线程或者就必须用独立的JVM来调用调度程序的main方法.1.8. JBoss jBPM 数据库兼容包JBoss jBPM 数据库兼容包包括所有支持数据库的相关信息,JDBC驱动程序和数据库初始化脚本.1.9. JBoss jBPM BPEL扩展JBoss jBPM BPEL扩展是独立的扩展包用来支持BPEL(Business Process Execution Language 商业流程执行语言). BPEL的基本要素是xml Scripting 语言用来写其他web server的web services.前一页Up 后一页JBoss jBPM 3.0 首页第二章:开始第二章开始前一页后一页第二章开始本章将带你如何获得JBoss jBPM的第一步并且提供立即运行的初始提示 .2.1. 下载包一览下面是当前可用的不同jBPM包清单. 这些包中的每一个都包含一个或多个可下载的文件. 同这些文件一起的包含一个描述它的内容及相关安装的指示所有下面下载的描述都可以在the sourceforge jbpm 下载页面.上找到2.1.1. jBPM 3这是主要的发行包,包括了主要核心引擎和数个额外的你使用jBPM的时候可能用得上的包.下载这个包的文件从这里.2.1.1.1. 新手工具箱如果你想尽快开始运行jBPM,那么这就是你想下载的文件.工具箱包含了所有jBPM的模块以及图形化的设计工具在一个单独下载的文件里名字为:'jbpm-starters-kit-<version>.zip'. 展开这个压缩文件到目录下阅读'readme.html' 获取更多信息. 有了这个工具箱,你可以立即开始进入第三章讲座.2.1.1.2. 核心引擎和身份组件下载文件名为 'jbpm-<version>.zip' 包含jBPM 核心引擎也包含角色和组管理的身份组件. 开始工作前, 展开文件到一个目录下,然后'jbpm-<version>'文件夹下找到包含重要的参考信息的'readme.html'文件2.1.1.3. 数据库扩展如果你想改变jBPM的默认数据库( Hypersonic HSQLDB), 你需要下载这个包. 文件名为'jbpm-db-<version>.zip' 包含你改变数据库需要的各种资源. 包含, 数据库建立脚本, hibernate 属性文件及数据库JDBC驱动程序. 如何操作的步骤包含在'readme.html' 文件里,它在你展开这个压缩包的最上层的目录下.2.1.2. jBPM 流程设计器The second package contains the downloads related to the jBPM Graphical Proces Designer. The designer enables you to author your process definitions and to easily deploy them. You can find these downloads here.The designer is a plug-in for the Eclipse platform which is available for download either as a zipped Eclipse feature or as a zippedEclipse update site. There is no difference in content, the only difference is in the way you have to do the installation.2.1.2.1. Eclipse 更新站点If you want to be absolutely sure that the designer installation goes smoothly, we recommend to use the update site mechanism together with a new Eclipse installation. Of cource the Eclipse version should match the downloaded update site archive. To obtain the Process Designer Update Site, you should download the file'jbpm-gpd-site-<version>.zip'. Then follow the instructions in the'readme.html' file included in the archives root folder to succesfully install the GPD.2.1.2.2. Eclipse 特性If you are tired of each time having to do a fresh Eclipse installation and you are willing to cope with some possible issues, you can try the feature download. In this case installation is as easy as extracting the archive into your Eclipse installation (make sure the included 'plugins' and 'features' folders end up in the same location of your Eclipse installation) overwriting the files and folders with the same name that are possibly already present. This installation is very easy, but you could run into incompatibility issues when you overwrite plugins already present inyour installation because of other features that you did install. Though they have the same name it could happen that the versions of these colliding plugins are not equal, hence the possible incompatibilities.Download the file 'jbpm-gpd-feature-<version>.zip' to obtain the GPD feature. The installation instructions are repeated in the 'readme.html' file.2.1.3. jBPM BPEL 扩展第三个也是最后一个包包含jBPM BPEL 扩展. 它只包含一个文件:'jbpm-bpel-<version>.zip'. 你可以找到这个包在这里 .要开始BPEL扩展,在doc目录下找到User's Guide .2.2. JBoss jBPM 项目号码簿•professional support: JBoss is the company that backs this project with professional support, training and consultancy services.•user guide: is the document you're reading and serves as the main entry point into the project.•download descriptions: description of the downloadables•downloads: sourceforge download page for jBPM•forums: get in contact with the community, ask questions and discuss jBPM •wiki: extra information, mostly provided by the community•issue tracker: for submitting bugs and feature requests•roadmap: shows what to expect in the next versions•mailing lists: mailing lists are used for announcements •javadocs: part of the download in the doc/javadoc directory. •cvs: the details of how to get the jBPM sources from CVS 2.3. 公开的CVS访问另外,你可以通过JBoss jBPM cvs服务器得到jBPM服务器的信息如下•Connection type: pserver•User: anonymous•Password:•Host: •Port: 2401 (which is the default)•Repository path: /cvsroot/jbpm•Label: :pserver:anonymous@:/cvsroot/jbpm第三章. 讲座前一页后一页第三章. 讲座这个讲座将展示如何建造一个jpdl和如何使用API的方法来管理运行时的执行. 这个讲座的方式是解释一系列的例子. 每个例子将集中关注特别的主题和额外的说明. 这些例子可以在jBPM包的examples目录下找到.最好的方法就是学着来建立一个Project实验所给的例子.eclipse 用户注意:下载jbpm-3.0-[version].zip并且解压缩到系统. 然后从菜单"File" --> "Import..." --> "Existing Project into Workspace". 点"Next" 然后浏览jBPM 根目录然后点击"Finish". 现在你的有了jbpm 3 project了. 你可以发现这个讲座目录在目录src/java.examples/... . 你打开这些例子后,可以运行它们"Run" --> "Run As..." --> "JUnit Test"jBPM 包括一个图形设计器来产生例子中的XML. 你可以从这里下载和学习有关图形设计器的说明节2.1, “下载一览”3.1. Hello World 例子一个流程是有一个定向图(directed graph)来定义,由节点和变换组成 . hello world 流程有3个节点.如下看如何组合起来, 我们先开始一个简单的流程不使用图形设计器. 下面的图形表示hello world 流程:Figure 3.1. hello world 流程图3.2. 数据库例子jBPM一个基本的特性是当流程处于等待状态时候可以把流程执行永久化到数据库中 . 下一个例子想你展示了如何存储一个流程实例到jBPM数据库中. 例子给出一个将会发生的上下文.分开的方法用来建立不同部分的用户代码. 比如一部分用户代码在web 应用程序中开始一个流程并永久化执行到数据库中.然后,message drive bean从数据库中载入流程实例并继续它的执行jBPM 永久化的更多内容可以参看第六章, 永久化.3.3. 上下文例子: 流程变量在流程执行时候流程变量包含上下文信息. 流程变量同java.util.Map相似映射名字到值,值可能是个java对象 . 流程变量被永久化作为流程实例的一部分. 为了让事情简单,这个例子中我们仅仅展示使用变量的API而没有永久化.关于变量的更多信息可以参看第8章上下文3.4. 任务分派例子在下个例子里我们将要展示你怎么才能分派一个任务给一个用户.因为jBPM工作流引擎和组织模型是分开的,一种用来计算参与者表达语言总是受限的. 因此,你不得不指定AssignmentHandler的实现来计算任务的参与者.3.5. 客户化动作例子动作action是绑定你自己的定制java代码和jBPM流程的一种机制. 动作可以同它自己的节点关联起来(如果它们在流程图表示中相关). 动作也可以放在事件event上比如. taking a transition, leaving a node 或者entering a node.在这个case ,动作不是图表的一部分,但是它们在流程执行产生事件的时候,也会被执行.我们将用一个例子: MyActionHandler 来观察动作的实现.这个动作handler实现不是什么非常特别的事情.它只是设置boolean变量isExecuted为true . 变量isExecuted是静态的因此它可以在action handler内部被访问.关于动作action的内容可以参看7.4节, “动作”我们将要在转换时开始一个动作下一个例子是同样的动作,但动作被分别放在enter-node和leave-node事件 .注意节点同转换相比有超过一个事件类型(event type)转换(transition)只有一个事件.第四章. 面向图的程序设计前一页后一页第四章. 面向图的程序设计当前工作流和业务流程管理(BPM)的总体发展来说是极其零碎的.在一些工具,规范和学术界发现很少的统一意见 .传统方法导致笨重的,单系统把大量的功能包含在一个单一的系统中.Java开发语言中缺少的特性导致在这个范围产生了完整系列的解决方法. 这个文章将标识缺少的特性并且提出一个简单的解决方法让java变成面向图的开发语言.面向图的开发语言可以看作是构造工作流,BPM及流程编排通用构造模块.4.1. 缺少的一环先从比较高层面来看看当前工作流,BPM和流程编排(或协调)领域的解决方法. Figure 4.1. 一览工作流,BPM和流程编排因为现在没有很清晰和被普遍接受的有关工作流,BPM和流程编排(或协调)的定义,我们还是做一些普通的观察工作流是同人们管理任务最接近的. 重点关注工作流指明的由人完成的任务同流程目标的联系.业务流程管理(BPM),指把工作流和企业应用集成(EAI)结合起来 . 一个业务流程指明通过人通过一些软件完成的任务及他们如何互相联系来完成业务流程目标. 流程编排(Orchestration)根据它所处的环境而有显著的不同. 流程编排(Orchestration)语言(像BPEL)是定位于web 服务环境. 流程编排(orchestration)语言是为web服务所用的编程语言. 这就表明你可以由流程编排来为其他web Serverice 编写新的web Service. 流程编排语言有控制流结构作为语言的一部分.其他的基本操作需要调用其他的web services.现在,我们对这三个领域的一般的期望都有了明显的认识. 对流程来说有等待状态是必须具有的能力.这些流程的在等待状态时必须能暂停执行.暂停执行在Java中是不可能的.实际上在Java里暂停和继续一个thread(线程)是可能的(比如用Object.wait()和Object.notify() ).但是由于永久化的原因这同流程的等待状态不是非常匹配.工作流, BPM 和流程编排方法在等待状态时候需要永久化它们的执行.事实上, 在流程流程中状态的改变对应着服务器上的事务..在这些事务之间暂停执行应该被永久化到数据库中或文件系统里.Figure 4.2. Java里缺少的暂停执行的路径.实际上, Java缺少内置的暂停和永久化的机制是没有什么让人惊奇的. 这是因为Java是构造在诺依曼架构上.基本的特征就是顺序执行指令. 这篇文章就是呈现一种扩展诺依曼架构来支持暂停和永久化执行的技术.在这三个领域的产品为了解决上述问题都有从自己的角度来观察的方法, . 作为结果,每一个解决组合暂停执行的方法都包含了所有的可用功能. 这就是让开发社区感到不清楚和混乱的根本原因..4.2. 图形表示和开发流程在我们开始处理暂停执行的解决方法之前有一个方面是什么重要的必须引起重视:流程的图形表示.暂停执行的这个技术能力产生了非常有趣的机会: 两个业务流程之间的直接连结及技术实现. 业务流程是业务分析需求确定中的中心部分. 没有暂停执行的机制, 业务流程的需求实现需要复杂转换成软件设计. 这种情况下,开发者不的不在等待状态保存某些形式的执行状态到数据库中.如此的复杂性会因为业务的功能需求和组合而增加.结论是如果我们找到一个解决用图形表示的业务流程的执行暂停的方法,将会是一件伟大的事情.. 许多(可能是全部) 图形化表示业务流程是基于定向图. 一个流程语言限制成了一个tree,只是定向图的一个子集. 这些语言叫做块结构语言block structured languages .一个重要的考虑结果提议利用迭代开发. 对UML 类图, 这是常见的联系. 分析员可以用UML类图来画分析模型.然后开发人员用这个模型作为设计模型的开始点. 然后在实现中加入更多的技术细节. 太多的建议方案最后都是结束于形成一个可视化的开发环境.4.3. 习惯方法传统方法是指定一个作为结构集合的流程语言.每一个结构有一个图形表示和运行时的行为.下面是一般的回顾常用的方法:•Monolithic systems(单一系统) : 传统工作流,BPM 和流程编排orchestration 方法是打包成一个要求独立环境的单一系统.在大多数情况下,这意味着它们很难在你的应用程序中被使用,因为它们在你自己程序范围的外面.. •Incomplete process language(不完全的流程语言) : 学术研究( ) 指出当前所有标准的方案都有严重的局限,甚至当这个研究范围只是局限在控制流程结构.•No modelling freedom(没有建模自由) : 因为图形化表示有之间有固定的连接及流程结构有固定的运行时行为,分析员失去了自由建模的自由. 结构的绘图包含所有分析员不关心的执行细节.•Visual programming(可视化编程) : 因为在图形化表示之间有固定连接及固定的运行时行为,这总是以某种形式的可视化编程结束, . 根据经验,我知道这是非常消耗时间的编写软件的方式..4.4. 面向图的程序设计或编程是什么?面向图的程序设计是解决执行暂停和永久化的问题的技术..因为它的局限范围,这个技术,是容易理解和作为工作流,BPM和流程编排方法功能的建设模块 .面向图的程序设计中心思想是我们为运行时间的图执行用简单的命令式编程.因此图是软件的一部分并且在运行时间图的执行同解释命令软件紧密偶合的 .流程图是有节点(nodes)和转换(Transitions)组成.转换(Transitions)有方向并且在图中连接两个节点.Figure 4.3. 流程是个定向图图可以看成是一个状态机. 执行模型我们可以解释的比较具体对路径的并发执行有较好的支持.下面的UML类图勾画了流程元素怎么被建模UML类图中.这也展示了流程图可以被表现为数据(data). 流程图数据可以用不同的方式表达:XML,java对象,数据库记录...Figure 4.4. 流程图可以用节点和转换来建模下一个部分对开发人员和技术人员来说是最难于理解的部分.这是因为我们指明的执行模型同众所周知的诺埃曼架构不同.我们定义一个令牌作为执行路线.它是在一个系统内的执行路线.Figure 4.5. 令牌是在一个系统内的执行路线注意流程执行可能包括多个并发的执行路线.我们现在定义一个流程执行作为一个令牌树.令牌在流程图中有个指针指向节点.Figure 4.6. 流程执行可以表示为一个令牌树下面的UML类图展示了令牌树如何建模做为UML类图.同样流程执行也能表示为数据.这实际上是使执行永久化的关键部分.Figure 4.7. 流程执行数据模型现在,我们来解释java的执行如何同图的执行紧密偶合的. 下一个图形展示了节点和转换中的方法在图执行中是相关的.为了计算下一个执行状态,我们用一个改良的GOF设计模式中提到的chain of responsibility 模式版本.Figure 4.8. 图执行是不同的chain of responsibility 模式图中的节点表示等待状态.在等待状态期间, 一个令牌指到节点.在节点每个令牌可以接受信号signal. 信号可以被送到令牌来再继续开始执行,之后等待状态结束了.这将使图执行开始.Figure 4.9. 一个信号触发重新开始图执行信号的效果使令牌离开节点. 在case中节点有多个离开转换In case the node has more then one leaving transition, 离开转换必须作为信号的一部分.转换只是使令牌到目的节点.当令牌到达节点,节点被执行.图中每个被定义类型的节点都有运行时间的行为.每个节点类型对应着节点的子类其行为在excute方法中实现.节点的execute方法有两个责任.第一, 她执行同节点类型一致的一些业务逻辑,比如.发送一个消息, 更新数据库,为一个用户生成任务... 第二个责任是节点的execute方法必须传播图执行.如果节点不传播执行,那么它的行为就是等待状态.她可以传播到达节点的令牌向下到其中的一个离开转换. 或者她可以新建一个令牌然后传播这些向下到离开转换.当所有令牌进入等待状态的时候图执行就结束了. 在这个时候,信号已经全部处理过了并且流程执行全部完成(由令牌树组成)全部进入新的等待状态.此时令牌树可被保持.每个令牌在等待接受另外一个信号.这个模型需要一个重要的精化: 动作(action). 动作是在流程事件中执行的一段java代码. 比如事件是'离开节点leaving a node', '进入节点entering a node'和'取得转换taking a transition'. These 这些都是直接的不能跨越等待状态的事件.图执行模型用动作action来做精化是必须的,因为这允许技术开发人员可以为商业流程增加执行的细节 , 而不必改变由分析员建立的原始图.现在我们小结一下这个模型怎么解决传统工作流,BPM和流程编排的问题.•简单 API + chain of responsibility 模式: 替代单一系统.•节点继承: 提供了根本的流程语言力量.•增加了可见的动作: 给业务分析员建模的自由.•流程开发周期:替代可视化编程.4.5. 构建模块(Building blocks)积木。

JDK6.0+MyEclipse6.5+Tomcat6.0安装与配置图解

JDK6.0+MyEclipse6.5+Tomcat6.0安装与配置图解

JDK6.0+MyEclipse6.5+Tomcat6.0安装与配置图解1安装前的准备1.1下载或拷贝以下安装文件并解压1.2推荐安装顺序:JDK6.0→MyEclipse6.5→Tomcat6.02JDK6.0安装与路径配置2.1JDK6.0安装2.1.1双击JDK6.0安装文件,出现“许可证”窗体,点击“接受”按钮2.1.2出现“自定义安装”窗体,点击“更改”按钮可改变安装路径(不一定非要安装在C盘。

初学者担心出错,选择默认路径即可)2.1.3点击“下一步”,开始安装2.1.4出现“目标文件夹”窗体,点击“更改”,同样可以更改安装路径。

注意:如果上一步采用的是默认安装路径,此处也应该采取默认路径;如果上一步更改安装路径为D:\Program Files\Java\jdk1.6.0_10,此处则应该更改为D:\Program Files\Java\jre6\2.1.5点击“下一步”,继续安装,等待完成,点击“完成”按钮,结束安装。

2.2JDK路径配置2.2.1根据JDK默认安装路径或者自定义安装路径,找到java.exe和javac.exe两个文件所在的路径,复制此路径2.2.2退回桌面,单击“我的电脑”,右键选择“属性”2.2.3在属性窗体点击“高级”选项卡,点击“环境变量”按钮2.2.4在“环境变量”窗体中找到“系统变量”下的“Path”2.2.5双击“Path”,弹出“编辑系统变量”窗体2.2.6按键盘的“Home”键,将光标停在“变量值”文本框的最前面,将刚才拷贝的路径:D:\Program Files\Java\jdk1.6.0_10\bin复制到最前面,并在此路径前面加上英文的点和分号,在此路径后面加上英文的分号,如下所示:2.2.7点击“确定”2.3验证JDK是否安装成功:2.3.1点击桌面“开始”按钮,选择“运行”2.3.2在“运行”窗体输入cmd2.3.3出现DOS界面。

输入java,会出现以下文字2.3.4输入javac,会出现以下文字2.3.5以上两个界面显示正常,说明JDK安装成功!3MyEclipse6.5安装与配置3.1MyEclipse6.5安装3.1.1双击MyEclipse6.5.0GAE3.3.2InstallerA.exe文件,出现MyEclipse6.5安装界面,点击“Next”按钮3.1.2出现安装协议窗体,选择接受协议,然后点击“Next”3.1.3出现更改安装路径的窗体,可更改路径,也可采用默认路径,然后点击“Next”3.1.4出现正式安装前的提示窗体,点击“Install”,等待安装完成3.1.5出现安装完成的窗体,选择“Launch MyEclipse6.5”,点击“Finish”3.1.6出现MyEclipse6.5的标志,等待……3.1.7出现选择工作空间的界面。

JBPM 6 开发者指南 Chapter 7

JBPM 6 开发者指南 Chapter 7

Chapter7.DefiningYourEnvironmentwitht heRuntimeManagerBynow,wehaveseenthetwomaincomponentsofajBPM6runtime,theKIEsessionandtheHuma ntaskservice.Thesecomponentsareprovidedasthebasiccomponentsneededtorunprocessinter actionsbetweenhumansandsystems.Astheresponsibilitiesoftheprocessruntimegrows,conne ctorstoexternalsystemsshouldbeaddedtotransformtheprocessengineintoahighlyconfigurabl eenterpriseintegrationplatform,wherecoordinationbetweendifferentsystemscanbeeasilyma nagedinabusiness-friendlyway. Theentireconfigurationinvolvedincreatingaruntimefortheprocessengine,theHumantaskco mponent,andalltheexternalsystemsconnectorscouldbecomecumbersomeifnotmanagedinas ingleplace.Inthischapter,wewilllearnaboutthe runtimemanager component,whichisdesign edtocreateabridgebetweenallthecomponentsandconfigurationsinvolvedinaprocessexecuti on.Thiscomponentcanbeusedtocreateafullruntimefortheprocessengine.Forthischapter,our goalswillbeasfollows:UnderstandtheroleoftheruntimemanagerinthejBPM6architectureGetfamiliarwiththeavailableruntimemanagersandinterfacesStartextendingtheAPItocreateourowncustomruntimemanagersUnderstandingtheroleoftheruntimemanager Theruntime manager’s mainroleinanapplicationistoprovideanapplication-widepointtoaccess processruntimes(allthenecessaryinterconnectedservicestoexecuteaprocessexecutionwithin aspecificdomain).Thenatureofthoseruntimesandhowmanydifferentruntimescanexistinapart iculardomainisadecisionthateachoftheruntimemanagerimplementationsavailablehastomak e.Bydefault,aruntimewillbecomposedoftwomaincomponents:theKIEsessionwheretheproc essisexecutedandtheHumantaskcomponentwherehumantaskswillbehandled.Botharegroup edandreturnedfromtheruntimemanagerthroughthe RuntimeEngine interface: publicinterfaceRuntimeManager {RuntimeEnginegetRuntimeEngine(Context<?>context);voiddisposeRuntimeEngine(RuntimeEngineengine);StringgetIdentifier();voidclose();}publicinterfaceRuntimeEngine{KieSessiongetKieSession();TaskServicegetTaskService();}Runtimemanagerswillreturnaspecificnumberofruntimeengines,dependingontheirspecificn ature.Thereisasingletonimplementationthatwillreturnasinglesessionforallrequiredruntimesi nanapplication,nomatterhowmanyyouask.Ontheotherhand,thereisaruntimemanagerforeach processinstancethatwillprovideaseparatesessionfor eachprocessinstancestartedintheruntime.Thefollowingdiagramshowshowtheclassesinvolve dintheruntimemanagercomponentinteractwitheachother:Determiningwhattypeofruntimemanagerweshoulduseforourenvironmentisacomplexdecisi onthatinvolvesanequilibriumbetweensynchronizationofoperationsandthenumberofconcurrentcallsthatcanbeperformedbyaBPMenvironmentatthesametime.Wew illtrytoexplaintheadvantagesanddisadvantagesofeachtypeofruntimemanagerasweexplainth em.Regardingthearchitecturaldecisionsonwhichruntimemanagertouse,wewillseeafewconsi derationstohelpusin Chapter10,IntegratingKIEWorkbenchwithExternalSystems. ThenatureoftheKIEsessionswillimpacttheamountofinformationsharedbetweenprocessinsta ncesandhowrecoverablethatinformationwillbebyotherthreadslateron.TheKIEsessionshave amemorygroupcalledworkingmemory,whichgroupsasetofobjectsthatwillbeevaluatedbybus inessrules.Ifyoufeedinformationtothisworkingmemoryfromtheprocessinstanceordecidetofi rerulesduringtheprocessexecution,dependingonthelevelofisolationoftheKIEsession,thewor kingmemorymightcontainobjectsfromasingleprocessinstanceormany. Rulesevaluatethisworkingmemorytofindpatternsbetweendifferentobjects.Dependingonwh atabusinessrulestates,youmightwanttomatchdifferentobjectsthatcomefromdifferentprocess instances,orisolatethemontheinstancelevel/requestlevelofeachprocess.Forthesecases,theru ntimemanagerprovidesdifferentalternativestoaccessaprocessinstanceindifferentsessionenvi ronments.Understandingtheruntimeenvironment Runtimemanagersprovideyouwithastrategytoaccessdifferentlevelsofisolationforyourrunti me,butitdependsonanothercomponenttodefinealltheconfigurationsthatallowtheruntimetor uninaspecificway.Thecomponentthatallowsyoutodefinetheseconfigurationsiscalledthe runtimeenviron ment,whichisagroupingofallthedifferentelementsrequiredfortheprocessruntime.Intherunti meenvironment,youcanconfigureseveralthings:Whetheryourenginewillusepersistence(wewillseepersistenceconfigurationsindetailin Chapter8,ImplementingPersistenceandTransactions)orifitwillruninmemoryonlyTheknowledgedefinitionsyouwilluseintheruntimeThespecificusergroupcallbackobjecttoconnecttheHumantaskcomponenttoauserandgr oupsdatasourceThefollowingcodesectiondefinesthe RuntimeEnvironment interface: publicinterfaceRuntimeEnvironment{KieBasegetKieBase();EnvironmentgetEnvironment();KieSessionConfigurationgetConfiguration();booleanusePersistence();RegisterableItemsFactorygetRegisterableItemsFactory();UserGroupCallback getUserGroupCallback();ClassLoadergetClassLoader();voidclose();}Asyoucansee,therearemethodstoprovideallthedifferentcomponentsinvolvedinprovidingthe necessaryinformationtotheruntimetoruncorrectly,includingtheKIEsessionconfigurationpro perties,classloaders,andruntimeconnectors,whicharedefinedinsidethe registerableitemsfac tory.Thisisexplainedinthenextsection.Registerableitemsfactory Theruntimeenvironmenthasaparticularsubcomponentthattakescareofregisteringallthediffer entconnectorstoexternalsystems.Thissubcomponentiscalled RegisterableItemsFactory,a nditprovidesacontractfortheprocessenginetopopulateitsworkitemhandlersanddifferentliste nertypesforprocessandruleexecutions:publicinterfaceRegisterableItemsFactory{Map<String,WorkItemHandler>getWorkItemHandlers(RuntimeEngineruntime);List<ProcessEventListener>getProcessEventListeners(RuntimeEngineruntime);List<AgendaEventListener>getAgendaEventListeners(RuntimeEngineruntime);List<WorkingMemoryEventListener> getWorkingMemoryEventListeners(RuntimeEngineruntime);}Asyoumighthavenoticedalready,externalconnectorscanbeimplementedinabidirectionalwa y—bothtoexposetheinternalfunctionalityoftheenginetotherestoftheapplicationcomponents andtoconfiguresignalingmethodsfromexternalcomponentsbackintotheengine.Itisbecauseo fthisreasonthatlistenersandworkitemhandlersareprovidedwithareferencetotheruntimeengin e,soyoucanpassitontoyourownconnectorswhenevertheymightneedthem. Definingourruntimeenvironment Anotherthingtonoticeisthatalltheseinterfaces(exceptfor RuntimeManager)definejustgettersf ordifferentcomponentsthattheruntimewillneedatspecificinstancesofrulesandprocessesexec utionpaths.Youcanimplementyourowntoreturnthedifferentimplementationsyouwishasyou seefit.However,the jbpm-runtime-manager projectprovidestwoimplementations:SimpleRu ntimeEnvironment and DefaultRuntimeEnvironment.The SimpleRuntimeEnvironment implementationprovidessettersaswellasgettersforalltheco nfigurationcomponents,orenoughsetterstocreatetheconfigurationcomponentsbasedonsimpl erparameters.The DefaultRuntimeEnvironment instanceextendsthefirstimplementationtoad dthemostusualconfigurationsasadefaulttemplate.Thisdefaultconfigurationwillprovideapers istentenvironmentforsessionstobecreated,withhistorylogsandtheHumantaskcomponentpre configured.Sincepersistencewillbecoveredindetailin Chapter8,ImplementingPersistenceandTransactio ns,wewillsaveitforlateruseandjustfocusonworkingwith SimpleRuntimeEnvironment for now.However,inordertosimplifythecodealittle,wewillnotuseitdirectly,butthroughabuilderclassc alled RuntimeEnvironmentBuilder.Inthefollowingcodesnippet,wecanseehowthisbuildercl asswillletusinitializea RuntimeEnvironment instancereallyfast: SimpleRegisterableItemsFactoryfactory =newSimpleRegisterableItemsFactory();factory.addWorkItemHandler("Hum anTask",MyWIHandler.class);RuntimeEnvironmentenvironment = RuntimeEnvironmentBuilder.Factory.get().newEmptyBuilder().userGroupCallback(userGroupCallback).knowledgeBase(kbase).registerableItemsFactory(factory).get();Asyoucanseeinthepreviouscode,wecanprovideourownimplementationsofdifferentcompon entstoa RuntimeEnvironment instancereallyfastwithoutcreatingmultiplelinesofcodetoinvok eeachofthesettersprovidedbyaspecificimplementation. Youmighthavealsonoticedthe SimpleRegisterableItemsFactory implementationthatweus edtoregisteraworkitemhandlertype(byaclassname)toitscorrespondentkey. WhiletheAPIprovidestwodifferentimplementationsofthe RuntimeEnvironment interface,ital soprovidesseveraldifferentimplementationsorthe RegisterableItemsFactory implementati onthatwecanuseindifferentsituations.Thedifferentimplementationsavailableare:SimpleRegisterableItemsFactory:Thisimplementationdefinestypesettersforworkit emhandlersandlisteners.Whenaruntimeengineasksfortheimplementations,itwilltrytob uildthedifferenthandlers.Itwillcreateeachofthespecifiedtypeslookingforaconstructor witha KieSession parameter,a TaskService parameter,a RuntimeEngine parameter,orno parameteratall.DefaultRegisterableItemsFactory:Thisimplementationextendsthepreviousonetopr ovidedefaultlistenersandworkitemhandlers.Particularly,itwillcreateaHumantaskcomp onentworkitemhandlerandlistenerstotriggerrulesfromprocessesandkeephistorylogsina persistentenvironment.KModuleRegisterableItemsFactory:Thisimplementationextendsthepreviousonetoad danyconfigurationdefinedinthe kmodule.xml fileofaspecific KieModule object.Itisconstr uctedwitha KieContainer referenceandasessionnamefromwhichtoobtainthecorrespon dentmappings.InjectableRegisterableItemsFactory:Thisimplementationextendsthedefaultimpl ementationtodiscoverthedifferentconfigurationcomponentsfromCDIinjection. Nowthatweunderstandhowtheenvironmentforaruntimemanagerisconfigured,andbeforewe startworkingwiththeactual RuntimeEngine implementations,weneedtounderstandhowthelif ecycleoftheruntimeisexpectedtobeexecuted.Runtimelifecyclemanagement Wehavealreadyreviewedtheideabehindtheruntimemanagerandtheruntimeenginetounderstan dtheirpurpose.Theruntimeengineisagroupingofalltherunningconfigurationsconnectedtogeth erthatareprovidedbytheruntimemanager.Wenowneedtounderstandhowthesecomponentsresi deintheserverandatwhattimestheymustbecreatedordiscarded.Firstofall,let’s discusstherunti me manager’slifecycle. Theruntimemanagerusuallybehaveslikeasingletoninanapplication;wejustneedoneinstance ofit.Fromthatoneinstance,wewillconstructoneormanyruntimeengines.So,itisimportantthat evenifwecreatemanydifferentruntimemanagers,theyallbehaveinthesamemanner;otherwise ,wemighthavedifferentbehaviorsdependingonhowmanyruntimemanagerswehave. Inthenextsection,wewillseehowdifferentimplementationsoftheruntimemanagerinterfacepr ovidesolutionsforthisproblem.Whicheverimplementationwechoose,thebehavioragainstthe obtained RuntimeEngine instanceisthesameasexplainedinthefollowingsequencediagram:The RuntimeManager implementationwillreturnaspecificruntimeengine,dependingonthe Run timeManager typeandthe Context parameterwepasstoit:RuntimeManagermanager = ...;RuntimeEngineengine =manager.getRuntimeEngine(EmtpyContext.get());Oncewereceivea RuntimeEngine instance,wewillbeabletointeractwithitssubcomponentsusin gthefollowingoptions:WecanusetheKIEsessiontostartprocesses,firerules,andsendsignals.Thecodeisasfollo ws:engine.getKieSession().startProcess("procId");engine.getKieSession().fi reAllRules();engine.getKieSession().signalEvent("signalX",null);Wecanusethetaskservicetointeractwithhumantasks.Thecodeisasfollows:List<TaskSummary>tasks = engine.getTaskService().getTasksOwned("john","en-UK");LongtaskId = tasks.iterator().next().getId()engine.getTaskService().start(taskId,"jo hn");The RuntimeEngine interfacecouldalsobeextendedtoaddotherinteractionsifnecessaryforapa rticulardomain.Whenwe’re doneusing RuntimeEngine inthecurrenttransactionorthread,welet RuntimeManag er knowwhetheritcantrytofreeresourcesbycallingthe disposeRuntimeEngine method:manager.disposeRuntimeEngine(engine);Oncewedothat,the engine instancewillberenderedunusable.Ifwewanttointeractwiththeproc essesortasks,wewillneedtogetanotherinstanceof RuntimeEngine. Nowthatweunderstandthelifecycleofboththe RuntimeManager and RuntimeEngine instances, wecandiscussthedifferenttypesofruntimemanagersavailableforuseinthejBPM6codebase.ThedifferentimplementationsavailableThe RuntimeManager and RuntimeEngine areinterfacesthatcanbeimplementedinanywayaspe cificdomainrequires.Thereisnocorrectwayofusingtheruntimemanagers,becausethespecifics ofwhatyourorganizationistryingtoaccomplishwilldeterminewhetheraKIEsessionshouldbes haredbetweendifferentprocessesornot.Nevertheless,thejBPM6projectprovidesanumberofi mplementationsforthemostcommonsituations.Dependingonwhichimplementationoftheruntimemanagerweuse,wewillneedtorequesta Run timeEngine instancewithdifferentparameters.Theruntimemanagerprovidesthe getRuntimeE ngine methodtoobtaina RuntimeEngine instanceusinga Context objectasaparameter.This Con text objectwillhavetheresponsibilityofidentifyingtheactualinstanceoftheKIEsessionandot herconfigurationcomponentsforourruntimethatweneedforeachdifferentcontext.Thefollowingimplementationsofthe RuntimeManager interfacearealreadyprovidedinjBPM6:SingletonRuntimeManagerPerProcessInstanceRuntimeManagerPerRequestRuntimeManagerWewilldiscusseachoneindetail,learnhowtheycanbeused,andseethedifferenttypesof Context objectsthatshouldbeusedtoobtainthe RuntimeEngine instancesfromeachoneofthem.SingletonRuntimeManagerThe SingletonRuntimeManager makessureasingleKIESessionisusedforallinteractionswit htheruntimeengine,asshowninthefollowingdiagram:ThejBPM6codebaseprovidesafactorymethodtocreateaSingletonRuntimeManager.Acodes ectionfromthe singleton-runtime-manager projectforthischapterwherethisfactorymethod isbeingusedisshownhere:RuntimeManagermanager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(runtimeEnvironment,"node-identifier");Asyoucansee,itreceivestwoparameters.Thesecondoneisoptional,anditidentifiesaruntimem anageruniquely.Giventhatruntimemanagersshouldbehaveassingletons,thefactorykeepsareg isterof allruntimemanagersuntilthey’reclosedtomakesurethat youcannotinstantiatethesamer untimemanagertwice.The get factorymethodmentionedbeforewillinstantiatea SingletonRuntimeManager object. ThisobjectstoresafilewiththeKIEsessionIDthatshouldbeused.Everytimeanewinstanceof Si ngletonRuntimeManager iscreated,itchecksifthatfileisalreadycreated.ThissessionIDislater onretrievedfromthedatabase,orifpersistenceisnotbeingused,fromanin-memory HashMap.Eachtimearuntimeengineiscreated,areferencetoa TaskService instanceisalsocreated.Sincet he TaskService instanceactsasastatelessservicewithonlythepersistencekeepingstateinforma tion,nodistinctionismadebetweenthedifferentbuilt-inruntimemanagerswhenitcomestocreat ingtheHumantaskcomponent. TheSingletonRuntimeManagerwillrequireacontextparametertoretrievethe RuntimeEngine i nstance.Sincethereisnodistinctionrequiredbetweendifferentenvironments(becausetheyalls harethesameKIEsession),wecanusean EmptyContext instanceornullparameterstoretrievethe runtimeengine:RuntimeEngineengine = manager.getRuntimeEngine(EmptyContext.get());With SingletonRuntimeManager,every RuntimeEngine instancereturnedwillhavethesame KIEsessionobject.Thishasitsownadvantagesanddisadvantages.Ontheonehand,allprocessesthatwillberunningonthesamesessioncaninteractwitheachothert hroughtheruleenginememory,andfeedcombinedruleexecutionswithdata.Thisallowsyoutoh avemanyprocessesinteractingwitheachotheraswellaswithrules,lettingtheprocessesremainsi mpleenough,andcomplexdecisionsbeinghandledbyrules.Also,itallowsforperformancemon itoringrulestobewrittenandexecutedonthesameenvironmentastheprocessesarerunning. Ontheotherhand,havingrulessharinginformationbetweendifferentprocessinstancescanalsol eadtocomplications,particularlyifwewanttowriterulesthattakeintoaccountonlytheobjectsof aspecificprocessinstanceinaBusinessRuletask.Also,whenpersistenceandconcurrentinvocat ionsofprocessinstancesarebeingused,allofthemwillbederivedformthesamesessionthatwillh avetoexecutethemoneatatime.Thiscouldleadtoperformancedegradation.The CDI injectionThejBPM6projectprovidesCDIannotationstodirectlyinjecta SingletonRuntimeManager ins tanceinyourmanagedbeans.Todistinguishitfromothertypesofruntimemanagers,youshouldmarkitwithboththe@javax.inject.Inject annotationandthe@org.kie.internal.runtime .manager.cdi.qualifier.Singleton annotation.Thatway,theCDIinitializationwillknowto injectasingletonruntimemanagerinstancewithouthavingtodeclareitsspecifictype.Itcanmarka RuntimeEnvironment instanceaswell:@Inject@SingletonRuntimeManagermanager;@Inject@SingletonRuntimeEnvironmentenvironment;RememberthatCDIiscalleduponinitialization,soalwaysinjectthemanagerbutnotthe RuntimeEngine instance.PerRequestRuntimeManagerThe PerRequestRuntimeManager doestheoppositeofthesingletoninstance;itcreatesanew KIEsessionthefirsttimearequestismadeinaparticularthread.Eachruntimeenginereturnedfro mthemanagerwillhaveanewKIEsessionforthedurationofthethread,asthefollowingdiagramd epicts:ThejBPM6codebaseprovidesafactorymethodtocreateaPerRequestRuntimeManager.Acode sectionfromthe per-request-runtime-manager projectforthischapterwherethatfactorymeth odisbeingusedisshownhere:RuntimeManagermanager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(runtimeEnvironment,"node-identifier");Asyoucansee,itreceivestwoparameters.Thesecondoneisoptional,anditidentifiesaruntimema nageruniquely,inthesamewayasweexplainedfortheSingletonRuntimeManager.The get factorymethodinstantiatesa PerRequestRuntimeManager object.Thisobjectwillkeepa ThreadLocal referencepointingtotheKIEsessioninoneparticularthread.Ifitisanonpersistentenvironment,thereferencewillbe lostthemomenttheruntimeengineisdisposedof.Thisdoesn’tm akemuchsenseunlessyourunfully-synchronous,automaticprocessesthatwillbecompletedthe momenttheyreturnfromthe startProcess methodinvocation,orinasinglecodeblock. However,ifyouareinapersistentenvironment,allreferencestolong-livedprocessinstanceswil lbekeptinthedatabase,aswellasanyprocessinstancereferencethatiswaitingforaspecificsignal .Inthesecases,thePerRequestRuntimeManagerprovidesthemostisolationregardingexecutio nofprocessesandrules.Allruleswillbefiredwithonlythedatathatispresentintheprocessinstanc eorexplicitlyaddedtotheworkingmemorybeforecallingaprocessrelatedinvocationintheKIE session. ThePerRequestRuntimeManagerwillrequireacontextparametertoretrievetheRuntimeEngine instanceassociatedtoaspecificprocessinstanceID.However,inthesamewaya stheSingletonRuntimeManager,itwillnotconditiontheKIESessiontobeused(inthiscase,itwil lalwaysbeanewone),sowecanusethe EmptyContext instance:RuntimeEngineengine = manager.getRuntimeEngine(EmptyContext.get());ProcessInstancepInst = engine.getKieSession().startProcess("procId");LongprocInstId = pInst.getId();manager.disposeRuntimeEngine(engine);The PerRequestRuntimeManager injectionprovidesenoughisolationofprocessestoguarantee thehighestscalabilitypossible,buttherulesassociatedwiththeprocessexecutioncannottakead vantageofgatheringcross-processinstanceinformation. Informationthatcouldbeusedincrossreferencingcomplexeventsfiredbydifferentprocessinst anceswillnotbeavailable,becauseeverytimeanewKIEsessioniscreated,theworkingmemoryi sinitializedfromscratch.The CDI injectionThejBPM6projectprovidesCDIannotationsforthe PerRequestRuntimeManager injectioninm anagedbeans.Todistinguishitfromothertypesofruntimemanagers,youshouldmarkitwithboth the@javax.inject.Inject annotationandthe@org.kie.internal.runtime.manager.cdi.qualifier.PerRequest annotation.CDIiniti alizationwillinjectaruntimemanagerinstanceperrequestwithouthavingtodeclareitsspecifict ype.Itcanmarka RuntimeEnvironment instanceaswell:@Inject@PerRequestRuntimeManagermanager;@Inject@PerRequestRuntimeEnvironmentenvironment;RememberthatCDIiscalleduponinitialization,soalwaysinjectthemanagerbutnotthe RuntimeEngine instance.TipIfyouuseaPerProcessInstanceorPerRequestRuntimeManager,neverinjectKIEsessionsorHu mantaskserviceobjectsasCDIbeans.Theywillbemanagedbytheruntimemanageranddifferen tKIEsessioninstancesandservicescouldbecreated.Instead,youshouldonlyinjectthemanager andrequestsessionsandservicesfromaspecificruntimeengine.PerProcessInstanceRuntimeManagerThe PerProcessInstanceRuntimeManager takescareofregisteringthespecificKIEsession whereaprocesswascreated.Eachruntimeenginereturnedfromthemanagerwilllateronusethes amesessionthatcreatedaspecificprocessinstance,asshowninthefollowingdiagram:ThejBPM6codebaseprovidesafactorymethodtocreateaPerProcessInstanceRuntimeManage r.Acodesectionfromthe per-process-instance-runtime-manager projectforthischapterwh erethisfactorymethodisbeingusedisshownhere:RuntimeManagermanager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(runtimeEnvironment,"node-identifier");Asyoucansee,itreceivestwoparameters.Thesecondoneisoptional,andidentifiesaruntime manageruniquely,inthesamewayasweexplainedfortheSingletonRuntimeManager.The get factorymethodinstantiatesa PerProcessInstanceRuntimeManager object.Thisobjec twillkeepareferenceofwhichsessionstartedwhichprocessinstance.Ifitisanonpersistentenvir onment,thereferencewillbekeptinaninternal HashMap.Ifitisusespersistence,thereferenceiske ptonaJPA-managedtablecalled ContextMappingInfo aswell,butiscachedinternallytominimi zedatabaseuse.The PerProcessInstanceRuntimeManager willrequireacontextparametertoretrievethe Runt imeEngine instanceassociatedtoaspecificprocessinstanceID.IfwewanttostartusinganewKIEsession,wecanrequestaruntimeenginewithafreshsessionbyusingthe EmptyContext instance. Thisisusuallythepracticetostartanewprocess:RuntimeEngineengine = manager.getRuntimeEngine(EmptyContext.get());ProcessInstancepInst = engine.getKieSession().startProcess("procId");LongprocInstId = pInst.getId();manager.disposeRuntimeEngine(engine);However,ifwewanttoretrievethesamesessionthatstartedapreviousprocessinstance,wecanret rieveitwiththeprocessinstanceIDandthehelpofacontextclasscalled ProcessInstanceIdCont ext:LongprocInstId = ...//processinstanceIDprovidedbycodeRuntimeEngineengine2 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(procInstId));engine2.getKieSession().g etProcessInstance(procInstId);Evenifthe PerProcessInstanceRuntimeManager objectcanreturnanewsessionforeachproces sinstancewemanuallystart,thisisnotmandatory.Thereisnolimitationtothenumberofprocessin stancesaKIEsessioncoulduse.Also,processinstancesstartedbyinternalprocesssignalingands ubprocesseswillendupsharingthesameKIEsession.Nevertheless,eachnewprocessinstancewillregisteranewmappingbetweentheKIEsessionand thenewprocessinstance,whichmeansthatyoucanusethe ProcessInstanceIdContext toretrie vethespecificKIEsession.Also,ifyouwantedtoexplicitlycreateaprocessinstanceinthesamesessionwhereanotheroneres ides,youcouldjustgetthe RuntimeEngine instanceusingtheprocessinstanceIDofthepreviousp rocessinstanceandstartthenewprocessinitssession:RuntimeEngineengine =manager.getRuntimeEngine(EmtpyContext.get());ProcessInstanceinst1 =engine.getKieSession().startProcess("procId");LongoldProcInstId =inst1.getId();manager.disposeRuntimeEngine(engine);RuntimeEnginereuseEngine =manager.getRuntimeEngine(ProcessInstanceIdContext.get(oldProcInstId));Proce ssInstanceinst2 = reuseEngine.getKieSession().startProcess("procId"); Thisallowsforagreatercontroloverwhichprocessinstancesareexecutedineachsession.Wecan haveseveralgroupsofprocessinstancesrunninginparallelinmultipleKIEsessionsthatcanruni nmultiplethreads,whichallowsforbetterperformanceandscalability.Processinstancesinsidet hesamesessioncanshareeventsandruledatabetweeneachother.However,wemustunderstandthatprocessinstancesresidinginadifferentKIEsessionwillnotha vethisdataavailableunlessweexplicitlyshareitthroughourowncode.Wemustexplicitlysearch forKIEsessionsusingprocessinstanceIDs,whichmeansthatwemuststoreotherdetailsassociat edtothemappingwewanttokeepelsewhere.ThePerProcessInstanceRuntimeManagerisacom ponentthatsacrificesalittleofthiseaseofuseinexchangeforbetterperformance(byprovidingth epossibilityofhavingmultiplesessions).The CDI injectionCDIannotationsareprovidedaswellfor PerProcessInstanceRuntimeManager.Todistinguish itfromothertypesofruntimemanagers,youshouldmarkitwithboththe@javax.inject.Inject annotationandthe@org.kie.internal.runtime.manager.cdi.qualifier.PerProcessInstance annotation .CDIinitializationwillinjecta PerProcessInstanceRuntimeManager instancewithouthaving todeclareitsspecifictype.Itcanmarka RuntimeEnvironment instanceaswell:@Inject@PerProcessInstanceRuntimeManagermanager;@Inject@PerProcessInstanceRuntimeEnvironmentenvironment;RememberthatCDIiscalleduponinitialization,soalwaysinjectthemanagerbutnotthe RuntimeEngine instance.TipForthe RuntimeEnvironment injectedinstanceinCDI,youcouldusemultipleannotationsforthe differentruntimemanagertypes.Thefollowingcodeiscompletelyvalidandoftenusedintestcase s:@Produces@Singleton@PerProcessInstance@PerRequestpublicRuntimeEnviornmentcreateEnv() {returnRuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().get();}TheUIconfigurationofruntimemanagers TheKIEWorkbench(whichweexplainedin Chapter4,UnderstandingtheKIEWorkbench),a mongitsfunctionalities,providesaruntimeenvironmentforprocessexecutions.Itusesthepro videdruntimemanagerimplementationstoallowtheusertoconfigurehoweachmoduletheycr eateisgoingtobeexecuted.Inordertodoso,youmustfollowspecificstepstoprovidetheworkbe nchwithallthenecessaryinformation.Youwillhavetoperformthefollowingoperations: ConfigureaKIEsessionforaspecificprojectanddeployitConfigurearuntimemanagertypeforthespecificdeploymentWe’ll provideastep-by-stepguidetobeabletodoso.ConfiguringaKIEsessionforaKIEmodule EveryprovidedinstanceoftheruntimemanagerdependsonaKIEsessionbeingdefinedandtheH umantaskcomponentbeingavailable.TheKIEWorkbenchprovidesarunninginstanceofthetas kservice,buttheKIEsessionrequiresaKIEmoduletobeconfiguredinsideaprojectbeforebeinga vailableforuse.Inthissection,wewillgointodetailaboutdefiningourknowledgebasesandsessi onsinaprojectinsidetheKIEWorkbench.Firstofall,weneedtogotothe ProjectEditor.Y oucanfinditinthe ProjectAuthoring perspective under Authoring,andthennavigatingto T ools|ProjectEditor.There,youwillhaveadrop-down listfromwhereyouwillbeabletoselecttheoption Knowledgebasesandsessions asshowninthef ollowingsessions:Whenyouselectthe Knowledgebasesandsessions option,theprojecteditorcontentswillchang etoshowaseriesofuserfriendlyformcomponentstodefinea kmodule.xml fileinsidetheproject. WewilluseittodefineaKIEbasewiththename kbase1andastatefulKIEsessioncalled ksession 1.Anynamewewanttousewilldo,aswewillonlyusethemasareferencelateron. MakesureyoumarktheKIEbaseasdefaultbyselectingitandclickingonthe MakeDefault button ;forthemoment,let’s leavetherestoftheconfigurationasis.TheKIEsessionmenuistothebottom-rightcorneroftheprojecteditor.Afteryoufinisheditingthe ksession1components(youcanedititspreconfiguredworkitemhand lersandlistenersaswell),youcanclickonthe Build&Deploy buttontomakethedeploymentavail ablefortheruntimeconfigurationcomponents:Oncethe Build&Deploy stageisfinishedandthecompilationissuccessful,wecangoto Deploy|D eployments,becausebydefaulttheKIEWorkbenchwillinitializeaSingletonRuntimeManagerf orthedefaultKIEsessionofthedefaultKIEbaseofeverydeployedproject.Thisisshowninthefoll owingscreenshot:Configuringaruntimemanagertype Wecandeletetheexistingdeploymentunitsbyclickingonthe Delete actionbuttontotherightofeac hrow,orcreatenewonesbyclickingonthe NewDeploymentUnit buttonontheheaderofthetable. Whenweclickonthe NewDeploymentUnit button,apopupwillguideustoselectaspecificreleas eofaproject,aKIEbase,andaKIEsessionfromthatproject,andalsotoselectthetypeofprovidedru ntimemanagerthatwewillusetooperatewiththeKIEsession:Oncewecompleteallthefieldsandclickonthe DeployUnit button,wewillseetheunitdetailsavai lableasanewrowinthedeploymentunitstableasshowninthefollowingscreenshot:Bydefault,theKIEWorkbenchwillallowyoutohaveoneruntimemanagerperKIEsessiondefin。

jBPM6与BPMN2.0(JBPM6系列之一)

jBPM6与BPMN2.0(JBPM6系列之一)

jBPM6与BPMN2.0(JBPM6系列之一)1、何谓BPMN2.0BPMN是Business Process Model and Notation的缩写。

我觉得将其翻译为“业务流程模型及其标注”是比较确切的。

BPMN是OMG (Object Management Group 对象管理组织)所发布的规范之一。

小注:OMG在1989年由11家公司(包括IBM、原Sun、微软、苹果、美国航空等)创立。

OMG最初的目的是开发一个分布式面向对象系统的标准。

而如今OMG拥有800多名成员公司,包括计算机产业和软件产业的企业,也包括其他产业的成员。

OMG所广泛使用的标准包括UML,MOF,XMI,BPMN等。

BPMN的最主要目的就在于“如何进行业务流程的标注,可以使得所有的“业务用户”能够轻松阅读和理解”。

所谓业务用户(Business users)其实包含三种类型的用户:业务分析员、业务开发者以及最终用户。

对于业务流程来说,分析员喜欢创建流程的草图,以此进行演练分析;而开发者则更关心流程在技术上的实现;而最终用户则需要管理和监控这些流程。

BPMN的早期版本(BPMN 1.x)仅仅定义了怎样图形化一个业务流程,而目前的BPMN 2.0不仅仅定义了业务流程的图形化标准,还追加了已定义元素的执行语义和流程定义的XML格式化。

在BPMN 2.0中,这种可执行流程(在这里,所谓可执行流程是指可以使用BPMN 2.0规范完整的描绘出流程图的业务流程。

)是由不同类型的节点(nodes)组成的,且节点之间使用顺序流(sequence flows)进行相互连接。

BPMN 2.0规范抽象了三大类型的节点:Events类型:事件类型的节点用于建模某个特定事件的发生。

BPMN 2.0抽象了三种事件节点:1)开始事件节点(start event):用于表示某个流程的开始;2)结束事件节点(end event):定义了流程的结束或者其子流程的结束;3)中间事件节点(intermediate event):用于表示在某个流程执行期间可能发生的事情。

JBPM工作流

JBPM工作流

JBPM⼯作流⼀.开发环境的搭建1.下载Jbpm4.41.1下载地址:1.2解压后的⽬录2.安装GPD插件(eclipse图形化流程设计器)2.1打开eclipse--------选择help--------选择install new software2.2选择add添加插件:点击Archive选择插件⽬录:插件⽬录所在位置就是下载的解压后的路径中找jbpm-4.4\install\src\gpd2.3选择插件后续直接下⼀步就⾏,等待安装插件。

1.配置运⾏时的环境打开eclipse-------------preference1.配置JPDL xml的schema dtd4.1⽬的有时在建jpdlxml⽂件的时候没有节点的提⽰,我们配置⼀下这个schema dtd,就有提⽰了。

4.2配置步骤打开eclipse-------------preference⼆.JBPM简介2.1什么是jbpmJBPM,全称是Java Business Process Management(业务流程管理),它是覆盖了业务流程管理、、服务协作等领域的⼀个开源的、灵活的、易扩展的可执⾏流程语⾔框架。

2.2为什么⽤jbpm业务分析师和开发⼈员使⽤的是同⼀种语⾔来交谈,⼤⼤降低了开发的风险,如果要开发⼀个项⽬,速度也更快了,因为开发⼈员不⽤再将⽤户需求转化成软件设计了。

其次,JBPM采⽤的不是⼀般的开发⼯具,⽽是⾃⼰的图形化开发⼯具,⾮常⽅便随时了解和掌握运⾏的进程。

最后,JBPM的流程框架⾮常灵活,使⽤起来也⾮常安全,它经过了安全认证,因此可以保证⼀些商业机密不被泄露。

三.开发步骤1.引⼊jar包在jbpm4.4的解压包中根⽬录Jbpm的jar包还有lib⽂件夹中除report-engine,war包外所有jar包注:因为Jbpm4.4是⽤Mysql作为DB的,如果要⽤Oracle作为DB需要引⼊相应的驱动包。

2.创建配置⽂件<?xml version="1.0" encoding="utf-8"?><!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><!-- 连接数据库的⼀些信息 --><property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property><property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property><property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property><property name="ername">jbpm</property><property name="hibernate.connection.password">jbpm</property><property name="hibernate.hbm2ddl.auto">update</property><property name="hibernate.format_sql">true</property><!-- ⼩配置:映射⽂件 --><mapping resource="jbpm.repository.hbm.xml"/><mapping resource="jbpm.execution.hbm.xml"/><mapping resource="jbpm.history.hbm.xml"/><mapping resource="jbpm.task.hbm.xml"/><mapping resource="jbpm.identity.hbm.xml"/></session-factory></hibernate-configuration>3.画流程图新建jpdl.xml⽂件/*** 创建表结构:有18张表*/@Testpublic void createTable(){// 读取配置⽂件new org.hibernate.cfg.Configuration().configure("jbpm.hibernate.cfg.xml").buildSessionFactory(); }18张表的含义:/a757956132/p/4774188.html5.获取⼯作流引擎//获取⼯作流引擎//ProcessEngine processEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();//获取⼯作流引擎ProcessEngine processEngine =Configuration.getProcessEngine();6.部署流程定义//获取⼯作流引擎//ProcessEngine processEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();//获取⼯作流引擎ProcessEngine processEngine =Configuration.getProcessEngine();7.启动流程实例//获取⼯作流引擎//ProcessEngine processEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();//获取⼯作流引擎ProcessEngine processEngine =Configuration.getProcessEngine();8.查询任务@Testpublic void selectMyStack(){//根据指定的⼈员去查看他的任务List<Task> stacks= processEngine.getTaskService().findPersonalTasks("部门经理");System.out.println("经理的任务");for (Task task : stacks) {System.out.println("任务ID:"+task.getId()+"\t任务名称:"+task.getName()+"\t任务的办理⼈:"+task.getAssignee());}}9.查询当前任务所在节点@Testpublic void getActivity(){String name=processEngine.getExecutionService().createProcessInstanceQuery().processInstanceId("jbpm01.10001").uniqueResult().findActiveActivityNames().toString(); System.out.println("当前任务所在节点:"+name);}10.办理任务@Testpublic void saveTask(){processEngine.getTaskService().completeTask("80002");System.out.println("任务办理成功");}流程管理四.流程管理四.4.1部署流程4.2查看所有流程定义的信息@Testpublic void findAll(){List<ProcessDefinition> list = pe.getRepositoryService().createProcessDefinitionQuery().list();for (ProcessDefinition pd : list) {/*** id的格式 name-版本号* name:jbpm.cfg.xml⽂件中根据点的name属性值* key,如果在配置⽂件中指定了,那么就是根据点中的test的值,如果不指定默认是name的值* version版本号,同⼀个名称的第⼀个为1后续的⾃增*/System.out.println("id:"+pd.getId()+"\tname:"+pd.getName()+"\tkey"+pd.getKey()+"\t版本号:"+pd.getVersion()+"\t部署的id:"+pd.getDeploymentId()); }}4.3删除指定id流程信息@Testpublic void deleteByid(){pe.getRepositoryService().deleteDeploymentCascade("100001");System.out.println("删除成功");}4.4删除指定key的所有流程信息@Testpublic void deleteByids(){//01.取出当前key对应的版本信息List<ProcessDefinition> list = pe.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("jbpmtest").list();for (ProcessDefinition pd : list) {pe.getRepositoryService().deleteDeploymentCascade(pd.getDeploymentId());}System.out.println("删除成功");}4.5获取流程图@Testpublic void getImage() throws Exception{String deploymentId="10001";//根据id去查询所有对应的资源名Set<String> resourceNames = pe.getRepositoryService().getResourceNames(deploymentId);for(String item: resourceNames){System.out.println("资源名称:"+item);}InputStream in=pe.getRepositoryService().getResourceAsStream(deploymentId, resouceName);OutputStream os=new FileOutputStream("D:\\1.png");int a=in.read();while (a!=-1) {os.write(a);a=in.read();}in.close();os.close();System.out.println("成功");}4.6部署zip格式的资源public void addZipResource(){InputStream is=this.getClass().getClassLoader().getResourceAsStream("two.zip");ZipInputStream zs=new ZipInputStream(is);String id= pe.getRepositoryService().createDeployment().addResourcesFromZipInputStream(zs).deploy();System.out.println("部署成功:deploymentid:"+id);}4.7找到所有最新版本的流程定义@Testpublic void findNewVersionInfo(){//查询所有List<ProcessDefinition> list = pe.getRepositoryService().createProcessDefinitionQuery()//.orderAsc(ProcessDefinitionQuery.PROPERTY_VERSION).list();Map<String,ProcessDefinition> map=new java.util.HashMap<String,ProcessDefinition>();for (ProcessDefinition item : list) {map.put(item.getKey(),item);}for (ProcessDefinition pd : map.values()) {System.out.println("id:"+pd.getId()+"\tname:"+pd.getName()+"\tkey"+pd.getKey()+"\t版本号:"+pd.getVersion()+"\t部署的id:"+pd.getDeploymentId()); }4.8设置流程变量public void setVariable() {pe.getExecutionService().setVariable("jbpm01.90001", "请假天数", 18);}@Testpublic void getVariable() {Integer days = (Integer) pe.getExecutionService().getVariable("jbpm01.90001", "请假天数");System.out.println(days);}五.JBPM和SSH整合⽬的:整合jBPM的⽬的就是能够通过注⼊的⽅式得到ProcessEngine实例,因为ProcessEngine是jbpm 的核⼼.1.关于jar包在Tomcat/lib⽬录下添加jBPM软件包⾥的下列三个jar包,删掉Tomact/lib下的el-api2.关于配置⽂件修改jbpm.cfg.xml⽂件<?xml version="1.0" encoding="UTF-8"?><jbpm-configuration><import resource="jbpm.default.cfg.xml"/><import resource="jbpm.businesscalendar.cfg.xml"/><!-- Hibernate的事务管理器 --><!-- <import resource="jbpm.tx.hibernate.cfg.xml" /> --><!-- 修改为Spring的事务管理器 --><import resource="jbpm.tx.spring.cfg.xml"/><import resource="jbpm.jpdl.cfg.xml"/><import resource="jbpm.bpmn.cfg.xml"/><import resource="jbpm.identity.cfg.xml"/><!-- Job executor is excluded for running the example test cases. --><!-- To enable timers and messages in production use, this should be included. --><import resource="jbpm.jobexecutor.cfg.xml" />--></jbpm-configuration>修改applicationcontext.xml⽂件<?xml version="1.0" encoding="UTF-8"?><beans xmlns="/schema/beans"xmlns:xsi="/2001/XMLSchema-instance" xmlns:tx="/schema/tx" xmlns:aop="/schema/aop" xmlns:context="/schema/context" xsi:schemaLocation="/schema/beans/schema/beans/spring-beans.xsd/schema/tx/schema/tx/spring-tx.xsd/schema/aop/schema/aop/spring-aop.xsd/schema/context/schema/context/spring-context.xsd"><!-- 扫描包中注解标注的类 --><context:component-scan base-package="cn"></context:component-scan><!-- 1.引⼊jdbc.properties⽂件 --><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location"><value>classpath:jdbc.properties</value></property></bean><!-- 2.配置dataSource c3p0数据源 --><bean id="datasource" class="boPooledDataSource"><!-- 数据库连接信息 --><property name="jdbcUrl" value="${jdbc.url}"></property><property name="driverClass" value="${jdbc.driver}"></property><property name="user" value="${ername}"></property><property name="password" value="${jdbc.password}"></property><!-- 其他配置 --><!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。

JIUYN CEMP 安装操作手册

JIUYN CEMP 安装操作手册

九垠真金JIUYIN CEMP目录1、九垠真金后台管理安装操作 (3)2、服务代理安装操作 (7)3、配送中心中心传输安装操作 (12)4、配送中心自动导出安装操作 (17)5、配送中心自动导入安装操作 (22)6、储金卡中心系统操作 (28)7、分店传输系统安装操作 (32)8、储金卡远程转发系统操作 (37)9、POS前台管理安装操作 (42)10、九垠软件程序卸载 (47)一、九垠真金后台管理安装操作(连锁超市和独立卖场都要安装)1、在九垠安装程序找到BACKAPPCIII文件夹,并打开2、点击“SETUP”,安装后台管理系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入注册窗口,点击“”10、安装系统提示系统成功注册,点击“确定”11、系统安装成功,点击“确定”12、第一次该运程序提示:13、系统提示连接服务器失败要设置点“是”14、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”二、服务代理安装操作(连锁超市和独立卖场都要安装,只在服务器上安装)1、在九垠安装程序找到CJYSERAGENT文件夹,并打开2、点击“SETUP”,安装服务代理系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入注册窗口,点击“”10、安装系统提示系统成功注册,点击“确定”11、安装加密狗驱动,点击“下一步”12、选择安装参数,系统默认,点“下一步”13、系统自动安装,完成后点击“完成”14、系统提示安装成功,点击“确定”15、第一次该运程序提示:16、系统提示连接服务器失败要设置点“是”17、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”三、配送中心中心传输安装操作(只在连锁超市配送服务器安装,独立卖场不用安装)1、在九垠安装程序找到CDOWNLOADCER文件夹,并打开2、点击“SETUP”,安装中心传输系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入注册窗口,点击“”10、安装系统提示系统成功注册,点击“确定”11、系统安装成功,点击“确定”12、第一次运程序提示:13、系统提示连接服务器失败要设置点“是”14、系统进入数据库连接设置,输入需要连接服务器名称和数据库登陆用户及密码,点击“确定”四、配送中心自动导出安装操作(只在连锁超市配送服务器安装,独立卖场不用安装)1、在九垠安装程序找到CAUTOEXPORT文件夹,并打开2、点击“SETUP”,安装自动导出系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入安装向导,不用填写,直接点击“下一步”10、进入安装向导,不用填写,直接点击“下一步”11、进入安装向导,不用填写,直接点击“完成”12、系统提示安装设置成功完成,点击“确定”13、进入注册窗口,点击“”14、安装系统提示系统成功注册,点击“确定”15、系统安装成功,点击“确定”16、、第一次运程序提示:17、系统提示连接服务器失败要设置点“是”18、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”五、配送中心自动导入安装操作(只在连锁超市配送服务器安装,独立卖场不用安装)1、在九垠安装程序找到CAUTOIMPORT文件夹,并打开2、点击“SETUP”,安装自动导入系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入安装向导,不用填写,直接点击“下一步”10、进入安装向导,不用填写,直接点击“下一步”11、进入安装向导,不用填写,直接点击“完成”12、系统提示安装设置成功完成,点击“确定”13、进入注册窗口,点击“”14、安装系统提示系统成功注册,点击“确定”15、第一次运程序提示:16、系统提示连接服务器失败要设置点“是”17、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”六、储金卡中心系统操作(储金卡中心系统只在配送和独立卖场服务器上安装)1、在九垠安装程序找到CICSERVER文件夹,并打开2、点击“SETUP”,安装储金卡中心系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入注册窗口,点击“”10、安装系统提示系统成功注册,点击“确定”11、系统安装成功,点击“确定”12、第一次运程序提示:13、系统提示连接服务器失败要设置点“是”14、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”七、分店传输系统安装操作(只在分店服务器上安装)1、在九垠安装程序找到CREMOTETRANS文件夹,并打开2、点击“SETUP”,安装分店传输系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入安装向导,不用填写,直接点击“下一步”10、进入安装向导,不用填写,直接点击“下一步”11、系统提示安装设置成功完成,点击“确定”12、进入注册窗口,点击“”13、安装系统提示系统成功注册,点击“确定”14、系统安装成功,点击“确定”15、第一次运程序提示:16、系统提示连接服务器失败要设置点“是”17、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”八、储金卡远程转发系统操作储金卡远程转发系统只在分店服务器上安装单店系统和储金卡中心系统装在一起在设置中心通讯IP处输入配送和独立卖场服务器IP1、在九垠安装程序找到CICCLIRNT文件夹,并打开2、点击“SETUP”,安装储金卡远程转发系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、进入注册窗口,点击“”10、安装系统提示系统成功注册,点击“确定”11、系统安装成功,点击“确定”12、第一次运程序提示:13、系统提示连接服务器失败要设置点“是”14、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,并输入中心通讯IP输入总服务器IP点击“确定”九、POS前台管理安装操作手册1、在九垠安装程序找到前台安装文件如:FRONTCLIENTCIII文件夹,并打开2、点击“SETUP”,安装POS前台管理系统3、点击“确定”系统开始安装进程4、系统跳到系统安装许可协议录入界面,每个客户只能用自己的安装协议号5、录入安装协议号,点击“下一步”6、安装系统提示安装路径,选好后点击“”7、系统提示选择程序组,系统默认,点击“继续”8、系统提示安装复制进度9、选择数据库路径,点击“完成”10、系统提示安装设置成功完成11、进入注册窗口,点击“”12、安装系统提示系统成功注册,点击“确定”13、系统弹出前台POS设置文件14、修改分店编号和POS机ID号,保存并关闭15、系统安装成功,点击“确定”16、第一次运程序提示:点击“设置”17、系统进入数据库连接设置,输入需要连接服务器名称和数据库登录用户及密码,点击“确定”(商品服务器连接和储金卡服务器连接都输入本地服务器设置)十、九垠软件程序卸载如需重新安装九垠操作模块就要先卸载原来的安装程序1、打开WINDOWS开始菜单,选择“设置”,再打开“控制面板”,在出现的对话框中选择“添加/删除程序”,出现如图1所示的对话框(WINDOWS2000系统的九垠后台安装程序)图12、在添加/删除程序窗口中选择需要删除的九垠软件程序,点击“”如图1,系统自动进入删除程序如图2,点击“是”图23、系统提示删除共享文件点“全部删除”如图3图34、提示将删除所有不再使用的共享文件点“是”如图4图45、系统提示删除进度。

GCCP6操作快速指南

GCCP6操作快速指南

GCCP6操作快速指南1. 准备工作在开始使用GCCP6之前,请确保您的开发环境满足以下要求:- 安装Java JDK 1.8或以上版本- 安装Maven 3.6或以上版本- 安装Git 2.14或以上版本- 配置好SSH密钥,以便于使用Git进行代码管理2. 创建项目在GCCP6平台上创建项目,请按照以下步骤进行:1. 登录GCCP6平台。

如果您还没有账号,请先注册。

2. 在主页面点击“创建项目”按钮。

3. 填写项目名称、描述和选择项目模板。

4. 选择云服务提供商(如阿里云、腾讯云等)。

5. 配置项目环境,如CPU、内存、存储等。

6. 点击“创建项目”按钮,等待项目创建完成。

3. 开发应用在项目创建完成后,您可以开始开发云原生应用。

以下是基本的开发流程:1. 编写代码:使用您熟悉的编程语言(如Java、Python等)编写应用代码。

2. 构建项目:使用Maven或Gradle等构建工具进行项目构建。

3. 测试应用:在本地环境进行单元测试和集成测试。

4. 打包应用:将应用打包成适合在云端运行的格式,如Docker 镜像。

4. 部署应用将编写和测试好的应用部署到GCCP6平台,请遵循以下步骤:1. 上传镜像:在GCCP6平台的镜像管理中上传打包好的Docker镜像。

2. 创建服务:在GCCP6平台的服务管理中创建一个新的服务。

3. 配置服务:选择刚刚上传的镜像,配置服务所需的CPU、内存、存储等资源。

4. 部署服务:点击“部署”按钮,GCCP6平台将自动创建所需资源并部署应用。

5. 管理应用在应用部署后,您需要对其进行管理和监控,以确保其稳定运行。

以下是管理应用的基本方法:1. 监控应用:在GCCP6平台的监控管理中查看应用的运行状态、CPU使用率、内存使用情况等。

2. 日志管理:在日志管理中查看应用的输出日志,以便于排查问题和定位故障。

3. 更新和扩缩容:根据需求对应用进行更新和扩缩容操作。

6. 清理资源当您完成应用的开发、部署和管理后,请确保清理所有使用的资源,以避免产生不必要的费用。

jbpm与ssh完整示例

jbpm与ssh完整示例

目录说明 (1)流程的定义 (1)流程的发布 (3)流程实例的启动 (7)流程节点的流转 (12)查看流程节点图片 (17)说明Jbpm的开发流程可以按如下几步进行:流程的定义、流程的发布、流程实例的启动、流程节点的流转、查看流程节点图片。

本示例是在spring2.0、hibernate3.2、struts1.2下开发。

如果是其它版本的框架也很容易做程序的迁移。

流程的定义流程的定义建议使用jbpm提供的eclipse下的插件,图形化配置插件安装文件可以到jbpm-starters-kit-3.1.4\jbpm-designer\jbpm-gpd-feature\eclipse下找到,需注意版本。

使用这种方式可以把定义的流程描述的三个文件压缩成zip包,统一的部署到数据库中,方便b/s系统中显示图片当前节点信息。

1插件安装把jbpm-gpd-feature文件夹复制到C:\Program Files\MyEclipse-6.0M1\eclipse \plugins下,注意自己的ecplise路径。

在C:\Program Files\MyEclipse-6.0M1\eclipse\links文件夹下建立jbpm-gpd.lin k文件。

内容如下:path=C:\\Program Files\\MyEclipse-6.0M1\\eclipse\\plugins\\j bpm-gpd-feature。

这样再重新启动eclipse就可以使用流程定义功能了。

2流程的定义在eclipse环境中选择file->new->other下的jboss jbpm->process definition 流程定义。

要在自己的项目文件中先指定文件要创建的文件夹。

这样会产生三个文件:gpd.xml、processdefinition.xml、processimage.jpg。

processdefinition.xml为描述流程定义文件,本例为:<?xml version="1.0" encoding="UTF-8"?><process-definition name="文档测试流程"><start-state name="开始"><transition name="提交张三审批" to="张三审批"></transition> </start-state><task-node name="张三审批"><task name="审批1"><assignment actor-id="张三"/></task><transition name="提交李四审批" to="李四审批"></transition> </task-node><task-node name="李四审批"><task name="审批2"><assignment actor-id="李四"/></task><transition name="提交王五审批" to="王五审批"></transition> </task-node><task-node name="王五审批"><task name="审批3"><assignment actor-id="王五"/></task><transition name="结束流程" to="结束"></transition></task-node><end-state name="结束"></end-state></process-definition>processimage.jpg文件是定义流程产生的图片、gpd.xml文件是图形文件的座标说明。

工作流框架jbpm使用说明书

工作流框架jbpm使用说明书

工作流框架JBPM使用说明书(V1.0)长城计算机软件与系统有限公司目录1引言 (2)1.1简介 (2)1.2使用版本 (2)1.3使用环境 (2)2使用说明 (3)2.1建立数据库 (3)2.2建立项目 (6)2.3建立工作流定义 (6)2.4工作流的发布 (8)2.5工作流中定义的类 (9)1引言1.1简介JBoss JBPM是一个灵活、可扩展的流程语言框架。

JPDL是建立在这个通用框架之上的一个流程语言。

它使用直观的流程语言以图形化的方式来表示业务流程,使用术语任务、异步通讯等待状态、定时器、自动操作等。

为了将这些操作绑定在一起,JPDL提供了强有力的、可扩展的流程控制机制。

JBoss jBPM有一个具有最小的依赖性和尽可能简单易用的java库。

当然它也可以用在吞吐量极为关键的J2EE集群应用服务器环境中。

持久层采用Hibernate实现,理论上说,只要Hibernate支持的数据库JBPM都支持。

1.2使用版本本例中使用的是JBPM-3.2-GA版本,需要JDK 1.4.2及以上版本,下载地址为:/jbossjbpm/jbpm_downloads/,建议下载完整包。

在jbpm安装路径\designer\eclipse中有支持图形化设计的插件,将其加到eclipse中,在eclipse的窗口-首选项中如果有jboss jbpm选项,则安装成功。

1.3使用环境本说明书中用到的软件环境如下:操作系统:Window XP sp3JDK:1.4.2_08IDE:MyEclipse 5.5应用服务器:Weblogic 8.1 Tomcat 5.0数据库:oracle 9i2使用说明该示例演示的是一个公司报销流程。

普通员工可以填写报销单,然后提交主管审批;主管审批可以有三种可能:一是主管可以驳回请求,那么报销人需要重填报销单,或者取消报销操作;二是主管不同意请求,请求直接结束;三是主管同意请求,那又存在两种情况,一是如果报销总费用大于1000的话那么会自动转到老板那里,如果小于1000就直接进入财务处理子流程,老板审批的话有两种可能,一是同意进入财务处理子流程,二是不同意请求直接结束。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

目录1.安装前准备: (1)1.1安装ant (1)1.2安装jdk1.7 (1)2安装jbpm6 (1)3替换成mysql数据库 (2)1.安装前准备:1.1安装ant(1)进入官网:/dist/ant/binaries/ ,下载apache-ant-1.8.0-bin.zip(2)解压到D:/ant (当然其他目录也可以)。

(3)设置如下系统变量:ANT_HOME=d:/ant 。

(4)把%ANT_HOME%/bin 加入到系统变量PATH 中。

1.2安装jdk1.7(1.6版本不可用)(1)下载jdk1.7版本,安装到目录C:\Program Files\Java\jdk1.7.0(2)设置环境变量JA V A_HOME=C:\Program Files\Java\jdk1.7.0;Path=%JA V A_HOME%\bin;%JA V A_HOME%\jre\bin;CLASSPATH=.;%JA V A_HOME%\lib;%JA V A_HOME%\lib\tools.jar2安装jbpm6(1)下载Download jBPM 6.1.0.Final,解压到D盘/project/jbpm/jBPM%206/jbpm-6.1.0.Final/jbpm-6.1.0.Final -installer-full.zip?r=http%3A%2F%%2Fprojects%2Fjbpm%2Ffiles%2FjBPM% 25206%2Fjbpm-6.1.0.Final%2F&ts=1412056239&use_mirror=jaist(2)运行cmd,切换目录到安装目录D:\jbpm-installer,运行ant install.demo命令(3)运行完成会出现build success。

如果build failed,检查环境ant和jdk的环境变量的设置,并且jdk必须采用1.7版本的,1.6版本太低,安装会出现问题。

(4)启动之前使用,netstat -ano|findstr “8080”,查看是否有8080端口被占用,如果占用根据PID,去任务管理器中把该应用给结束进程。

(5)检查端口完,确认无8080端口进程后。

运行ant start.demo,后出现以下画面,表示启动成功。

(6)可以在D:\jbpm-installer\wildfly-8.1.0.Final\standalone\log\server.log文件中查看启动日志,如果启动成功那么在D:\jbpm-installer\wildfly-8.1.0.Final\standalone\deployments目录下会有一个jbpm-console.war.deployed文件,失败则会产生jbpm-console.war.failed文件。

这里需要等待一会。

(7)在浏览器中访问:http://localhost:8080/jbpm-console,出现登录页面使用以下用户名和密码进行登录3替换成mysql数据库(1)假设mysql数据的root用户密码为123456,创建jbpm数据库(2)修改文件D:\jbpm-installer\build.properties# default is H2# H2.version=1.3.168# =h2# =${}.jar#db.driver.download.url=/maven2/com/h2database/h2/${H2. version}/h2-${H2.version}.jar#mysql=mysqldb.driver.module.prefix=com/mysql=${}-connector-java.jardb.driver.download.url=https:///nexus/service/local/repo sitories/central/content/mysql/mysql-connector-java/5.1.18/mysql-connector-j ava-5.1.18.jar(3)修改D:\jbpm-installer目录下所有的standalone-*.xml文件,共有6个。

将6个文件中原文件内容:<datasources><datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"><connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url><driver>h2</driver><security><user-name>sa</user-name><password>sa</password></security></datasource><datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true"><connection-url>jdbc:h2:~/jbpm</connection-url><driver>h2</driver><security><user-name>sa</user-name></security></datasource><drivers><driver name="h2" module="com.h2database.h2"><xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class></driver></drivers></datasources>替换成:<datasources><datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"><connection-url>jdbc:mysql://localhost:3306/jbpm?useUnicode=true&amp;characterEncoding=ut f8</connection-url><driver>mysql</driver><security><user-name>root</user-name><password>123456</password></security></datasource><datasource jndi-name="java:jboss/datasources/jbpmDS" pool-name="MySQLDS" enabled="true" use-java-context="true"><connection-url>jdbc:mysql://localhost:3306/jbpm?useUnicode=true&amp;characterEncodin g=utf8</connection-url><driver>mysql</driver><pool></pool><security><user-name>root</user-name><password>123456</password></security></datasource><drivers><driver name="mysql" module="com.mysql"><xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-c lass></driver></drivers></datasources>(4)讲文件D:\jbpm-installer\db\jbpm-persistence-JPA2.xml中的<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />修改为:<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />(5)如果之前已经启动了应用,则先停掉应用:ant stop.demo(6)清除原先部署的应用:ant clean.demo.noeclipse(7)重新部署应用:ant install.demo.noeclipse(8)再次启动应用:ant start.demo.noeclipse(9)启动是否成功参考上一节,启动成功则表示替换成mysql数据库OK,那么在jbpm数据库中会生成jbpm6所需要的相应的表。

相关文档
最新文档