use of org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent in project carbon-business-process by wso2.
the class EventListener method onEvent.
public void onEvent(BpelEvent bpelEvent) {
if (isCoordinationEnabled) {
if (bpelEvent instanceof ProcessTerminationEvent) {
ProcessTerminationEvent event = (ProcessTerminationEvent) bpelEvent;
ProcessConfigurationImpl processConf = getProcessConfiguration(event);
if (processConf != null && processConf.isB4PTaskIncluded()) {
if (log.isDebugEnabled()) {
log.debug("TERMINATED Process instance " + event.getProcessInstanceId() + " has a B4P activity. Initiating Exit Protocol Messages to task(s).");
}
TerminationTask terminationTask = new TerminationTask(Long.toString(event.getProcessInstanceId()));
terminationTask.setTenantID(processConf.getTenantId());
B4PContentHolder.getInstance().getCoordinationController().runTask(terminationTask);
}
} else if (bpelEvent instanceof ProcessInstanceStateChangeEvent) {
ProcessInstanceStateChangeEvent instanceStateChangeEvent = (ProcessInstanceStateChangeEvent) bpelEvent;
if (ProcessState.STATE_COMPLETED_WITH_FAULT == instanceStateChangeEvent.getNewState()) {
ProcessConfigurationImpl processConf = getProcessConfiguration(instanceStateChangeEvent);
if (processConf != null && processConf.isB4PTaskIncluded()) {
if (log.isDebugEnabled()) {
log.debug("Process Instance, COMPLETED WITH FAULT " + instanceStateChangeEvent.getProcessInstanceId() + " has a B4P activity. Initiating Exit Protocol Messages to task(s)");
}
TerminationTask terminationTask = new TerminationTask(Long.toString(instanceStateChangeEvent.getProcessInstanceId()));
terminationTask.setTenantID(processConf.getTenantId());
B4PContentHolder.getInstance().getCoordinationController().runTask(terminationTask);
}
}
}
}
}
Aggregations