use of io.automatiko.engine.api.runtime.process.ProcessRuntime 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.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterProcessStarted.
public void fireAfterProcessStarted(final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessStartedEvent event = new ProcessStartedEventImpl(instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.afterProcessStarted(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.afterProcessStarted(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeProcessStarted.
public void fireBeforeProcessStarted(final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessStartedEvent event = new ProcessStartedEventImpl(instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeProcessStarted(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.beforeProcessStarted(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterProcessCompleted.
public void fireAfterProcessCompleted(final ProcessInstance instance, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessCompletedEvent event = new ProcessCompletedEventImpl(instance, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.afterProcessCompleted(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
delayedListeners.forEach(l -> l.afterProcessCompleted(e));
}));
}
use of io.automatiko.engine.api.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireBeforeWorkItemTransition.
public void fireBeforeWorkItemTransition(final ProcessInstance instance, WorkItem workitem, Transition<?> transition, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessWorkItemTransitionEvent event = new ProcessWorkItemTransitionEventImpl(instance, workitem, transition, runtime, false);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.beforeWorkItemTransition(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.beforeWorkItemTransition(e));
}));
}
Aggregations