Search in sources :

Example 1 with BackgroundTaskTimeoutEvent

use of com.haulmont.cuba.gui.event.BackgroundTaskTimeoutEvent in project cuba by cuba-platform.

the class TaskHandlerImpl method timeoutExceeded.

/**
 * Cancel with timeout exceeded event
 */
public final void timeoutExceeded() {
    uiAccessor.access(() -> {
        Frame ownerFrame = getTask().getOwnerFrame();
        if (log.isTraceEnabled()) {
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Task timeout exceeded. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
            } else {
                log.trace("Task timeout exceeded. Task: {}", taskExecutor.getTask());
            }
        }
        checkState(started, "Task is not running");
        boolean canceled = taskExecutor.cancelExecution();
        if (canceled || timeoutHappens) {
            detachCloseListener();
            BackgroundTask<T, V> task = taskExecutor.getTask();
            boolean handled = task.handleTimeoutException();
            if (!handled) {
                log.error("Unhandled timeout exception in background task. Task: " + task.toString());
                events.publish(new BackgroundTaskTimeoutEvent(this, task));
            }
        }
        if (log.isTraceEnabled()) {
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Timeout was processed. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
            } else {
                log.trace("Timeout was processed. Task: {}", taskExecutor.getTask());
            }
        }
    });
}
Also used : BackgroundTaskTimeoutEvent(com.haulmont.cuba.gui.event.BackgroundTaskTimeoutEvent) Frame(com.haulmont.cuba.gui.components.Frame)

Aggregations

Frame (com.haulmont.cuba.gui.components.Frame)1 BackgroundTaskTimeoutEvent (com.haulmont.cuba.gui.event.BackgroundTaskTimeoutEvent)1