Process Execution

The heart of the bexee is the process controller. Its primary task is to receive messages for business processes and to execute them against a business process. Thus the process controller is the part of the bexee system which comprises logic capable of executing processes. Each activity has its own dedicated method for processing. Enhancing bexee with capabilities for processing new activities boils down to implementing the right method within the process controller.

Visitor pattern implementation

The process controller and the BPELProcess representing business process blueprints implement the Visitor software design pattern. The process and its activities are the "Visitable" partners and the process controller is the "Visitor"

Visitor pattern implementation

For the execution of a BPELProcess, double dispatching is used. This allows an elegant processing of each type of the activities comprised in a BPELProcess without tedious activity type checking:

if (activity instanceof Scope) {
  ...
} else if (activity instanceof Flow) { // tedious activity type cheking
  ...
} else if (...
  ...

Before the visitor really processes an Activity, it merely calls the accept method of the activity and passes itself and a ProcessInstance (which represents an instance of a business process) with the call:

>Visitor code
rootActivity.accept(this, processInstance);
>Activity code

public void accept(ProcessController controller, ProcessInstance instance) {
    controller.process(this, instance);
}

This in effect results in calling exactly the right method of the process controller, i.e. a method specialized for the processing of exactly one activity:

public class ProcessControllerImpl implements ProcessController {

    ...
    public void process(Process process, ProcessInstance instance) {
        ...
        Activity activity = process.getActivity();
        if (activity != null) {
            activity.accept(this, instance);
        } else {
            throw new MissingActivityException();
        }
        ...
    }

    //**************************************************/
    // process structured activities
    //**************************************************/

    public void process(Sequence sequence, ProcessInstance instance) {
        ...
        // process all activities in sequence
        List activities = sequence.getActivities();
        for (Iterator iter = activities.iterator(); iter.hasNext();) {
            Activity activity = (Activity) iter.next();
            activity.accept(this, instance);
        }
        ...
    }
    ...

    //**************************************************/
    // process atomic activities
    //**************************************************/

    public void process(Receive receive, ProcessInstance instance) {
        ...
        // process a receive activity
        ...
    }

    public void process(Invoke invoke, ProcessInstance instance) {
        ...
        // process an invoke activity
        ...
    }
    ...
}

Processing of activities which might contain other activities consists of iterating over the contained activities and calling their accept() method. This method, as already mentioned, will call the right method within the ProcessController. A guide for enhancing the process controller to support more activities can be found in the Developer's Guide