JBPM 4.4 Notes

 

  • Starts with <Start> Node, Common example:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <process name="Purchase order" xmlns="http://jbpm.org/4.4/jpdl">
    
      <start>
        <transition to="Verify supplier" />
      </start>
    
      <state name="Verify supplier"> //choice is triggered by external input.
        <transition name="Supplier ok" to="Check supplier data" />
        <transition name="Supplier not ok" to="Error" />
      </state>
    
      <decision name="Check supplier data">
        <transition name="nok" to="Error" />
        <transition name="ok" to="Completed" />
      </decision>
    
      <end name="Completed" />
    
      <end name="Error" />
    
    </process>
  • <state> node can have multiple transitions:
    <process name="StateChoice" xmlns="http://jbpm.org/4.4/jpdl">
    
      <start>
        <transition to="wait for response" />
      </start>
    
      <state name="wait for response">
        <transition name="accept" to="submit document" />
        <transition name="reject" to="try again" />
      </state>
    
      <state name="submit document" />
    
      <state name="try again" />
    
    </process>
  • <decision> node :A decision expression evaluates to a String representing the name of an outgoing transition.
    <process name="DecisionExpression" xmlns="http://jbpm.org/4.4/jpdl">
    
      <start >
        <transition to="evaluate document"/>
      </start>
    
      <decision name="evaluate document" expr="#{content}" >
        <transition name="good" to="submit document"  />
        <transition name="bad"  to="try again"  />
        <transition name="ugly" to="give up"  />
      </decision>
    
      <state name="submit document"  />
      <state name="try again"  />
      <state name="give up"  />
    
    </process>
    
    
  • Decision handler Class
    public interface DecisionHandler {
       String decide(OpenExecution execution);
    }
    <process name="DecisionHandler">
    
      <start>
        <transition to="evaluate document" />
      </start>
    
      <decision name="evaluate document">
        <handler />
        <transition name="good" to="submit document" />
        <transition name="bad" to="try again" />
        <transition name="ugly" to="give up" />
      </decision>
    
      <state name="submit document" />
    
      <state name="try again" />
    
      <state name="give up" />
    
    </process>
    public class ContentEvaluation implements DecisionHandler {
    
      public String decide(OpenExecution execution) {
        String content = (String) execution.getVariable("content");
        if (content.equals("you're great")) {
          return "good";
        }
        if (content.equals("you gotta improve")) {
          return "bad";
        }
        return "ugly";
      }
    }
  • Concurrency:

    <process name="ConcurrencyGraphBased" xmlns="http://jbpm.org/4.4/jpdl">
    
       <start>
          <transition to="fork"/>
       </start>
    
       <fork name="fork">
          <transition to="send invoice" />
          <transition to="load truck"/>
          <transition to="print shipping documents" />
       </fork>
    
       <state name="send invoice" >
          <transition to="final join" />
       </state>
    
       <state name="load truck" >
          <transition to="shipping join" />
       </state>
    
       <state name="print shipping documents">
          <transition to="shipping join" />
       </state>
    
       <join name="shipping join" >
          <transition to="drive truck to destination" />
       </join>
    
       <state name="drive truck to destination" >
          <transition to="final join" />
       </state>
    
       <join name="final join" >
          <transition to="end"/>
       </join>
    
       <end name="end" />
    
    </process>
  • <end> node, we can have multiple end node .
  • <custom> node: Invokes user code that implements custom behaviour of an activity.
    <process name="Custom" xmlns="http://jbpm.org/4.4/jpdl">
    
      <start >
        <transition to="print dots" />
      </start>
    
      <custom name="print dots"
           >
    
        <transition to="end" />
      </custom>
    
      <end name="end" />
    
    </process>

    The custom activity behaviour class PrintDots shows that it’s possible to control the flow when implementing custom activity behaviours. In this case the PrintDots acitivity implementation will after printing dots wait in the activity until a signal is given.

    public class PrintDots implements ExternalActivityBehaviour {
    
      private static final long serialVersionUID = 1L;
    
      public void execute(ActivityExecution execution) {
        String executionId = execution.getId();
    
        String dots = ...;
    
        System.out.println(dots);
    
        execution.waitForSignal();
      }
    
      public void signal(ActivityExecution execution,
                         String signalName,
                         Map<String, ?> parameters) {
        execution.take(signalName);
      }
    }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s