Example usage for org.springframework.scheduling.concurrent ScheduledExecutorTask getPeriod

List of usage examples for org.springframework.scheduling.concurrent ScheduledExecutorTask getPeriod

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ScheduledExecutorTask getPeriod.

Prototype

public long getPeriod() 

Source Link

Document

Return the period between repeated task executions.

Usage

From source file:org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean.java

/**
 * Register the specified {@link ScheduledExecutorTask ScheduledExecutorTasks}
 * on the given {@link ScheduledExecutorService}.
 * @param tasks the specified ScheduledExecutorTasks (never empty)
 * @param executor the ScheduledExecutorService to register the tasks on.
 *//*from   ww  w. j av a  2  s  .c  o  m*/
protected void registerTasks(ScheduledExecutorTask[] tasks, ScheduledExecutorService executor) {
    for (int i = 0; i < tasks.length; i++) {
        ScheduledExecutorTask task = tasks[i];
        Runnable runnable = getRunnableToSchedule(task);
        if (task.isOneTimeTask()) {
            executor.schedule(runnable, task.getDelay(), task.getTimeUnit());
        } else {
            if (task.isFixedRate()) {
                executor.scheduleAtFixedRate(runnable, task.getDelay(), task.getPeriod(), task.getTimeUnit());
            } else {
                executor.scheduleWithFixedDelay(runnable, task.getDelay(), task.getPeriod(),
                        task.getTimeUnit());
            }
        }
    }
}