jbpm3與發散模型
來源:互聯網
上載者:User
jbpm支援http://blog.csdn.net/hongbo781202/archive/2004/07/12/39393.aspx
中提到的三種發散模型:1)Parallel Split由fork來實現
對於fork後面的多個分支,jbpm保證它們是同步enabled2)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/" );" +
"}" );