=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2015-09-14 18:06:48 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2015-10-07 13:25:14 +0000 @@ -28,6 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.springframework.util.concurrent.ListenableFuture; + +import java.util.concurrent.Callable; + /** * Scheduler for managing the scheduling and execution of tasks. * @@ -52,6 +56,15 @@ * @task the task to execute. */ void executeTask( Runnable task ); + + /** + * Execute the given task immediately and return a ListenableFuture. + * + * @param callable the task to execute. + * @param return type of the supplied callable. + * @return a ListenableFuture representing the result of the task. + */ + ListenableFuture executeTask( Callable callable ); /** * Schedule the given task for future execution. The task can be referenced === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 2015-06-05 12:56:34 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 2015-10-07 13:25:14 +0000 @@ -31,13 +31,15 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.Callable; import java.util.concurrent.ScheduledFuture; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.core.task.TaskExecutor; +import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.support.CronTrigger; +import org.springframework.util.concurrent.ListenableFuture; /** * {@link Scheduler} implementation for use within the Spring framework. @@ -61,9 +63,9 @@ this.taskScheduler = taskScheduler; } - private TaskExecutor taskExecutor; + private AsyncListenableTaskExecutor taskExecutor; - public void setTaskExecutor( TaskExecutor taskExecutor ) + public void setTaskExecutor( AsyncListenableTaskExecutor taskExecutor ) { this.taskExecutor = taskExecutor; } @@ -79,6 +81,12 @@ } @Override + public ListenableFuture executeTask( Callable callable ) + { + return taskExecutor.submitListenable( callable ); + } + + @Override public boolean scheduleTask( String key, Runnable task, String cronExpr ) { if ( key != null && !futures.containsKey( key ) )