---
title: "jbpm3与发散模型"
author: "hongsoft"
date: "2004-12-05T14:03:00Z"
tags: []
slug: "jbpm3"
draft: false
lastmod: "2004-12-05T14:03:00Z"
id: 287512
url: "https://hongsoft.iteye.com/blog/287512"
---

#### jbpm支持[http://blog.csdn.net/hongbo781202/archive/2004/07/12/39393.aspx](http://blog.csdn.net/hongbo781202/archive/2004/07/12/39393.aspx) 中提到的三种发散模型:

#### 1)Parallel Split由fork来实现 对于fork后面的多个分支,jbpm保证它们是同步enabled

#### 2)exclusive choice由decision来实现 在流程定义中,要加入bsh脚本,下面是jbpm解析脚本的方法:     Script script = new Script();     script.setResultVariableName("transitionName");     script.setStatements(       "if ( scenario == 1 ) { " +       "  transitionName = \\"to b\\"; " +       "} else if ( scenario == 2 ) {" +       "  transitionName = \\"to c\\"; " +       "}" ); 然后,jbpm把script加入到流程定义中:     Decision decision = (Decision) pd.getNode("xor");     decision.setScript( script ); 在流程运行过程中,通过环境实例为脚本中的变量赋值:    ci.setVariable( "scenario", new Integer(1) ); jbpm就能够根据变量的值确定流程的流转.

#### 3)multiple choice也通过decision来实现 与上面不同的是,结果变量不再是一个串,而是一个数组: script.setStatements(       "transitionNames = new ArrayList();" +       "if ( scenario == 1 ) {" +       "  transitionNames.add( \\"to b\\" );" +       "} else if ( scenario == 2 ) {" +       "  transitionNames.add( \\"to c\\" );" +       "} else if ( scenario &gt;= 3 ) {" +       "  transitionNames.add( \\"to b\\" );" +       "  transitionNames.add( \\"to c\\" );" +       "}" );