Hi, I propose this solution based on an event type "node-enter" on the fork node.
| <process-definition name="parent-process"> | | <swimlane name="tester"> | <assignment expression="user(ernie)" /> | </swimlane> | | <start-state name="start"> | <task name="start-task" swimlane="tester"> | <controller> | <variable name="my-fork.leaving-transitions-count" /> | </controller> | </task> | <transition to="my-fork" /> | </start-state> | | <fork name="my-fork"> | <event type="node-enter"> | <action name="spawning" class="xxx.SpawningMultipleTransitions"/> | </event> | <transition to="sub-process-state" /> | </fork> | | <process-state name="sub-process-state"> | <sub-process name="sub-process" /> | <transition to="join"/> | </process-state> | | <join name="join"> | <transition to="end" /> | </join> | | <end-state name="end" /> | | </process-definition> | | package xxx; | | import java.util.List; | | import org.jbpm.graph.def.ActionHandler; | import org.jbpm.graph.def.Transition; | import org.jbpm.graph.exe.ExecutionContext; | import org.jbpm.graph.node.Fork; | | public class SpawningMultipleTransitions implements ActionHandler { | | public void execute(ExecutionContext executionContext) throws Exception { | Fork fork = (Fork) executionContext.getNode(); | String varName = new StringBuffer(fork.getName()).append(".leaving-transitions-count").toString(); | String leavingTransitionCount = (String) executionContext.getVariable(varName); | if (leavingTransitionCount == null) { | throw new RuntimeException("The variable " + varName + " must have an integer value"); | } | int n; | try { | n = Integer.parseInt(leavingTransitionCount); | } | catch (NumberFormatException e) { | throw new RuntimeException("The variable " + varName + " must have an integer value"); | } | | List transitions = fork.getLeavingTransitions(); | if (transitions.size() == 0) { | throw new RuntimeException("The fork node " + fork.getName() + | " must have a transition. Check your processdefinition.xml"); | } | else if (transitions.size() > 1) { | throw new RuntimeException("The fork node " + fork.getName() + | " must have only one transition. Check your processdefinition.xml"); | } | Transition transition = (Transition) fork.getLeavingTransitions().remove(0); | if (transition.getTo() == null) { | throw new RuntimeException("The transition " + transition.getName() + " of the fork node " + | fork.getName() + " must have a destination. Check your processdefinition.xml"); | } | String name = transition.getName(); | name = new StringBuffer(name != null ? name : "transition").append("-").toString(); | for (int i = 1; i <= n; i++) { | Transition trans = new Transition(new StringBuffer(name).append(i).toString()); | trans.setProcessDefinition(fork.getProcessDefinition()); | trans.setFrom(fork); | trans.setTo(transition.getTo()); | fork.addLeavingTransition(trans); | } | } | } | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953973#3953973 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953973 Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user