Example usage for org.springframework.scheduling.support DelegatingErrorHandlingRunnable DelegatingErrorHandlingRunnable

List of usage examples for org.springframework.scheduling.support DelegatingErrorHandlingRunnable DelegatingErrorHandlingRunnable

Introduction

In this page you can find the example usage for org.springframework.scheduling.support DelegatingErrorHandlingRunnable DelegatingErrorHandlingRunnable.

Prototype

public DelegatingErrorHandlingRunnable(Runnable delegate, ErrorHandler errorHandler) 

Source Link

Document

Create a new DelegatingErrorHandlingRunnable.

Usage

From source file:org.springframework.scheduling.support.TaskUtils.java

/**
 * Decorate the task for error handling. If the provided {@link ErrorHandler}
 * is not {@code null}, it will be used. Otherwise, repeating tasks will have
 * errors suppressed by default whereas one-shot tasks will have errors
 * propagated by default since those errors may be expected through the
 * returned {@link Future}. In both cases, the errors will be logged.
 *///from   w  w  w . j a va2  s.c  o  m
public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runnable task,
        @Nullable ErrorHandler errorHandler, boolean isRepeatingTask) {

    if (task instanceof DelegatingErrorHandlingRunnable) {
        return (DelegatingErrorHandlingRunnable) task;
    }
    ErrorHandler eh = (errorHandler != null ? errorHandler : getDefaultErrorHandler(isRepeatingTask));
    return new DelegatingErrorHandlingRunnable(task, eh);
}