use of io.automatiko.engine.api.event.process.ProcessSignaledEvent in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterProcessSignaled.
public void fireAfterProcessSignaled(String signal, Object data, final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessSignaledEvent event = new ProcessSignaledEventImpl(signal, data, instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.afterProcessSignaled(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.afterProcessSignaled(e));
}));
}
use of io.automatiko.engine.api.event.process.ProcessSignaledEvent in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeProcessSignaled.
public void fireBeforeProcessSignaled(String signal, Object data, final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessSignaledEvent event = new ProcessSignaledEventImpl(signal, data, instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeProcessSignaled(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.beforeProcessSignaled(e));
}));
}
Aggregations