Example usage for org.springframework.scheduling.config IntervalTask IntervalTask

List of usage examples for org.springframework.scheduling.config IntervalTask IntervalTask

Introduction

In this page you can find the example usage for org.springframework.scheduling.config IntervalTask IntervalTask.

Prototype

public IntervalTask(Runnable runnable, long interval, long initialDelay) 

Source Link

Document

Create a new IntervalTask .

Usage

From source file:com.github.jmnarloch.spring.cloud.config.refresh.ConfigClientRefreshAutoConfiguration.java

/**
 * Configures the scheduler by registering task responsible for periodically refreshing entire endpoint.
 *
 * @param taskRegistrar the task registrar
 *//*ww w  .j  a v a2s . c om*/
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {

    final long interval = getRefreshIntervalInMilliseconds();

    logger.info(String.format("Scheduling config refresh task with %s second delay", refreshInterval));

    taskRegistrar.addFixedDelayTask(new IntervalTask(new Runnable() {
        @Override
        public void run() {
            refreshEndpoint.refresh();
        }
    }, interval, interval));
}