Package org.knowm.sundial
Class SundialJobScheduler
java.lang.Object
org.knowm.sundial.SundialJobScheduler
Main entry-point to the Sundial scheduler
- Author:
- timmolter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCronTrigger(String triggerName, String jobName, String cronExpression) static voidaddCronTrigger(String triggerName, String jobName, String cronExpression, Date startTime, Date endTime) static voidAdds a Job to the scheduler.static voidaddJob(String jobName, Class<? extends Job> jobClass, Map<String, Object> params, boolean isConcurrencyAllowed) Adds a Job to the scheduler.static voidAdds a Job to the scheduler.static voidaddJob(String jobName, String jobClassName, Map<String, Object> params, boolean isConcurrencyAllowed) Adds a Job to the scheduler.static voidaddSimpleTrigger(String triggerName, String jobName, int repeatCount, long repeatInterval) static voidaddSimpleTrigger(String triggerName, String jobName, int repeatCount, long repeatInterval, Date startTime, Date endTime) static SchedulercreateScheduler(int threadPoolSize, String annotatedJobsPackageName) Creates the Sundial Schedulerstatic SchedulercreateScheduler(SchedulerFactory schedulerFactory) Creates the Sundial SchedulerGenerates an alphabetically sorted List of all Job names in the DEFAULT job groupGenerates a Map of all Job names with corresponding Triggersstatic booleanstatic SchedulerGets the underlying Quartz schedulerstatic jakarta.servlet.ServletContextstatic booleanisJobRunning(String jobName) static voidstatic voidRemoves a Job matching the given Job Namestatic voidremoveTrigger(String triggerName) Removes a Trigger matching the the given Trigger Namestatic voidsetServletContext(jakarta.servlet.ServletContext servletContext) static voidshutdown()Halts the Scheduler's firing of Triggers, and cleans up all resources associated with the Scheduler.static voidStarts a Job matching the given Job Namestatic voidStarts a Job matching the the given Job Name found in jobs.xml or jobs manually added.static voidStarts the Sundial Schedulerstatic voidstartScheduler(int threadPoolSize) Starts the Sundial Schedulerstatic voidstartScheduler(int threadPoolSize, String annotatedJobsPackageName) Starts the Sundial Schedulerstatic voidstartScheduler(String annotatedJobsPackageName) Starts the Sundial Schedulerstatic voidTriggers a Job interrupt on all Jobs matching the given Job Name.static voidTriggers a Job interrupt on all Jobs matching the given Job Name, key and (String) value.static voidstatic void
-
Constructor Details
-
SundialJobScheduler
public SundialJobScheduler()
-
-
Method Details
-
startScheduler
Starts the Sundial Scheduler- Throws:
SundialSchedulerException
-
startScheduler
Starts the Sundial Scheduler- Parameters:
threadPoolSize-- Throws:
SundialSchedulerException
-
startScheduler
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 schedulerannotatedJobsPackageName- 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
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
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 SundialSchedulerExceptionAdds a Job to the scheduler. Replaces a matching existing Job.- Parameters:
jobName-jobClass-params- Set this null if there are no paramsisConcurrencyAllowed-- Throws:
SundialSchedulerException
-
addJob
public static void addJob(String jobName, String jobClassName, Map<String, Object> params, boolean isConcurrencyAllowed) throws SundialSchedulerExceptionAdds a Job to the scheduler. Replaces a matching existing Job.- Parameters:
jobName-jobClassName-params- Set this null if there are no paramsisConcurrencyAllowed-- Throws:
SundialSchedulerException
-
startJob
Starts a Job matching the given Job Name- Parameters:
jobName-- Throws:
SundialSchedulerException
-
removeJob
Removes a Job matching the given Job Name- Parameters:
jobName-- Throws:
SundialSchedulerException
-
startJob
public static void startJob(String jobName, Map<String, Object> params) throws SundialSchedulerExceptionStarts a Job matching the the given Job Name found in jobs.xml or jobs manually added.- Parameters:
jobName-- Throws:
SundialSchedulerException
-
stopJob
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 namekey- The key in the job data mappValue- 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 indefinitelyrepeatInterval-- 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 indefinitelyrepeatInterval-startTime-endTime-- Throws:
SundialSchedulerException
-
removeTrigger
Removes a Trigger matching the the given Trigger Name- Parameters:
triggerName-- Throws:
SundialSchedulerException
-
getAllJobNames
Generates an alphabetically sorted List of all Job names in the DEFAULT job group- Returns:
- Throws:
SundialSchedulerException
-
getAllJobsAndTriggers
Generates a Map of all Job names with corresponding Triggers- Returns:
- Throws:
SundialSchedulerException
-
isJobRunning
- Throws:
SundialSchedulerException
-
shutdown
Halts the Scheduler's firing of Triggers, and cleans up all resources associated with the Scheduler.- Throws:
SundialSchedulerException
-