Example usage for org.springframework.scheduling.config ScheduledTask cancel

List of usage examples for org.springframework.scheduling.config ScheduledTask cancel

Introduction

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

Prototype

public void cancel() 

Source Link

Document

Trigger cancellation of this scheduled task.

Usage

From source file:org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.java

@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    Set<ScheduledTask> tasks;
    synchronized (this.scheduledTasks) {
        tasks = this.scheduledTasks.remove(bean);
    }/* w  ww. j av a 2 s  . c om*/
    if (tasks != null) {
        for (ScheduledTask task : tasks) {
            task.cancel();
        }
    }
}

From source file:org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.java

@Override
public void destroy() {
    synchronized (this.scheduledTasks) {
        Collection<Set<ScheduledTask>> allTasks = this.scheduledTasks.values();
        for (Set<ScheduledTask> tasks : allTasks) {
            for (ScheduledTask task : tasks) {
                task.cancel();
            }//from  ww w.j  a v a  2 s  . com
        }
        this.scheduledTasks.clear();
    }
    this.registrar.destroy();
}