Provide accessors to scheduled tasks

Updated ScheduledTaskRegistrar to offer accessors to the tasks
it is responsible to schedule.

Issue: SPR-12748
This commit is contained in:
Tobias Montagna-Hay
2015-02-24 17:20:47 +13:00
committed by Stephane Nicoll
parent dff2a3d180
commit 64467b4f59
2 changed files with 109 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.scheduling.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
@@ -47,6 +48,7 @@ import org.springframework.util.CollectionUtils;
*
* @author Juergen Hoeller
* @author Chris Beams
* @author Tobias Montagna-Hay
* @since 3.0
* @see org.springframework.scheduling.annotation.EnableAsync
* @see org.springframework.scheduling.annotation.SchedulingConfigurer
@@ -123,6 +125,14 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
this.triggerTasks = triggerTasks;
}
/**
* Return the trigger tasks as a list of {@link TriggerTask}
* @since 4.2
*/
public List<TriggerTask> getTriggerTaskList() {
return Collections.unmodifiableList(this.triggerTasks);
}
/**
* Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.
* @see CronTrigger
@@ -144,6 +154,14 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
this.cronTasks = cronTasks;
}
/**
* Return the cron tasks as a list of {@link CronTask}
* @since 4.2
*/
public List<CronTask> getCronTaskList() {
return Collections.unmodifiableList(this.cronTasks);
}
/**
* Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values.
* @see TaskScheduler#scheduleAtFixedRate(Runnable, long)
@@ -165,6 +183,14 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
this.fixedRateTasks = fixedRateTasks;
}
/**
* Return the fixed-rate tasks as a list of {@link IntervalTask}.
* @since 4.2
*/
public List<IntervalTask> getFixedRateTaskList() {
return Collections.unmodifiableList(this.fixedRateTasks);
}
/**
* Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values.
* @see TaskScheduler#scheduleWithFixedDelay(Runnable, long)
@@ -186,6 +212,14 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean
this.fixedDelayTasks = fixedDelayTasks;
}
/**
* Return the fixed-delay tasks as a list of {@link IntervalTask}
* @since 4.2
*/
public List<IntervalTask> getFixedDelayTaskList() {
return Collections.unmodifiableList(this.fixedDelayTasks);
}
/**
* Add a Runnable task to be triggered per the given {@link Trigger}.
* @see TaskScheduler#scheduleAtFixedRate(Runnable, long)