Class SundialJobScheduler

java.lang.Object
org.knowm.sundial.SundialJobScheduler

public class SundialJobScheduler extends Object
Main entry-point to the Sundial scheduler
Author:
timmolter
  • Constructor Details

    • SundialJobScheduler

      public SundialJobScheduler()
  • Method Details

    • startScheduler

      public static void startScheduler() throws SundialSchedulerException
      Starts the Sundial Scheduler
      Throws:
      SundialSchedulerException
    • startScheduler

      public static void startScheduler(int threadPoolSize) throws SundialSchedulerException
      Starts the Sundial Scheduler
      Parameters:
      threadPoolSize -
      Throws:
      SundialSchedulerException
    • startScheduler

      public static void startScheduler(String annotatedJobsPackageName) throws SundialSchedulerException
      Starts the Sundial Scheduler
      Parameters:
      annotatedJobsPackageName - A comma(,) or colon(:) can be used to specify multiple packages to scan for Jobs.
      Throws:
      SundialSchedulerException
    • startScheduler

      public static void startScheduler(int threadPoolSize, String annotatedJobsPackageName) throws SundialSchedulerException
      Starts the Sundial Scheduler
      Parameters:
      threadPoolSize -
      annotatedJobsPackageName - A comma(,) or colon(:) can be used to specify multiple packages to scan for Jobs.
      Throws:
      SundialSchedulerException
    • createScheduler

      public static Scheduler createScheduler(int threadPoolSize, String annotatedJobsPackageName) throws SundialSchedulerException
      Creates the Sundial Scheduler
      Parameters:
      threadPoolSize - the thread pool size used by the scheduler
      annotatedJobsPackageName - A comma(,) or colon(:) can be used to specify multiple packages to scan for Jobs.
      Returns:
      Throws:
      SundialSchedulerException
    • createScheduler

      public static Scheduler createScheduler(SchedulerFactory schedulerFactory) throws SundialSchedulerException
      Creates the Sundial Scheduler
      Parameters:
      schedulerFactory - factory to create the scheduler
      Returns:
      Throws:
      SundialSchedulerException
    • getScheduler

      public static Scheduler getScheduler()
      Gets the underlying Quartz scheduler
      Returns:
    • toggleGlobalLock

      public static void toggleGlobalLock()
    • lockScheduler

      public static void lockScheduler()
    • unlockScheduler

      public static void unlockScheduler()
    • getGlobalLock

      public static boolean getGlobalLock()
    • getServletContext

      public static jakarta.servlet.ServletContext getServletContext()
      Returns:
      the ServletContext
    • setServletContext

      public static void setServletContext(jakarta.servlet.ServletContext servletContext)
      Parameters:
      servletContext - the ServletContext to set
    • addJob

      public static void addJob(String jobName, Class<? extends Job> jobClass) throws SundialSchedulerException
      Adds a Job to the scheduler. Replaces a matching existing Job.
      Parameters:
      jobName -
      jobClass -
      Throws:
      SundialSchedulerException
    • addJob

      public static void addJob(String jobName, String jobClassName) throws SundialSchedulerException
      Adds a Job to the scheduler. Replaces a matching existing Job.
      Parameters:
      jobName -
      jobClassName -
      Throws:
      SundialSchedulerException
    • addJob

      public static void addJob(String jobName, Class<? extends Job> jobClass, Map<String,Object> params, boolean isConcurrencyAllowed) throws SundialSchedulerException
      Adds a Job to the scheduler. Replaces a matching existing Job.
      Parameters:
      jobName -
      jobClass -
      params - Set this null if there are no params
      isConcurrencyAllowed -
      Throws:
      SundialSchedulerException
    • addJob

      public static void addJob(String jobName, String jobClassName, Map<String,Object> params, boolean isConcurrencyAllowed) throws SundialSchedulerException
      Adds a Job to the scheduler. Replaces a matching existing Job.
      Parameters:
      jobName -
      jobClassName -
      params - Set this null if there are no params
      isConcurrencyAllowed -
      Throws:
      SundialSchedulerException
    • startJob

      public static void startJob(String jobName) throws SundialSchedulerException
      Starts a Job matching the given Job Name
      Parameters:
      jobName -
      Throws:
      SundialSchedulerException
    • removeJob

      public static void removeJob(String jobName) throws SundialSchedulerException
      Removes a Job matching the given Job Name
      Parameters:
      jobName -
      Throws:
      SundialSchedulerException
    • startJob

      public static void startJob(String jobName, Map<String,Object> params) throws SundialSchedulerException
      Starts a Job matching the the given Job Name found in jobs.xml or jobs manually added.
      Parameters:
      jobName -
      Throws:
      SundialSchedulerException
    • stopJob

      public static void stopJob(String jobName) throws SundialSchedulerException
      Triggers a Job interrupt on all Jobs matching the given Job Name. The Job termination mechanism works by setting a flag that the Job should be terminated, but it is up to the logic in the Job to decide at what point termination should occur. Therefore, in any long-running job that you anticipate the need to terminate, put the method call checkTerminated() at an appropriate location.
      Parameters:
      jobName - The job name
      Throws:
      SundialSchedulerException
    • stopJob

      public static void stopJob(String jobName, String key, String pValue) throws SundialSchedulerException
      Triggers a Job interrupt on all Jobs matching the given Job Name, key and (String) value. Doesn't work if the value is not a String. The Job termination mechanism works by setting a flag that the Job should be terminated, but it is up to the logic in the Job to decide at what point termination should occur. Therefore, in any long-running job that you anticipate the need to terminate, put the method call checkTerminated() at an appropriate location.
      Parameters:
      jobName - The job name
      key - The key in the job data map
      pValue - The value in the job data map
      Throws:
      SundialSchedulerException
    • addCronTrigger

      public static void addCronTrigger(String triggerName, String jobName, String cronExpression) throws SundialSchedulerException
      Parameters:
      triggerName -
      jobName -
      cronExpression -
      Throws:
      SundialSchedulerException
    • addCronTrigger

      public static void addCronTrigger(String triggerName, String jobName, String cronExpression, Date startTime, Date endTime) throws SundialSchedulerException
      Parameters:
      triggerName -
      jobName -
      cronExpression -
      startTime - - Trigger will NOT fire before this time, regardless of the Trigger's schedule.
      endTime - - Set the time at which the Trigger will no longer fire - even if it's schedule has remaining repeats. If null, the end time is indefinite.
      Throws:
      SundialSchedulerException
    • addSimpleTrigger

      public static void addSimpleTrigger(String triggerName, String jobName, int repeatCount, long repeatInterval) throws SundialSchedulerException
      Parameters:
      triggerName -
      jobName -
      repeatCount - - set to -1 to repeat indefinitely
      repeatInterval -
      Throws:
      SundialSchedulerException
    • addSimpleTrigger

      public static void addSimpleTrigger(String triggerName, String jobName, int repeatCount, long repeatInterval, Date startTime, Date endTime) throws SundialSchedulerException
      Parameters:
      triggerName -
      jobName -
      repeatCount - - set to -1 to repeat indefinitely
      repeatInterval -
      startTime -
      endTime -
      Throws:
      SundialSchedulerException
    • removeTrigger

      public static void removeTrigger(String triggerName) throws SundialSchedulerException
      Removes a Trigger matching the the given Trigger Name
      Parameters:
      triggerName -
      Throws:
      SundialSchedulerException
    • getAllJobNames

      public static List<String> getAllJobNames() throws SundialSchedulerException
      Generates an alphabetically sorted List of all Job names in the DEFAULT job group
      Returns:
      Throws:
      SundialSchedulerException
    • getAllJobsAndTriggers

      public static Map<String,List<Trigger>> getAllJobsAndTriggers() throws SundialSchedulerException
      Generates a Map of all Job names with corresponding Triggers
      Returns:
      Throws:
      SundialSchedulerException
    • isJobRunning

      public static boolean isJobRunning(String jobName) throws SundialSchedulerException
      Throws:
      SundialSchedulerException
    • shutdown

      public static void shutdown() throws SundialSchedulerException
      Halts the Scheduler's firing of Triggers, and cleans up all resources associated with the Scheduler.
      Throws:
      SundialSchedulerException