Package com.avoka.fc.core.service
Class SchedulerService
java.lang.Object
com.avoka.fc.core.service.BaseService
com.avoka.fc.core.service.SchedulerService
Provides a schedule service.
This service provides schedule jobs handling with the quartz library.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSchedulerService(org.quartz.Scheduler scheduler) Create a scheduler service given a scheduler. -
Method Summary
Modifier and TypeMethodDescriptionvoidGo through the existing TM cron triggers and adjust their timezone.booleanDelete the job for the given name, return true if the job was found.static SchedulerServiceReturn the singleton instance of the scheduler service.getJobAndTrigger(String jobName) Return the Job and Trigger for the given job namegetJobAndTrigger(String jobName, String groupName) Return the Job and Trigger for the given job nameReturn the list of JobDetail and Trigger associations.org.quartz.JobDetailgetJobDetail(String jobName) Return the JobDetail for the given name.org.quartz.JobDetailgetJobDetail(String jobName, String groupName) Return the JobDetail for the given name.List<org.quartz.JobDetail> Return the list of scheduled JobDetails for the group name: "fc-group".org.quartz.SchedulerReturn the scheduler instance.booleanReturn true if the scheduler has the named job.booleanReturn true if the scheduler has the named job.booleaninterruptJob(String jobName) Interrupt the job for the given name, return true if the job was found.booleanisJobExecuting(String jobName) Return true if any job with the specified job name is currently executing.booleanisPaused()Return true if the scheduler is paused.voidpauseAll()Pause all the scheduled jobs, and interrupt any currently executing jobs.voidPause the job for the given name.voidResume all paused jobs.voidResume the job for the given name.scheduleCronJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, String cronExpression) Perform a schedule cron jobscheduleSimpleJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, int repeatCount, long repeatInterval) Schedule a simple jobvoidsetScheduler(org.quartz.Scheduler scheduler) Sets the scheduler.voidtriggerJob(String jobName) Trigger the job for the given name.voidtriggerJob(String jobName, String groupName) Trigger the job for the given name.Methods inherited from class com.avoka.fc.core.service.BaseService
getLogger
-
Field Details
-
FC_GROUP_NAME
The group name for TM jobs- See Also:
-
-
Constructor Details
-
SchedulerService
public SchedulerService(org.quartz.Scheduler scheduler) Create a scheduler service given a scheduler.- Parameters:
scheduler- the scheduler
-
-
Method Details
-
getInstance
Return the singleton instance of the scheduler service.- Returns:
- the singleton instance of the scheduler service
-
getScheduler
public org.quartz.Scheduler getScheduler()Return the scheduler instance.- Returns:
- the scheduler instance
-
setScheduler
public void setScheduler(org.quartz.Scheduler scheduler) Sets the scheduler.- Parameters:
scheduler- the new scheduler
-
scheduleSimpleJob
public Date scheduleSimpleJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, int repeatCount, long repeatInterval) Schedule a simple job- Parameters:
jobDetail- job detailsstartDate- start date of the jobendDate- end date of the jobrepeatCount- the repeat countrepeatInterval- the repeat interval- Returns:
- the schedule date
-
scheduleCronJob
public Date scheduleCronJob(org.quartz.JobDetail jobDetail, Date startDate, Date endDate, String cronExpression) Perform a schedule cron job- Parameters:
jobDetail- job detailsstartDate- start date of the jobendDate- end date of the jobcronExpression- the cron expression for this cron job- Returns:
- the schedule date
-
isPaused
public boolean isPaused()Return true if the scheduler is paused.- Returns:
- true if the scheduler is paused
-
isJobExecuting
Return true if any job with the specified job name is currently executing.- Parameters:
jobName- the name of the job- Returns:
- true if any job with the specified job name is currently executing
- Since:
- 4.1.0
-
pauseAll
public void pauseAll()Pause all the scheduled jobs, and interrupt any currently executing jobs. -
resumeAll
public void resumeAll()Resume all paused jobs. -
pauseJob
Pause the job for the given name.- Parameters:
jobName- the name of the job to pause
-
resumeJob
Resume the job for the given name.- Parameters:
jobName- the name of the job to resume
-
triggerJob
Trigger the job for the given name.- Parameters:
jobName- the name of the job to trigger
-
triggerJob
Trigger the job for the given name.- Parameters:
jobName- the name of the job to triggergroupName- the name of the group the job belongs to- Since:
- 4.2.0
-
interruptJob
Interrupt the job for the given name, return true if the job was found.- Parameters:
jobName- the name of the job to interrupt- Returns:
- true if the job was found and interrupted.
-
deleteJob
Delete the job for the given name, return true if the job was found.- Parameters:
jobName- the name of the job to delete- Returns:
- true if the Job was found and deleted.
-
getJobDetailList
Return the list of scheduled JobDetails for the group name: "fc-group".- Returns:
- the list of scheduled JobDetails for the group name: "fc-group"
- See Also:
-
getJobDetail
Return the JobDetail for the given name.- Parameters:
jobName- the job name- Returns:
- the JobDetail for the given name
-
getJobDetail
Return the JobDetail for the given name.- Parameters:
jobName- the job namegroupName- the group name- Returns:
- the JobDetail for the given name and group
- Since:
- 4.2.0
-
hasJob
Return true if the scheduler has the named job.- Parameters:
jobName- the name of the job- Returns:
- true if the scheduler has the named job
-
hasJob
Return true if the scheduler has the named job.- Parameters:
jobName- the name of the jobgroupName- the name of the job group- Returns:
- true if the scheduler has the named job
-
getJobAndTriggerList
Return the list of JobDetail and Trigger associations.- Returns:
- the list of JobDetail and Trigger associations
-
getJobAndTrigger
Return the Job and Trigger for the given job name- Parameters:
jobName- the name of the job- Returns:
- the Job and Trigger for the given job name
-
getJobAndTrigger
Return the Job and Trigger for the given job name- Parameters:
jobName- the name of the job (required)groupName- the group the job belongs to (required)- Returns:
- the Job and Trigger for the given job name
- Since:
- 4.2.0
-
adjustTriggerTimezones
public void adjustTriggerTimezones()Go through the existing TM cron triggers and adjust their timezone. This is needed if the system timezone has changed to avoid existing jobs being scheduled at inappropriate times.- Since:
- 4.2.0
-