Class TaskScheduler

java.lang.Object
org.deltava.taskman.TaskScheduler
All Implemented Interfaces:
Runnable, Thread.UncaughtExceptionHandler

public class TaskScheduler extends Object implements Runnable, Thread.UncaughtExceptionHandler
A class to control execution of Scheduled Tasks. This operates much like a Unix-style cron daemon in that it checks whether a task should be executed once every 60 seconds.
Since:
1.0
Version:
11.1
Author:
Luke
  • Constructor Details

    • TaskScheduler

      public TaskScheduler(Collection<Task> tasks)
      Initializes the Task scheduler with a group of Tasks.
      Parameters:
      tasks - a Collection of Tasks
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addTask

      public void addTask(Task t)
      Schedules a Task for execution.
      Parameters:
      t - the Task to schedule
    • getTask

      public Task getTask(String id)
      Retrieves a Task for manual execution.
      Parameters:
      id - the Task ID
      Returns:
      the Task, or null if not found
    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • setLastRunTime

      public void setLastRunTime(TaskLastRun lr)
      Updates the last execution time and duration of a Scheduled Task.
      Parameters:
      lr - the TaskLastRun bean
    • getTaskInfo

      public Collection<TaskInfo> getTaskInfo()
      Returns the current state of the Task Schedulder.
      Returns:
      a Collection of TaskInfo beans
    • uncaughtException

      public void uncaughtException(Thread t, Throwable e)
      Specified by:
      uncaughtException in interface Thread.UncaughtExceptionHandler