- 浏览: 910617 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
天天来注册:
...
try catch finally 用法 -
tadpole_java:
谢谢你的分享。
二十七、Qt数据库(七)QSqlRelationalTableModel(转) -
359449749tan:
android之EditText文本监听(addTextChangedListener) -
michael_wang:
人过留名 多谢分享
Android NOtification 使用 -
wilsonchen:
wangqi0614 写道这个删除是删除所有的把?能不能值删除 ...
Android的SharedPreferences保存与删除数据简单实例
jBPM是由JBoss开发的工作流和业务流程管理引擎,可以用于创建不同人、不同应用程序、不同服务之间交互的业务流程。jBPM还提供了一个可视化的业务流程设计器。jBPM包含下列组件:运行时引擎(一个POJO库),图形化设计器(一个Eclipse插件),基于Hibernate的持久化,基于JSF的web控制台,BPEL扩展等。
Hello World示例
流程定义是一个可管理的包含了节点和节点间交付件的流程图。Hello World示例流程包含三个节点。为了查看节点间如何相互配合,将不使用任何设计工具来定义一个简单的流程。下图显示了Hello World示例流程的流程图定义:
Hello World示例流程图
public void testHelloWorldProcess() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <start-state>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertSame(processDefinition.getStartState(), token.getNode());
token.signal();
assertSame(processDefinition.getNode("s"), token.getNode());
token.signal();
assertSame(processDefinition.getNode("end"), token.getNode());
}
数据库示例
jBPM基本特性之一是能够在jBPM数据库中持久化执行过程中处于等待状态的流程。数据库示例将展示如何在jBPM数据库中存储一个流程实例。该示例可能涉及到jBPM上下文。为不同的用户代码创建Separate方法。举例来说,webapplication中的一段用户代码开始一个流程并在数据库中持久化。之后,一个消息驱动Bean(MDB)加载该流程实例继续执行流程。
public class HelloWorldDbTest extends TestCase {
static JbpmConfiguration jbpmConfiguration = null;
static {
jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
" <jbpm-context>" +
" <service name='persistence' " +
" factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
" </jbpm-context>" +
" <string name='resource.hibernate.cfg.xml' " +
" value='hibernate.cfg.xml' />" +
" <string name='resource.business.calendar' " +
" value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
" <string name='resource.default.modules' " +
" value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
" <string name='resource.converter' " +
" value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
" <string name='resource.action.types' " +
" value='org/jbpm/graph/action/action.types.xml' />" +
" <string name='resource.node.types' " +
" value='org/jbpm/graph/node/node.types.xml' />" +
" <string name='resource.varmapping' " +
" value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
"</jbpm-configuration>"
);
}
public void setUp() {
jbpmConfiguration.createSchema();
}
public void tearDown() {
jbpmConfiguration.dropSchema();
}
public void testSimplePersistence() {
deployProcessDefinition();
processInstanceIsCreatedWhenUserSubmitsWebappForm();
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
}
public void deployProcessDefinition() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='hello world'>" +
" <start-state name='start'>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
jbpmContext.deployProcessDefinition(processDefinition);
} finally {
jbpmContext.close();
}
}
public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertEquals("start", token.getNode().getName());
token.signal();
assertEquals("s", token.getNode().getName());
jbpmContext.save(processInstance);
} finally {
jbpmContext.close();
}
}
public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
List processInstances = graphSession.findProcessInstances(processDefinition.getId());
ProcessInstance processInstance = (ProcessInstance) processInstances.get(0);
processInstance.signal();
assertTrue(processInstance.hasEnded());
jbpmContext.save(processInstance);
} finally {
jbpmContext.close();
}
}
}
上下文示例:流程变量
流程变量包含了流程执行期间的上下文信息。流程变量类似一个java.util.Map类型的名称/值对,并且是java对象。流程变量是流程实例的组成部分。以免事件复杂化,该示例仅仅演示处理流程变量的API,没有包括持久化处理。
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <start-state>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("amount", new Integer(500));
contextInstance.setVariable("reason", "i met my deadline");
processInstance.signal();
assertEquals(new Integer(500), contextInstance.getVariable("amount"));
assertEquals("i met my deadline", contextInstance.getVariable("reason"));
任务分配示例
任务分配示例演示如何给用户分配任务。因为分离jBPM工作流引擎和组织模型,处理参与者的表现语言始终受到很多限制。因此,你必须实现一个包含处理任务参与者的任务分配器。
public void testTaskAssignment() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='the baby process'>" +
" <start-state>" +
" <transition name='baby cries' to='t' />" +
" </start-state>" +
" <task-node name='t'>" +
" <task name='change nappy'>" +
" <assignment class='org.jbpm.tutorial.taskmgmt.NappyAssignmentHandler' />" +
" </task>" +
" <transition to='end' />" +
" </task-node>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance =
new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
token.signal();
assertSame(processDefinition.getNode("t"), token.getNode());
TaskInstance taskInstance = (TaskInstance)processInstance
.getTaskMgmtInstance()
.getTaskInstances()
.iterator().next();
assertEquals("papa", taskInstance.getActorId() );
taskInstance.end();
assertSame(processDefinition.getNode("end"), token.getNode());
}
Hello World示例
流程定义是一个可管理的包含了节点和节点间交付件的流程图。Hello World示例流程包含三个节点。为了查看节点间如何相互配合,将不使用任何设计工具来定义一个简单的流程。下图显示了Hello World示例流程的流程图定义:
Hello World示例流程图
public void testHelloWorldProcess() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <start-state>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertSame(processDefinition.getStartState(), token.getNode());
token.signal();
assertSame(processDefinition.getNode("s"), token.getNode());
token.signal();
assertSame(processDefinition.getNode("end"), token.getNode());
}
数据库示例
jBPM基本特性之一是能够在jBPM数据库中持久化执行过程中处于等待状态的流程。数据库示例将展示如何在jBPM数据库中存储一个流程实例。该示例可能涉及到jBPM上下文。为不同的用户代码创建Separate方法。举例来说,webapplication中的一段用户代码开始一个流程并在数据库中持久化。之后,一个消息驱动Bean(MDB)加载该流程实例继续执行流程。
public class HelloWorldDbTest extends TestCase {
static JbpmConfiguration jbpmConfiguration = null;
static {
jbpmConfiguration = JbpmConfiguration.parseXmlString(
"<jbpm-configuration>" +
" <jbpm-context>" +
" <service name='persistence' " +
" factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
" </jbpm-context>" +
" <string name='resource.hibernate.cfg.xml' " +
" value='hibernate.cfg.xml' />" +
" <string name='resource.business.calendar' " +
" value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
" <string name='resource.default.modules' " +
" value='org/jbpm/graph/def/jbpm.default.modules.properties' />" +
" <string name='resource.converter' " +
" value='org/jbpm/db/hibernate/jbpm.converter.properties' />" +
" <string name='resource.action.types' " +
" value='org/jbpm/graph/action/action.types.xml' />" +
" <string name='resource.node.types' " +
" value='org/jbpm/graph/node/node.types.xml' />" +
" <string name='resource.varmapping' " +
" value='org/jbpm/context/exe/jbpm.varmapping.xml' />" +
"</jbpm-configuration>"
);
}
public void setUp() {
jbpmConfiguration.createSchema();
}
public void tearDown() {
jbpmConfiguration.dropSchema();
}
public void testSimplePersistence() {
deployProcessDefinition();
processInstanceIsCreatedWhenUserSubmitsWebappForm();
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
}
public void deployProcessDefinition() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='hello world'>" +
" <start-state name='start'>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
jbpmContext.deployProcessDefinition(processDefinition);
} finally {
jbpmContext.close();
}
}
public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
assertEquals("start", token.getNode().getName());
token.signal();
assertEquals("s", token.getNode().getName());
jbpmContext.save(processInstance);
} finally {
jbpmContext.close();
}
}
public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
GraphSession graphSession = jbpmContext.getGraphSession();
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
List processInstances = graphSession.findProcessInstances(processDefinition.getId());
ProcessInstance processInstance = (ProcessInstance) processInstances.get(0);
processInstance.signal();
assertTrue(processInstance.hasEnded());
jbpmContext.save(processInstance);
} finally {
jbpmContext.close();
}
}
}
上下文示例:流程变量
流程变量包含了流程执行期间的上下文信息。流程变量类似一个java.util.Map类型的名称/值对,并且是java对象。流程变量是流程实例的组成部分。以免事件复杂化,该示例仅仅演示处理流程变量的API,没有包括持久化处理。
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition>" +
" <start-state>" +
" <transition to='s' />" +
" </start-state>" +
" <state name='s'>" +
" <transition to='end' />" +
" </state>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("amount", new Integer(500));
contextInstance.setVariable("reason", "i met my deadline");
processInstance.signal();
assertEquals(new Integer(500), contextInstance.getVariable("amount"));
assertEquals("i met my deadline", contextInstance.getVariable("reason"));
任务分配示例
任务分配示例演示如何给用户分配任务。因为分离jBPM工作流引擎和组织模型,处理参与者的表现语言始终受到很多限制。因此,你必须实现一个包含处理任务参与者的任务分配器。
public void testTaskAssignment() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='the baby process'>" +
" <start-state>" +
" <transition name='baby cries' to='t' />" +
" </start-state>" +
" <task-node name='t'>" +
" <task name='change nappy'>" +
" <assignment class='org.jbpm.tutorial.taskmgmt.NappyAssignmentHandler' />" +
" </task>" +
" <transition to='end' />" +
" </task-node>" +
" <end-state name='end' />" +
"</process-definition>"
);
ProcessInstance processInstance =
new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
token.signal();
assertSame(processDefinition.getNode("t"), token.getNode());
TaskInstance taskInstance = (TaskInstance)processInstance
.getTaskMgmtInstance()
.getTaskInstances()
.iterator().next();
assertEquals("papa", taskInstance.getActorId() );
taskInstance.end();
assertSame(processDefinition.getNode("end"), token.getNode());
}
发表评论
-
Tomcat 下配置https
2014-05-13 17:56 609引用 今天按照网上的教程做了一下在Tomcat下配置https ... -
SQL语句的练习
2014-04-18 15:42 833第一题:查询101课程比102课程成绩高的所有学生的学号 ... -
MySql中的常见技术
2014-04-14 23:08 800引用 第一部分:引擎选择 MySQL 存储引擎该如何选择 一、 ... -
SQL语句大全(转链接)
2014-04-12 00:00 917http://www.cnblogs.com/yubinfen ... -
Oracle SID在本机上已经存在,请指定一个不同的SID”的解决办法
2012-08-23 17:36 1323windows 系统: 1、 开始->设置->控制面板-> ... -
HDFS详解
2011-12-06 10:31 2171http://www.cnblogs.com/chinacl ... -
git 远程管理
2011-12-05 23:20 1347Pro Git professional version c ... -
KV存储
2011-12-05 23:07 3561KV-存储 之 Hash算法 http://www.ces ... -
互联网常见Open API文档资源
2011-11-16 15:15 1059所谓的开放API(OpenAPI)是服务型网站常见的一种应用, ... -
Jdk1.6+Tomcat6+Apache2+jk_mod1.2+PHP5+MySql5安装与配置详解
2011-11-06 20:38 977http://jiarry.bokee.com/2375369 ... -
下载mod_jk.so地址
2011-11-06 18:34 1871apache版本与mod_jk.so版本要一致,要是不一致就 ... -
php环境安装视频教程
2011-11-05 18:03 893http://dv.ce.cn/video/2010/12/3 ... -
PHP环境配置:Apach+Tomcat+mysql+php
2011-11-05 15:22 67341》下载需要的软件: Apache : apa ... -
Apache的使用方法
2011-11-05 15:18 23537http://www.heibai.net/book/html ... -
轻松搭建一个Windows SVN服务器
2011-11-04 21:58 799http://www.williamlong.info/arc ... -
SDO的使用
2011-11-04 15:26 992http://www.ibm.com/developerwor ... -
Tomcat安全域设置大全
2011-10-26 10:13 1164安全域是tomcat内置的功能,在org.apache.cat ... -
Tomcat-阀
2011-10-26 10:03 751Tomcat的阀能够对容器接收到的HTTP请求进行预处理.阀可 ... -
主键与外键
2011-10-13 20:08 1065一、什么是主键、外键 ... -
loadRunner的使用教程视频
2011-08-24 16:37 924http://v.youku.com/v_playlist/f ...
相关推荐
jbpm-starters-kit-3.1.2.zip官方...版本里包括一个JBPM流程设计器的Eclipse插件,和一个用JBOSS作为服务器的示例流程等相关文件。解压jbpm-starters-kit-3.1.2.rar到某个特定目录,这里我们首先用到的是包里的JBPM目
JBPM是一个扩展性很强的工作流系统,百分百用JAVA语言开发,持久层采用Hibernate实现,理论上说,只要Hibernate支持的数据库JBPM都支持。同时它还能被部署在任何一款JAVA应用服务器上 JBPM的工程文件,大家可以到...
【Jbpm开发流程实例演示】的PPT主要讲解了如何使用Jbpm进行工作流开发,以下是基于这个主题的详细知识点: 1. **jBPM概述** jBPM是一个开源的工作流平台,它提供了面向图形的编程方式来定义流程,让开发者能够专注...
在深入探讨JBPM及其下载资源之前,我们先来了解一下JBPM的基本概念以及它在工作流管理领域的地位。JBPM(JBoss Business Process Management)是Red Hat公司开发的一款开源业务流程管理(BPM)框架,主要应用于Java...
jBPM是JBoss组织提供的一款灵活且可扩展的工作流管理系统,它拥有直观的流程设计语言,支持图形化表示业务流程,并具备强大的流程控制机制。 在开始使用jBPM之前,你需要搭建相应的开发环境。以下是搭建环境的步骤...
jBPM,全称为Java Business Process Management,是一个开源的工作流管理系统,主要应用于J2EE环境中。自2004年10月18日成为JBoss企业中间件平台的一部分以来,jBPM一直在不断发展,其核心特性是使用了JBoss jBPM ...
建议下载`jbpm-starters-kit-3.1.2`这一版本,其中包含了Eclipse插件的JBPM流程设计器以及基于JBOSS服务器的示例流程等文件。解压缩后,可以将JBPM目录下的工程文件导入Eclipse中进行开发。 ##### 2.2 HelloWorld...
jBPM,全称JBoss Business Process Management,是一个全面的开源框架,专门用于处理业务流程管理、工作流以及服务协作。这个框架以其灵活性和可扩展性著称,允许开发者创建可执行的流程定义,以支持企业的业务流程...
说明,这篇文章说使用的流程实例是,学习《一个JBPM工作流管理示例》文章中的流程而来。原文中的流程实例不是jbpm3.1版本,不能适用于jbpm3.1。本人将其改写,并加入自己的设计和实现。原文地址为...
jbpm是一个强大的业务流程管理(BPM)和工作流引擎,它被广泛应用于协调人员、应用程序和服务之间的业务过程。在本文中,我们将深入探讨为什么选择jbpm,它所提供的功能,以及如何利用它来构建和管理流程。 首先,...
**JBPM** 是一个完全由 Java 语言编写的开源工作流管理系统,以其强大的可扩展性和灵活性而著称。JBPM 的持久化层采用了 Hibernate 技术,这使得它能够支持 Hibernate 所支持的几乎所有类型的数据库。此外,JBPM ...
此实例包括的是一个员工请假审批的流程实例,和流程相关的代码以及相应的测试代码。此流程在Eclipse3.1.2 ,JBoss-IDE 1.6环境...说明,这篇文章说使用的流程实例是,学习《一个JBPM工作流管理示例》文章中的流程而来。