Ok, so what's behind this picture ? jBPM uses jPDL to describe the process in XML format.

<process-definition xmlns="urn:jbpm.org:jpdl-3.2"
    <swimlane name="buyer">
        <assignment actor-id="customer"></assignment>

    <swimlane name="deliverDepartment">
        <assignment actor-id="deliver-man"></assignment>

    <start-state name="start">
        <transition name="trPlaceOrder" to="PlaceOrder"></transition>

    <task-node name="PlaceOrder">
        <task name="placeOrderTask" swimlane="buyer">
        <transition name="" to="CheckAvailability"></transition>

    <decision name="CheckAvailability">
        <handler class="com.sample.decision.VerifyOrder"></handler>
        <transition name="trDeliver" to="Deliver"></transition>
        <transition name="trGetFromStock" to="GetFromStock"></transition>

    <state name="GetFromStock">
        <event type="node-enter">
            <action class="com.sample.action.GetFromStockActionHandler"
        <transition name="checkAvailability" to="CheckAvailability"></transition>

    <task-node name="Deliver">
        <task name="getFromStock" swimlane="deliverDepartment">
        <transition name="trEnd" to="end"></transition>

    <end-state name="end"></end-state>


You can clearly see how the graphical elements have been translated into XML source code. jPDL in not too complicated, in short it will associate actions with handlers. Handlers are written as plain Java classes implementing business interfaces.

For example, the decision node CheckAvailability delegates to a DecisionHandler which path should be followed by our process. Here we'll use a very simple decision handler which compares two process variables in order to decide if there are enough good in the stock. In real world process, we'll likely query a Database in order to collect this information.  

package com.sample.decision;

import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;

public class VerifyOrder implements DecisionHandler {

    public String decide(ExecutionContext executionContext) throws Exception {

        Integer goodsOrdered = (Integer)executionContext.
        System.out.println("Goods ordered "+goodsOrdered.intValue());

        Integer goodsInStock = (Integer)executionContext.
        System.out.println("Goods in stock "+goodsInStock.intValue());

        if (goodsOrdered.intValue() > goodsInStock.intValue()) {
            return "trGetFromStock";
        else {
            return "trDeliver";




Related articles available on mastertheboss.com

How do I fire an action every time a JBPM Node enters?

JBoss recipe of the day

JBoss Jbpm superstates

What is a superstate ? a Superstate is a group of nodes. Supersta

Jbpm Mail delivery

Almost every workflow needs a notification of the process activit

How do you embed Java code in your JPDL ?

  You can use a BeanShell expression to add a Java script in you

JBPM best practices

There's no perfect rule to model your workflow, it depends on the

How to delete/persist your JBPM process after restart ?

JBoss recipe of the day