[jboss-user] [JBoss jBPM] - Re: modelling worklows with parallel nodes

ffernandez do-not-reply at jboss.com
Tue Mar 11 07:41:01 EDT 2008


Hi Ronald,

I have tested this workflow with task-nodes but without parallel execution (task node "one" and "two" are executed in sequence):


  | import junit.framework.*;
  | import org.jbpm.*;
  | import org.jbpm.graph.def.*;
  | import org.jbpm.graph.exe.*;
  | 
  | public class JbpmForkTest extends TestCase {
  | 	
  | 	JbpmConfiguration configuration = JbpmConfiguration.getInstance( "my.jbpm.cfg.xml" );	
  | 	
  | 	 protected void setUp() { 
  | 		JbpmContext jbpmContext = configuration.createJbpmContext();
  | 
  | 		ProcessDefinition pd = ProcessDefinition.parseXmlString(
  | 				"<process-definition name='test'>" +
  | 				" <start-state name='start'>" +
  | 				" <transition to='fork' />" +
  | 				" </start-state>" +
  | 				" <fork name='fork'>" +
  | 				" <transition name='first' to='one' />" +
  | 				" <transition name='second' to='two' />" +
  | 				" </fork>" +
  | 				" <task-node name='one' >" +				
  | 				"   <event type='node-enter'>" +
  | 				" 	<action class='JbpmSleepActionHandler'/>" +
  | 				"   </event> " +
  | 				" 	<transition to='join'>" +
  | 				" 	</transition>" +
  | 				" </task-node >" +
  | 				" <task-node  name='two' >" +
  | 				"   <event type='node-enter'>" +
  | 				"	<action class='JbpmSleepActionHandler'/>" +
  | 				"   </event> " +
  | 				" 	<transition to='join'>" +			
  | 				" 	</transition>" +
  | 				" </task-node >" +
  | 				" <join name='join'>" +
  | 				" <transition to='end' />" +
  | 				" </join>" +
  | 				" <end-state name='end' />" +
  | 				"</process-definition>"
  | 		);
  | 		jbpmContext.deployProcessDefinition( pd );
  | 		jbpmContext.close();		
  | 	}
  | 
  | 	public void testFork() throws Exception{
  | 		
  | 		JbpmContext jbpmContext = configuration.createJbpmContext();
  | 		ProcessInstance pi = jbpmContext.newProcessInstance( "test" );		
  | 		pi.signal();
  | 		jbpmContext.save( pi );
  | 		jbpmContext.close();				
  | 	}
  | 
  | }
  | 
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class JbpmSleepActionHandler implements ActionHandler {
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception {
  | 		System.err.println ( "sleep " + executionContext );	
  | 		Thread.sleep( 10000 );
  | 		System.err.println ( "wakeup " + executionContext );
  | 		}
  | }
  | 
  | 

Thanks Ronald

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135581#4135581

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135581



More information about the jboss-user mailing list