06-12-2012 10:26 AM
06-12-2012 11:56 AM
<process id="exceptionHandling">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="javaService" />
<serviceTask id="javaService"
name="Java service invocation"
activiti:class="org.activiti.examples.bpmn.servicetask.ThrowsExceptionBehavior">
</serviceTask>
<sequenceFlow id="no-exception" sourceRef="javaService" targetRef="theEnd" />
<sequenceFlow id="exception" sourceRef="javaService" targetRef="fixException" />
<userTask id="fixException" name="Fix Exception" />
<sequenceFlow id="flow4" sourceRef="fixException" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
And the trick is done inside the ThrowsExceptionBehavior:
public class ThrowsExceptionBehavior implements ActivityBehavior {
public void execute(ActivityExecution execution) throws Exception {
String var = (String) execution.getVariable("var");
PvmTransition transition = null;
try {
executeLogic(var);
transition = execution.getActivity().findOutgoingTransition("no-exception");
} catch (Exception e) {
transition = execution.getActivity().findOutgoingTransition("exception");
}
execution.take(transition);
}
protected void executeLogic(String value) {
if (value.equals("throw-exception")) {
throw new RuntimeException();
}
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.