[jboss-user] [JBoss jBPM] - Re: Tasks need to done by multiple users

bradsdavis do-not-reply at jboss.com
Mon Mar 9 18:19:24 EDT 2009


I just tried this by the way.  It works great for cases where you want a number of tasks created.  But, as Ronald suggested, more complicated cases require the join pattern.  In such cases, a lock token exception is thrown; for example, if I have an event on the end of the task instance to kill another task in the same node, an exception will occur.

Like I said though, if you just simply want to generate a number of tasks to be created, I think this works great.  Within an action handler, you would have:



  | 	    Token token = executionContext.getToken();
  | 	    TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
  | 	      
  | 	    TaskNode taskNode = (TaskNode) executionContext.getNode();
  | 
  | 	    Task example = taskNode.getTask("Example");
  | 
  | 	    tmi.createTaskInstance(validateDateTask, token);
  |             //Generate some tasks on the fly.	    
  | 	    for(int i=0; i<3; i++)
  | 	    {
  | 	    	TaskInstance instance = tmi.createTaskInstance(example, token);
  | 	    	instance.setVariableLocally("ExampleVar", "AAA"+i);
  | 	    	instance.setVariableLocally("Example2Var", new Date());
  | 	    }
  | 

Process definition:

  | 	<task-node name="task-node1" create-tasks="false" signal="last">
  | 		<event type="node-enter">
  | 			<action class="com.example.DynamicGenerateActionHandler"></action>
  | 		</event>
  | 		<transition to="end-state1"></transition>
  | 		<task name="Example">
  | 			<controller>
  | 				<variable name="ExampleVar" access="read"></variable>
  | 			</controller>
  | 		</task>
  | 	</task-node>
  | 

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

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



More information about the jboss-user mailing list