Example usage for org.springframework.scheduling.support TaskUtils decorateTaskWithErrorHandler

List of usage examples for org.springframework.scheduling.support TaskUtils decorateTaskWithErrorHandler

Introduction

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

Prototype

public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runnable task,
        @Nullable ErrorHandler errorHandler, boolean isRepeatingTask) 

Source Link

Document

Decorate the task for error handling.

Usage

From source file:com.xyxy.platform.examples.showcase.demos.schedule.JdkTimerJob.java

@PostConstruct
public void start() throws Exception {
    Validate.isTrue(period > 0);/*w  w  w .  jav a  2s.c  o  m*/

    // ?schedule, Spring TaskUtilsLOG_AND_SUPPRESS_ERROR_HANDLER?
    Runnable task = TaskUtils.decorateTaskWithErrorHandler(this, null, true);

    // ?SechdulerExecutor,guavaThreadFactoryBuilder???
    scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
            new ThreadFactoryBuilder().setNameFormat("JdkTimerJob-%1$d").build());

    // scheduleAtFixedRatefixRate() ?.
    // scheduleAtFixedDelay() ???.
    scheduledExecutorService.scheduleAtFixedRate(task, initialDelay, period, TimeUnit.SECONDS);
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) {
    return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask);
}