This guide describes the procedure of enhancing the Process controller in order to enable processing of newly implemented activities. In order to describe this procedure, an example will be used. In the guide: "How to implement BPEL Activities in bexee" the "Switch" activity has been implemented. Enabling the processing of a "Switch" activity boils down to:
Implementing the accept(...) method of the "Switch" activity is fairly straightforward. In this version of bexee it looks the same for all activities:
public class SwitchImpl extends AbstractActivity implements Switch { ... public void accept(ProcessController controller, ProcessInstance instance) throws Exception { controller.process(this, instance); } }
After the implementation of the accept(...) method within the "Switch" activity it is necessary to define a process(Switch, ProcessInstance) method in the ProcessController.
ProcessController interface:
public interface ProcessController { ... public void process(Sequence sequence, ProcessInstance instance) throws Exception; ... }
Once the method definition has been added to the ProcessController interface, it is necessary to implement it. Thanks to the double dispatch mechanism this method will be called directly from the "accept(...)" method, no tedious instanceof checking is necessary.
ProcessController example implementation:
public class ProcessControllerImpl implements ProcessController { ... public void process(Switch bpelSwitch, ProcessInstance instance) throws Exception { List bpelCases = bpelSwitch.getCases(); for (Iterator iter = bpelCases.iterator(); iter.hasNext();) { BpelCase bpelCase = (BpelCase) iter.next(); if (bpelCase.getBooleanExpression().evaluate()) { bpelCase.getCaseActivity().accept(this, instance); return; } } Activity otherwise = bpelSwitch.getOtherwise(); if (otherwise != null) { otherwise.accept(this, instance); } } ... }