[jboss-user] [jBPM] New message: "Re: Jbpm 4.3 Event Listeners"

Tony D do-not-reply at jboss.com
Mon Feb 15 05:17:54 EST 2010


User development,

A new message was posted in the thread "Jbpm 4.3 Event Listeners":

http://community.jboss.org/message/526294#526294

Author  : Tony D
Profile : http://community.jboss.org/people/tony2010

Message:
--------------------------------------------------------------
I dont have the unit test case but the basic code is below:
 
*Sample Workflow:*
 
<?xml version="1.0" encoding="UTF-8"?>
 
<process name="TEST" xmlns="http://jbpm.org/4.3/jpdl">
 
    <start g="0,0,80,40">
        <transition to="theEnd" />
    </start>    
    
    <end g="135,72,80,40" name="theEnd" />
 
    <on event="start">
            <event-listener class="WorkflowStatusEvent">
                <field name="transactionId" cache="disabled">
                    <object expr="#{id}" />
                </field>
                <field name="status" >
                    <string value="IN_PROGRESS" />
                </field>
                <field name="tcn" cache="disabled">
                    <object expr="#{param1}" />
                </field>
            </event-listener>            
        </on>
 

    <on event="end">
        <event-listener class="WorkflowStatusEvent">
            <field name="transactionId" cache="disabled">
                <object expr="#{id}" />
            </field>
            <field name="status">
                <string value="COMPLETED" />
            </field>
            <field name="tcn" cache="disabled">
                <object expr="#{param1}" />
            </field>
        </event-listener>
    </on>
</process>
 
 
 
*Event Listener Code:*
 
public class WorkflowStatusEvent implements EventListener {
 
  Logger log = Logger.getLogger(WorkflowStatusEvent.class);
  
  //value gets injected from process definition
  String transactionId;
  
  String status;
  
  String tcn;
  
  public void notify(EventListenerExecution execution) {    
      log.info( transactionId+" -- " + status);
      log.info(tcn);           
  }
  
    
}
 
 
 
*Code starting the business process:*
 
for (i = 0 ; i < 2 ; i++) {
 
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("param1", Integer.toString(i));
    parameters.put("param2", Integer.toString(i));
    parameters.put("id", Integer.toString(i));
            
    executionService.startProcessInstanceByKey("TEST",parameters);            
}
 
The SOPL in the Event listener displays the value of first cycle event if the value of i = 2.

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/526294#526294




More information about the jboss-user mailing list