Class SchedulerService


  • public class SchedulerService
    extends BaseService
    Provides a schedule service.

    This service provides schedule jobs handling with the quartz library.

    • Constructor Detail

      • SchedulerService

        public SchedulerService​(org.quartz.Scheduler scheduler)
        Create a scheduler service given a scheduler.
        Parameters:
        scheduler - the scheduler
    • Method Detail

      • getInstance

        public static SchedulerService 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 details
        startDate - start date of the job
        endDate - end date of the job
        repeatCount - the repeat count
        repeatInterval - 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 details
        startDate - start date of the job
        endDate - end date of the job
        cronExpression - 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

        public boolean isJobExecuting​(String jobName)
        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

        public void pauseJob​(String jobName)
        Pause the job for the given name.
        Parameters:
        jobName - the name of the job to pause
      • resumeJob

        public void resumeJob​(String jobName)
        Resume the job for the given name.
        Parameters:
        jobName - the name of the job to resume
      • triggerJob

        public void triggerJob​(String jobName)
        Trigger the job for the given name.
        Parameters:
        jobName - the name of the job to trigger
      • triggerJob

        public void triggerJob​(String jobName,
                               String groupName)
        Trigger the job for the given name.
        Parameters:
        jobName - the name of the job to trigger
        groupName - the name of the group the job belongs to
        Since:
        4.2.0
      • interruptJob

        public boolean interruptJob​(String jobName)
        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

        public boolean deleteJob​(String jobName)
        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

        public List<org.quartz.JobDetail> 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:
        JobDetail
      • getJobDetail

        public org.quartz.JobDetail getJobDetail​(String jobName)
        Return the JobDetail for the given name.
        Parameters:
        jobName - the job name
        Returns:
        the JobDetail for the given name
      • getJobDetail

        public org.quartz.JobDetail getJobDetail​(String jobName,
                                                 String groupName)
        Return the JobDetail for the given name.
        Parameters:
        jobName - the job name
        groupName - the group name
        Returns:
        the JobDetail for the given name and group
        Since:
        4.2.0
      • hasJob

        public boolean hasJob​(String jobName)
        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

        public boolean hasJob​(String jobName,
                              String groupName)
        Return true if the scheduler has the named job.
        Parameters:
        jobName - the name of the job
        groupName - the name of the job group
        Returns:
        true if the scheduler has the named job
      • getJobAndTriggerList

        public List<JobAndTrigger> getJobAndTriggerList()
        Return the list of JobDetail and Trigger associations.
        Returns:
        the list of JobDetail and Trigger associations
      • getJobAndTrigger

        public JobAndTrigger getJobAndTrigger​(String jobName)
        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

        public JobAndTrigger getJobAndTrigger​(String jobName,
                                              String groupName)
        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