Search in sources :

Example 1 with ProcessInstanceStateChangeEvent

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);
                }
            }
        }
    }
}
Also used : ProcessInstanceStateChangeEvent(org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent) ProcessTerminationEvent(org.apache.ode.bpel.evt.ProcessTerminationEvent) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)

Aggregations

ProcessInstanceStateChangeEvent (org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent)1 ProcessTerminationEvent (org.apache.ode.bpel.evt.ProcessTerminationEvent)1 ProcessConfigurationImpl (org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)1