This sample is an excerpt from arbitrary cycle of the workflow patterns:

  | <process-definition name="arbitrary-cycle">
  | 
  |     <start-state name="A">
  |     <transition to="B"/>
  |     </start-state>  
  | 
  |     <state name="B">
  |     <timer duedate="20 seconds" transition="C">
  |        <script>print( "Your 20 seconds is up. Just letting you know I will 
go to C now" );</script>         
  |     </timer>
  |     <transition name="C" to="C">
  |     </state>                
  | 
  |     <state name="C">
  |     <event type="node-enter">
  |        <action class="DoAsyncStuff"/> 
  |     </event>        
  |     <transition name="fail" to="B"/>
  |     <transition name="pass" to="E"/>
  |     </state>                
  | 
  |     <end-state name="E"/>   
  | 
  | </process-definition>
  | 

This is the main execution part. Executed only once.

  |     JbpmContext ctx = config.createJbpmContext();
  |     try {
  |       ProcessInstance proc = ctx.newProcessInstance( "arbitrary-cycle" );
  |       proc.signal();
  |       ctx.save(proc);
  |     }
  |     catch(Exception ex) 
  |     {
  |       ctx.setRollbackOnly();
  |       throw ex;
  |     }
  |     finally 
  |     {
  |       ctx.close();
  |     }      
  | 

In the EventListenerThread example from my previous code


  |    public void run() {
  |     //this class executes a long running process. It returns a status 
  |     boolean pass = ALongRunningProcess.execute();        
  | 
  |             JbpmContext ctx = config.createJbpmContext();
  |             try {
  |                     ProcessInstance proc = ctx.newProcessInstance( 
"arbitrary-cycle" );
  |             if( !pass ) 
  |                             proc.signal("fail");
  |             else
  |                     proc.signal("pass");
  |                     ctx.save(proc);
  |             }
  |             catch(Exception ex) 
  |             {
  |                     ctx.setRollbackOnly();
  |                     throw ex;
  |             }
  |             finally 
  |             {
  |                     ctx.close();
  |             }      
  |     }
  | 

Take note: Running threads has some issues in a J2ee environment, also this 
will not run if you restart the server. But thats another story. So this 
example is just used to illustrate a point. In fact you can accomplish 
something similar using timers instead. Hope this is clear.

Regards,

Elmo


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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to