ITeye博客

jbpm3与发散模型

hongsoft · 2004-12-05 14:03 · Markdown

jbpm支持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 >= 3 ) {" +       "  transitionNames.add( \"to b\" );" +       "  transitionNames.add( \"to c\" );" +       "}" );

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。