前面我有一篇《JBPM源码解读之:Fork》,大致分析了JBPM对于Fork的实现方式,其实Fork和Join是不可分割的一对,Fork实现分拆,Join实现汇集。先让我们看一下《JBPM 3.2.3 User Guide》中关于Join的描述: The default join assumes that all tokens that arrive in the join are children of the same parent. This situation is created when using the fork as mentioned above and when all tokens created by a fork arrive in the same join. A join will end every token that enters the join. Then the join will examine the parent-child relation of the token that enters the join. When all sibling tokens have arrived in the join, the parent token will be propagated over the (unique!) leaving transition. When there are still sibling tokens active, the join will behave as a wait state. 下面就让我们从JBPM源码的角度分析一下Join是如何关闭每一个到达它的Token,是如何检查各个子Token与父Token的父子关系,又是如何重新激活父Token实现流程的继续流转,更重要的也是我写这篇文章的原因:我们如何能从Join默认的实现方式中得到启发,让我们能够更好的理解JBPM整个运转流程,更好的驾驭整个项目。
我们来看Join类的成员变量:
1/** *//** 2 * specifies wether what type of hibernate lock should be acquired. null 3 * value defaults to LockMode.Force 4*/ 5 String parentLockMode; 6 7/** *//** 8 * specifies if this joinhandler is a discriminator. a descriminator 9 * reactivates the parent when the first concurrent token enters the join. 10 * 注: 11*/ 12boolean isDiscriminator =false; 13 14/** *//** 15 * a fixed set of concurrent tokens. 16*/ 17 Collection tokenNames =null; 18 19/** *//** 20 * a script that calculates concurrent tokens at runtime. 21*/ 22 Script script =null; 23 24/** *//** 25 * reactivate the parent if the n-th token arrives in the join. 26*/ 27int nOutOfM =-1;
1// the token arrived in the join and can only reactivate 2// the parent once 3 token.setAbleToReactivateParent(false); 4 总感觉这句是多余的,因为好像一个子Token只有一次机会进入Join节点,然后他的生命周期也就结束了,再者在execute方法的后面有 5 Iterator iter = parentToken.getChildren().values().iterator(); 6while (iter.hasNext()) { 7 ((Token) iter.next()).setAbleToReactivateParent(false); 8 } 9 略去关于处理Hibernate锁机制的代码,因为它并不直接影响这个流程的运作. 10 11boolean reactivateParent =true; 12 13// if this is a discriminator 14if (isDiscriminator) { 15// reactivate the parent when the first token arrives in the 16// join. this must be the first token arriving because 17// otherwise 18// the isAbleToReactivateParent() of this token should have 19// been false 20// above. 21 reactivateParent =true; 22 23// if a fixed set of tokenNames is specified at design 24// time 25 }elseif (tokenNames !=null) { 26// check reactivation on the basis of those tokenNames 27 reactivateParent = mustParentBeReactivated(parentToken, tokenNames.iterator()); 28 29// if a script is specified 30 }elseif (script !=null) { 31 32// check if the script returns a collection or a boolean 33 Object result =null; 34try{ 35 result = script.eval(token); 36 }catch (Exception e) { 37this.raiseException(e, executionContext); 38 } 39// if the result is a collection 40if (result instanceof Collection) { 41// it must be a collection of tokenNames 42 Collection runtimeTokenNames = (Collection) result; 43 reactivateParent = mustParentBeReactivated(parentToken, runtimeTokenNames.iterator()); 44 45// if it's a boolean 46 }elseif (result instanceof Boolean) { 47// the boolean specifies if the parent needs to be 48// reactivated 49 reactivateParent = ((Boolean) result).booleanValue(); 50 } 51 52// if a nOutOfM is specified 53 }elseif (nOutOfM !=-1) { 54 55int n =0; 56// wheck how many tokens already arrived in the join 57 Iterator iter = parentToken.getChildren().values().iterator(); 58while (iter.hasNext()) { 59 Token concurrentToken = (Token) iter.next(); 60if (this.equals(concurrentToken.getNode())) { 61 n++; 62 } 63 } 64if (n < nOutOfM) { 65 reactivateParent =false; 66 } 67 68// if no configuration is specified.. 69 }else{ 70// the default behaviour is to check all concurrent tokens 71// and reactivate 72// the parent if the last token arrives in the join 73 reactivateParent = mustParentBeReactivated(parentToken, parentToken.getChildren().keySet().iterator()); 74 } 75 76// if the parent token needs to be reactivated from this join 77// node 78if (reactivateParent) { 79 80// write to all child tokens that the parent is already 81// reactivated 82 Iterator iter = parentToken.getChildren().values().iterator(); 83while (iter.hasNext()) { 84 ((Token) iter.next()).setAbleToReactivateParent(false); 85 } 86 87// write to all child tokens that the parent is already 88// reactivated 89 ExecutionContext parentContext =new ExecutionContext(parentToken); 90 leave(parentContext); 91 } 92
相关推荐
jbpm jbpm4.3.jar DDDDDDDD
标题 "jbpm源码阅读之一" 提到的是对jbpm(Java Business Process Management)源代码的初步探索。jbpm是一个开源的工作流管理系统,它提供了一套完整的框架来处理业务流程,包括流程定义、执行和监控。这篇博客文章...
这个项目的源码提供了深入理解jbpm工作原理的机会,同时也是学习和开发基于jbpm应用的基础。 jbpm的核心功能包括: 1. **流程建模**:jbpm支持BPMN 2.0标准,这是一种用于描述业务流程的图形化语言,允许开发者...
jBPM源码分析jBPM源码分析jBPM源码分析jBPM源码分析
JBPM数据库表说明 2 1 流程配置类数据库表: 2 1.1 JBPM_PROCESSDEFINITION:流程模版表 2 1.2 JBPM_NODE:流程节点表 2 1.3 JBPM_TRANSITION:流程迁移表 3 1.4 JBPM_ACTION:流程动作表 4 1.5 JBPM_EVENT:...
本文主要探讨的是如何将jBPM(一个开源的工作流管理系统)集成到Tomcat应用服务器,并连接MySQL数据库进行数据存储。jBPM是一个强大的业务流程管理(BPM)和工作流系统,它提供了完整的工具集来设计、部署和执行业务...
**JBPM4.0源码解析与分析** JBPM(JBoss Business Process Management)是一款开源的工作流管理系统,它提供了一套完整的业务流程管理解决方案。在JBPM4.0版本中,系统的核心是Process Virtual Machine(PVM)和Job...
3个JBPM的经典电子教程: jBPM4.1中文用户手册.pdf jBPM详解_工作流管理系统.doc 深入浅出_jBPM_电子书.doc 以及一个JBPM的HelloWorld的例子
【JBPM源码包详解】 JBPM,全称Java Business Process Management,是一个开源的工作流管理系统,主要用于业务流程的建模、执行和管理。它提供了一套完整的框架,使得开发者能够轻松地实现工作流驱动的应用程序。这...
通过jbpm源码分析jbpm引擎内核工作原理
**JBPM数据库表说明** JBPM(Java Business Process Management)是一个开源的工作流管理系统,它用于设计、执行和管理业务流程。在JBPM中,数据库扮演着至关重要的角色,存储了流程定义、执行实例、任务信息等多种...
### JBPM源码分析 #### 一、概述 JBPM是一个开源的工作流引擎,它提供了创建、管理和执行业务流程的功能。本文将深入分析JBPM的源码,特别是针对`org.jbpm`包下的几个核心模块,包括但不限于`org.jbpm.bytes`、`...
【jbpm开发实例源码】是一个关于jbpm的实践项目,旨在帮助开发者深入理解并掌握jbpm的工作流引擎。jbpm(Java Business Process Management)是一个开源的企业级工作流管理系统,它提供了一整套用于设计、执行、管理...
通过深入研究jbpm4的源码,可以了解其内部实现原理,学习如何构建高效、灵活的流程管理系统,同时也能提升Java编程、企业服务集成等方面的技术能力。对于想要从事企业级工作流管理开发的工程师来说,理解jbpm4源码是...
标题中的"JBPM4.4所需要的包.rar"表明这是一个与JBPM 4.4版本相关的压缩文件,包含了一些必要的库和组件。JBPM(Java Business Process Management)是一个开源的工作流和业务流程管理系统,用于设计、执行和管理...
**jbpm4.4项目测试源码解析** jbpm4.4是一款基于Java的企业级工作流管理系统,由JBoss公司开发。它提供了强大的业务流程管理(BPM)和工作流服务,帮助企业构建灵活且可扩展的流程应用。本源码下载主要针对jbpm4.4...
**jbpm数据库表说明** jbpm(Java Business Process Management)是一个开源的工作流管理系统,它用于设计、执行和管理业务流程。在jbpm中,数据库扮演着至关重要的角色,存储了流程实例、任务、变量等核心信息。...
### jBPM 电子书知识点总结 #### jBPM简介 jBPM是JBoss旗下的一个开源工作...总之,jBPM提供了一整套全面的工作流解决方案,从图形化设计到实际部署,覆盖了业务流程管理的各个阶段,是IT项目中不可或缺的工具之一。
总之,通过深入研究jbpm3.2.3的源码,开发者不仅可以掌握工作流管理的基本概念和技术,还能了解到Java企业级应用的设计模式和最佳实践,这对于提升软件开发能力、设计复杂的业务流程系统具有极大的帮助。同时,由于...
**JBPM 4.2 源码分析** JBPM(Java Business Process Management)是一款开源的工作流管理系统,它提供了一套完整的解决方案,用于设计、执行和管理业务流程。JBPM 4.2 是该框架的一个重要版本,包含了丰富的功能和...