`

最新JBoss jBPM 3.1 开始指南之三---创建流程和部署流程

    博客分类:
  • JBPM
阅读更多

本文来源于:http://www.qqgb.com/Program/Java/JavaBlog/Program_145684.html

Create your own process

创建流程

We have seen the process that comes with jBPM. Let’s now create a new process. Since the existing process is a web order process, lets create a process for returns of orders. This process will start with the buyer returning the item, then shipping receives the order. After that, the original order can be updated, and the money refunded. The process will then be complete.

我们已经学习了jBPM的流程. 现在, 让我们开始创建一个新的流程. 既然已经存在一个web订单流程, 我们就再创建一个订单回复流程. 这个流程在买家返回”item”时开始, 然后接收订单. 之后原始订单可以更新, 也可以退款. 最后此流程结束.

There are three ways to create a process with JBoss jBPM:

*       Draw the process with the visual process designer

*       Write the process in XML format

*       Dynamically create the process through Java business logic

JBoss jBPM有三种创建流程的方式:

*       用可视化的流程设计器绘制流程

*       用XML格式编写流程

*       通过Java业务逻辑动态地创建流程

For this guide, we will be using the visual process designer. The visual process designer is part of the JBoss IDE plugins to the Eclipse platform. This guide assumes that Eclipse is not currently on the workstation, and so we will download the bundled version of Eclipse with the JBoss IDE plugins. Go to the JBoss IDE download page (http://www.jboss.com/products/jbosside/downloads ), select the most recent GA version, and then select the bundled version of the zip. Unzip this download to your hard drive. There should be an eclipse directory where this was installed, with an eclipse.exe in it.

Use this to start eclipse. A dialog box will come up asking where to setup the workspace (Figure 26).

本指南使用可视化流程设计器来绘制流程. 可视化流程设计器是Eclipse平台的JBoss IDE插件之一. 本指南假设机器上还没有安装Eclipse, 所以我们将下载带JBoss IDE插件的捆绑式Eclipse版本. 打开JBoss IDE下载页http://www.jboss.com/products/jbosside/downloads, 选择最新GA版本(当前稳定的最新版本是JBoss Eclipse IDE1.6.0.GA), 然后选择捆绑式zip版本(windows平台用户选择JBossIDE-1.6.0.GA-Bundle-win32.zip, linux用户选择JBossIDE-1.6.0.GA-Bundle-linux-gtk.tar.gz). 解压zip文件到硬盘. 现在单击eclipse安装目录下的eclipse.exe文件, 出现对话框询问工作区(workspace)所在文件夹, 见图26.  

Figure 26. Workspace Selection dialog.

图26. 工作区选择对话框

This is where the project you create will be stored on the hard drive. Choose your workspace location, and select Ok. The next dialog will be the JBoss IDE welcome dialog (Figure 27).

我们创建的项目将存储在指定的文件夹内. 选择工作区地址, 单击OK. 出现JBoss IDE welcome对话框, 见图27.

Figure 27. JBoss IDE Welcome Dialog

图27. JBoss IDE welcome对话框

We don’t need to convert an existing project, so select Cancel. The main eclipse welcome page is shown (Figure 28).

我们不需要转换(convert)已有的项目, 所以单击Cancel. 出现eclipse欢迎页, 见图28.

Figure 28. Eclipse welcome page

图28. Eclipse 欢迎页.

Select the arrow icon in the upper right for the workbench. This will take us to the workbench view (Figure 29).

选择右上脚的肩头图标, 转到eclipse工作台(workbench)视图, 见图29.

Figure 29. Eclipse workbench view.

图29. Eclipse工作台(workbench)视图.

From here, we will create a process project and a process definition. First, select File, new, other… This will show a dialog with a list of projects to create (Figure 30).

下面, 我们开始创建一个流程项目和一个流程定义. 首先, 选择菜单栏中Fileànewàother, 弹出新建对话框, 见图30.

Figure 30. New project wizard selection page.

图30. 新建项目向导选择页.

Select Process Project under the JBoss jBPM folder and click Next. The new process project dialog is shown (Figure 31).

选择”JBoss jBPM”文件夹下的”Process Project”, 单击Next. 出现新建流程项目(process Project)对话框, 见图31.

Figure 31. New Process Project dialog.

图31. 新建流程项目对话框.

Enter the project name, and select Finish. The workbench view is shown again, now with the jBPMStartersProcess project in the left hand window (Figure 32).

输入项目名称, 此处指定” jBPMStartersProcess”, 选择Finish. 出现工作台视图, 见图32.

Figure 32. Workbench with jBPMStarters process.

图32. jBPMStartersProcess项目的工作台.

There is a process already defined in this project. Under the processes/simple folder, we see processdefinition.xml. We will create a new process definition in this same folder. Right click on the processes/simple folder, and select new, other… The new wizard shows again. This time select process definition under the JBoss jBPM folder (Figure 33). (Note: that the project layout is subject to change, and that the screenshots may not be consistent with these textual instructions).

在这个项目中已有一个定义好的流程, 流程定义文件processdefinition.xml在 processes/simple文件夹下. 现在, 我们在同一文件夹下创建一个新的流程, 右击processes/simple文件夹, 选择Newàother, 出现New对话框. 选择”JBoss jBPM”文件夹下的”Process Definition”. (注意, 不同版本的项目布局可能也不同, 所以截图可能跟本指南中的截图不一致.)

Figure 33. New project wizard dialog with Process Definition selected.

图23. 选择流程定义的新建项目向导对话框

Select Next, and the new process definition dialog shows (Figure 34).

单击Next, 出现创建流程定义对话框, 见图34.

Figure 34. New process definition dialog.

图34. 新建流程定义对话框.

Enter the name of the process (StartersProcess), and select Finish. The workbench shows again with the new process in the left hand navigation. In addition, the visual process designer now shows as well (Figure 35).

输入流程名” StartersProcess”, 单击Finish.

Figure 35. Workbench with visual process designer.

图35. 带可视化流程设计器的工作台

Now that we have created a blank process, we can draw the process out. This process will have:

*       a start state

*       a task node

*       a fork

*       two more task nodes

*       a join

*       an end state

Please see Figure 36 as to how these are laid out.

我们已经创建了一个空流程, 现在我们可以开始绘制流程了. 这个流程有:

*       一个开始状态

*       一个任务节点

*       一个分支(fork)

*       两个任务节点

*       一个连接(join)

*       一个结束状态

添加以上内容, 布局见图36.

Figure 36. Node layout for the new process.

图36. 新流程的节点布局.

Note that as you added the nodes, they automatically showed up in the outline on the right hand window. Now that we have nodes, we can add transitions. Click on the transition button, and draw transitions between the nodes. See Figure 37 for how this should look.

下面我们添加变迁(transition). 单击”transition”按钮, 分别单击开始节点和结束节点, 以此类推, 绘制好变迁之后的流程图见图37.

Figure 37. StartersProcess with transitions.

图37. 绘制完变迁后的StartersProcess

Note that the transitions also show up in the outline on the right hand window as well. From here, we will rename some of the nodes and transitions to make the process more readable. To do this, click on the node and the name will become enterable, or double click and use the dialog to enter the new name. See Figure 38 for the process with the names filled in.

现在, 我们来给某些节点和变迁重命名, 以使流程更具可读性. 单击节点选中它, 再单击一次, 就可以重命名此节点; 或者双击节点, 在弹出的对话框中也可以重命名节点; 或者在屏幕下方的属性(properties)窗口重新指定名称. 重命名之后的流程图见图38.

Figure 38. StartersProcess with the nodes and transitions renamed.

图38. 重命名节点和变迁之后的StartersProcess

The StartersProcess has nodes and transitions, so lets add tasks next. Right click on the Ship Order Return node, and select add task. A task will show in the right hand window under that node (Figure 39).

接下来我们来添加任务. 右击” Ship Order Return”节点, 选择”add task”. 一个task将显示在右边”Outline”窗口, 见图39.

Figure 39. Starters Process with a task added.

图39. 添加了一个task的Starters Process.

To customize this task, right click on the task and select properties. The properties dialog shows up (Figure 40).

右击此task, 选择”properties”, 出现”properties”对话框来定制此task, 见图40.

Figure 40. Task general properties dialog.

图40. task general properties对话框.

The general properties dialog has the name for the task. Enter Send Item as the task name. Click on Controller to add a process variable to this task (Figure 41).

在Name后的文本框中输入” Send Item”, 单击左边窗口的”Controller”, 出现图41所示对话框.

Figure 41. Task controller dialog.

图41. Task controller对话框.

Click Add to add a process variable. Change the name to “tracking number”, and select the read, write and required flags (Figure 42).

单击”Add”按钮, 第一列”name”值改为” tracking number”, 选中” read”,” write”和” required”, 见图42.

Figure 42. Task Controller dialog filled in.

图42. Task Controller对话框.

Click OK to finish defining this task. We will now repeat the process to create the other tasks in the process, and assign process variables to each. Right click on the Receive Return node, and add a task. Right click on the task and select properties. Change the name of the task to Receive Item, and add two process variables: “tracking number” (this time only select the read option), and “received date” with read, write and required selected (Figure 43).

单击”OK”结束定义此task. 现在我们重复刚才的过程创建其他流程task并给每个task指派流程变量. 右击” Receive Return”节点, 选择”Add Task”. 右击刚创建的task, 选择”properties”. Task重命名为” Receive Item”, 添加两个流程变量” tracking number”(只选中read)和” received date”(选中read,write和required), 如图43所示.

Figure 43. Controller dialog for the Receive Return task.

图43. “Receive Return” task的Controller对话框.

Click OK to finish defining this task. Right click on the Update Order node, and add a task. Right click on the task and select properties. Change the name of the task to Send Updated Order, and add the process variable “address” with read, write and required selected (Figure 44).

单击”OK”结束流程定义. 右击” Update Order”节点, 选择”Add Task”. 右击task, 选择” properties”. Task重命名为” Send Updated Order”, 添加流程变量”address”, 选中read,write和required, 如图44所示.

Figure 44. Controller dialog for the Send Updated Order task.

图44. “Send Updated Order”task 的Controller对话框.

Click OK to finish defining this task. Right click on the Return Money node, and add a task. Right click on the task and select properties. Change the name of the task to Update Books, and add the process variable “amount” with read, write and required selected (Figure 45).

单击”OK”完成task定义. 右击”Return Money”节点, 选择”Add Task”. 右击task, 选择”properties”. Task重命名为” Update Books”, 添加流程变量”amount”, 选中read, write和required, 如图45.

Figure 45. Controller dialog for the Update Books task.

图45. “Updated Books” task 的Controller对话框.

Click OK to complete the task. The outline on the right hand side now shows all four tasks (Figure 46).

单击”OK” 完成task. 现在所有task都在屏幕右边的outline窗口显示, 见图46.

Figure 46. StartersProcess with tasks defined.

图46. 定义了task的StartersProcess.

The tasks have been defined, but we still need to define who should do each task. We will do this by first creating swimlanes, then assigning tasks to the swimlanes. Click on Swimlanes at the bottom of the process diagram to view the swimlanes page (Figure 47).

任务(task)已经定义, 接下来我们需要定义每一个任务应由谁来执行. 我们首先来创建甬道(swimlane), 然后指派任务给甬道. 单击流程图下方的”Swimlanes”页签, 工作台中将显示甬道页, 见图47.

Figure 47. Swimlanes dialog.

图47. 甬道(Swimlanes)对话框.

Click Add to create an empty swimlane (Figure 48).

单击”Add”创建一个新甬道, 见图48.

Figure 48. Empty swimlane created.

图48. 一个空甬道被创建.

Enter the name of the swimlane as Shipping, and make the assignment type expression. A box appears for the expression. We will do a very simple assignment to a user that has already been setup. Enter “user(grover)” to assign this swimlane to grover (Figure 49).

输入甬道名字”Shipping”, “Assignment type”选择” Expression”, 出现一个” Expression”文本框. 输入” user(grover)”, 则此甬道指派给了grover, 见图49.

Figure 49. Shipping swimlane defined.

图49. 定义的Shipping甬道.

Click add again, and define a swimlane for Sales that will go to “user(ernie)” (Figure 50).

再单击”Add”, 定义”Sales”甬道并把甬道指派给“user(ernie)”, 见图50.

 

Figure 50. Sales swimlane defined.

图50. 定义的Sales甬道.

Click add again, and define a swimlane for Accounting that will go to “user(bert)” (Figure 51).

再次单击”Add”, 定义” Accounting”甬道并把甬道指派给“user(bert)”, 见图51.

Figure 51. Accounting swimlane defined.

图50. 定义的Accounting甬道.

Now that the swimlanes are defined, tasks can be assigned to the swimlanes. Right click on the Receive Item task and select properties. Select the Assignment link on the left hand side to show the assignment dialog. Select Swimlane as the assignment type, and then choose the Shipping swimlane (Figure 52).

现在甬道定义完毕, task可以指派给甬道了. 右击” Receive Item”任务, 选择” properties”. 单击左边的”Assignment”, “assignment type”选择” Swimlane”, 然后选择” Shipping”甬道, 见图52.

Figure 52. Shipping swimlane chosen for task Receive Item.

图52. 为” Receive Item” task选择” Shipping” 甬道.

Click OK. Right click on the Send Updated Order task and select properties. Select the Assignment link on the left hand side to show the assignment dialog. Select Swimlane as the assignment type, and then choose the Sales swimlane (Figure 53).

单击”OK”. 右击 “Send Updated Order” task, 选择” properties”. 单击左边的”Assignment”, “assignment type”选择” Swimlane”, 然后选择 ”Sales” 甬道, 见图53.

Figure 53. Sales swimlane chosen for task Send Updated Order.

图53. 为” Send Updated Order” task选择” Sales” 甬道.

Click OK. Right click on the Update Books task and select properties. Select the Assignment link on the left hand side to show the assignment dialog. Select Swimlane as the assignment type, and then choose the Accounting swimlane (Figure 54).

单击”OK”. 右击 “Updated Books” task, 选择” properties”. 单击左边的”Assignment”, “assignment type”选择” Swimlane”, 然后选择 ” Accounting” 甬道, 见图54.

Figure 54. Accounting swimlane chosen for task Update Books.

图54. 为” Update Books” task选择” Accounting” 甬道.

Click OK. We have now defined the process by adding nodes and transitions, then adding tasks and swimlanes. Click save to save the process definition. We are now ready to deploy the process definition to JBoss jBPM.

单击”OK”. 现在我们添加了节点和变迁, 也添加了任务和甬道. 单击屏幕左上方工具栏中的”save”按钮保存流程定义. 接下来我们就可以把流程定义部署到JBoss jBPM中了.

 

Deploy your process to JBoss jBPM

把流程部署到JBoss jBPM

首先, 确定jBPM服务器已经运行. 然后单击屏幕下方的”Deployment”, 出现图55中的页面. 确定所有参数跟图55相同. 如果JBoss jBPM运行在其他机器上, Server Name 就不是”localhost”要改成那台机器的IP.

图 55. Deployment页.

单击”Deployment”页中的”Test Connection…” 显示如下图:

单击”Deployment”页中的”Deploy process archive…”, 弹出图56所示对话框.

Figure 56. Deployment Successful dialog.

Now that the process is deployed, let’s use the sample web application to run through the process. Bring up Internet Explorer and go to the following URL: http://localhost:8080/jbpm . Log in as “cookie monster” and there are now two options under Create New Process Execution (Figure 57).

流程已经部署成功, 我们打开IE浏览器, 在地址栏中输入http://localhost:8080/jbpm, 以“cookie monster”身份登录, 现在”Create New Process Execution” 列表中已经有两个选项了, 如图57所示.

Figure 57. Home page showing StartersProcess task.

Click the Send Item task. The process definition we created now shows on the page, along with the process variable we created (Figure 58).

单击” Send Item”. 我们创建的流程定义和流程变量显示在页面中, 见图58.

Figure 58. Task page for StartersProcess showing the tracking number process variable.

From here, you can run through the rest of the process execution.

现在, 你就可以自己继续执行流程了.

Congratulations! In this guide, you have:

*       Downloaded and unzipped the JBoss jBPM Starter Kit

*       Executed the JBoss jBPM engine

*       Interacted with the Websale sample process

*       Managed a process that is being executed

*       Created your own process

*       Deployed your process to JBoss jBPM

Congratulations! 通过本指南, 你已经:

*       下载并解压了JBoss jBPM Starter Kit

*       执行了JBoss jBPM 引擎

*       执行了Websale 示例流程

*       管理了正在执行的流程

分享到:
评论

相关推荐

    jbpm3.1

    通过一个简单的 HelloWorld 流程来介绍如何使用 jBPM 创建和执行流程。 **3.2. 数据库示例** 演示如何设置数据库来支持 jBPM 的持久化需求,包括配置 Hibernate 与数据库的连接。 **3.3. 上下文示例:流程变量** ...

    jboss --JBPM介绍及应用

    JBoss jBPM是一个功能强大的工作流引擎,支持创建和自动化业务流程。本文档通过介绍其基本使用方法和流程设计,为开发者提供了一个全面的入门指南。无论是对于初次接触JBoss jBPM的新手还是有经验的开发者来说,都...

    JBoss jBPM jPDL中文指南

    ### JBoss jBPM jPDL中文指南知识点详解 #### 一、引言 JBoss jBPM(Java Business Process Management)是一个开源的工作流引擎,主要用于实现业务流程管理和任务协调。jPDL(jBPM Process Definition Language)...

    jbpm3.1-uml.rar_jbpm_uml

    描述中提到的"jboss getting start 官方手册"可能是指JBoss BPM平台的入门指南,通常这样的手册会涵盖如何安装、配置和初步使用JBPM,包括创建流程定义、部署流程和服务集成等内容。虽然该手册并未直接提供在压缩包...

    jbpm-3.1.1

    使用jbpm-3.1.1进行开发时,你需要了解如何使用Eclipse或其他IDE集成jbpm,如何创建和部署流程定义,以及如何编写与流程交互的Java应用。此外,熟悉JPA(Java Persistence API)和JTA(Java Transaction API)对于...

    jBPM开发入门指南

    2. **部署流程**:将流程定义打包成.jar或.war文件,部署到jBPM服务器。 3. **启动流程**:通过API或Web服务创建流程实例。 4. **监控流程**:跟踪流程实例的状态,管理任务分配。 5. **结束流程**:完成所有任务...

    jBPM4.3用户指南

    - **最新流程实例**: 如何启动最新的流程实例。 - **指定流程版本**: 如果需要,如何指定启动特定版本的流程实例。 - **使用key**: 通过key启动流程实例的方法。 - **使用变量**: 启动流程实例时传递变量的步骤。 *...

    工作流JBPM中文开发指南

    开发者可以使用JBPM提供的API或工作流设计器来创建和定制这些任务。 在jbpm3.1中文文档.chm中,详细介绍了JBPM的安装与配置过程,包括JBOSS服务器的集成以及数据库的设置。文档还涵盖了如何使用Eclipse等开发工具...

    JBPM 开发指南

    - **create-timer/cancel-timer**: 创建和取消定时器。 - **task**: 代表任务。 - **swimlane**: 用于分配任务的角色或组。 - **assignment**: 任务分配机制。 - **controller**: 控制流程的行为。 - **sub-process*...

    jbpm6.0 入门(很有权威)

    - **过程设计器**:允许用户可视化地创建和修改流程模型。 - **表单建模器**:用于设计用户任务中的表单界面。 - **流程和任务管理**:提供对正在运行的流程实例和任务的监控和管理。 - **业务活动监控**:通过图表...

    jBPM4_3用户指南.pdf

    **3.1 创建一个新的流程文件** - **文件创建:** 指导如何使用GPD创建新的流程文件。 **3.2 编辑流程文件的源码** - **源码编辑:** 介绍如何直接编辑流程文件的源代码。 #### 四、部署业务归档 **4.1 部署流程...

    JBPM4工作流应用开始指南.rar

    41 2.9.5 导入和使用范例 41 2.10 例程:jBPM HelloWorld 43 2.11 小结 45 第3章 使用jBPM图形化流程设计器(GPD)设计流程 46 3.1 创建一个新流程 47 3.2 编辑流程定义源 49 3.3 例程:设计一个“复杂的”业务流程 ...

    JBPM4.4使用简介

    ### JBPM 4.4 使用简介 ...以上步骤完成后,即可开始使用 JBPM 4.4 进行业务流程的设计与实施。对于初学者来说,通过实践一个简单的请假审批流程是一个很好的起点。随着经验的积累,可以逐渐尝试更复杂的应用场景。

    jbpm jpdl 帮助文档pdf版

    - **Web应用**:jBPM控制台Web应用程序的部署和配置指南。 #### 5.5 Enterprise architecture - **企业架构**:如何将jBPM集成到企业级系统中。 - **考虑因素**:安全性、可伸缩性等。 #### 5.6 The jPDL Runtime ...

    jBPM 帮助文档,帮助文档

    jBPM提供了一个图形化过程设计器(GPD),用于帮助开发者直观地创建和编辑业务流程。 - **2.5.1 下载Eclipse** - 用户需要下载Eclipse开发环境。 - **2.5.2 添加更新站点jbpm-gpd-site.zip** - 通过Eclipse的更新...

Global site tag (gtag.js) - Google Analytics