void fireInterrupted(InterruptedException exception) { TaskEvent<InterruptedException> event = TaskEvent.interrupted(task, exception); LOG.debug("firing interrupted event: {}", event); for (TaskListener<? super T> listener : listeners) { listener.interrupted(event); } }
void fireCanceled() { TaskEvent<Void> event = TaskEvent.started(task); LOG.debug("firing canceled event: {}", event); for (TaskListener<? super T> listener : listeners) { listener.canceled(event); } }
void fireFinished() { TaskEvent<Void> event = TaskEvent.finished(task); LOG.debug("firing finished event: {}", event); for (TaskListener<? super T> listener : listeners) { listener.finished(event); } }
void fireSucceeded(T value) { TaskEvent<T> event = TaskEvent.succeeded(task, value); LOG.debug("firing succeeded event: {}", event); for (TaskListener<? super T> listener : listeners) { listener.succeeded(event); } }
void fireFailed(Throwable exception) { TaskEvent<Throwable> event = TaskEvent.failed(task, exception); LOG.debug("firing failed event: {}", event); for (TaskListener<? super T> listener : listeners) { listener.failed(event); } }
/** * Invoked when a task completes or is cancelled. * * @param event the event */ private void onTaskEvent(TaskEvent event) { switch (event.getType()) { case SKIPPED: notifySkipped(); break; case CANCELLED: notifyCancelled(); break; case COMPLETED: notifyCompleted(); break; } }
/** * Invoked when the condition task completes or is cancelled. * * @param event the event */ private void onConditionEvent(TaskEvent event) { switch (event.getType()) { case SKIPPED: notifySkipped(); break; case CANCELLED: notifyCancelled(); break; case COMPLETED: if (condition.getValue()) { start(task, context); } else if (elseTask != null) { start(elseTask, context); } else { notifyCompleted(); } break; } }