Class SchedulerService

java.lang.Object
com.eurodyn.qlack.fuse.scheduler.service.SchedulerService

@Transactional @Service public class SchedulerService extends Object
Provides scheduler administration functionality
Author:
European Dynamics SA.
  • Constructor Details

    • SchedulerService

      @Autowired public SchedulerService(org.quartz.Scheduler scheduler)
  • Method Details

    • getJobName

      public static <J extends org.quartz.Job> String getJobName(Class<J> jobClass)
      A helper method to define the name of a job based on the class implementing the job.
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - the class implementing the job
      Returns:
      the name of the job
    • getTriggerName

      public static <J extends org.quartz.Job> String getTriggerName(Class<J> jobClass)
      A helper method to define the name of a trigger based on the class implementing the job.
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - the class implementing the job.
      Returns:
      returns the name of the trigger
    • getSchedulerName

      public String getSchedulerName()
      Retrieves the name of the Quartz scheduler instance used in the application
      Returns:
      the name of the Quartz scheduler instance
    • getSchedulerInstanceID

      public String getSchedulerInstanceID()
      Retrieves the id of the of the Quartz scheduler instance used in the application
      Returns:
      the id of the Quartz scheduler instance
    • start

      public void start()
      Starts the Quartz scheduler instance
    • shutdown

      public void shutdown()
      Terminates the Quartz scheduler instance
    • standby

      public void standby()
      Pauses the Quartz scheduler instance
    • isStarted

      public boolean isStarted()
      Checks if the Quartz Scheduler instance has started
      Returns:
      true if started, false otherwise
    • isShutdown

      public boolean isShutdown()
      Checks if the Quartz Scheduler instance has been terminated
      Returns:
      true if terminated, false otherwise
    • isInStandbyMode

      public boolean isInStandbyMode()
      Checks if the Quartz Scheduler instance is in standby mode
      Returns:
      true if paused, false otherwise
    • registerJob

      public <J extends org.quartz.Job> void registerJob(Class<J> jobClass)
      Registers a job to the scheduler's list of jobs. A registered job, should be scheduled manually.
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
    • registerJob

      public <J extends org.quartz.Job> void registerJob(Class<J> jobClass, Map<String,Object> jobData)
      Registers a job to the scheduler's list of jobs. A registered job, should be scheduled manually.
      Type Parameters:
      J - the Job Object to access on execution
      Parameters:
      jobClass - a class implementing the Job interface
      jobData - a map containing any number of serializable objects, that the job will be able
    • scheduleJob

      public <J extends org.quartz.Job> void scheduleJob(Class<J> jobClass, String cronExpression)
      Schedules a job for execution
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the job interface
      cronExpression - a cron expression defining the execution interval of the job
    • scheduleJob

      public <J extends org.quartz.Job> void scheduleJob(Class<J> jobClass, String cronExpression, Map<String,Object> jobData)
      Schedules a job for execution
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the job interface
      cronExpression - a cron expression defining the execution interval of the job
      jobData - a map containing any number of serializable objects, that the job will be able to access on execution
    • rescheduleJob

      public <J extends org.quartz.Job> void rescheduleJob(Class<J> jobClass, String cronExpression)
      Reschedules a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the job interface
      cronExpression - a cron expression defining the execution interval of the job
    • deleteJob

      public boolean deleteJob(String jobName)
      Deletes a scheduled job
      Parameters:
      jobName - The class name of the job to delete
      Returns:
      true if job has been deleted, false otherwise
    • deleteJobs

      public boolean deleteJobs(List<String> jobNames)
      Deletes multiple jobs
      Parameters:
      jobNames - a list containing the job names to delete
      Returns:
      true if all jobs have been deleted, false otherwise
    • triggerJob

      public <J extends org.quartz.Job> void triggerJob(Class<J> jobClass)
      Triggers the execution of a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
    • triggerJob

      public <J extends org.quartz.Job> void triggerJob(Class<J> jobClass, Map<String,Object> jobData)
      Triggers the execution of a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
      jobData - a map containing any number of serializable objects, that the job will be able to access on execution
    • pauseJob

      public <J extends org.quartz.Job> void pauseJob(Class<J> jobClass)
      Pauses all future executions of a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
    • pauseAllTriggers

      public void pauseAllTriggers()
      Pauses all triggers
    • resumeAllTriggers

      public void resumeAllTriggers()
      Resumes all triggers
    • clear

      public void clear()
      Clears all scheduled jobs
    • getNextFireForJob

      public <J extends org.quartz.Job> Date getNextFireForJob(Class<J> jobClass)
      Finds the next execution of a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
      Returns:
      the job's next execution date
    • getPreviousFireForJob

      public <J extends org.quartz.Job> Date getPreviousFireForJob(Class<J> jobClass)
      Finds the previous execution time of a job
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
      Returns:
      the job's previous execution date
    • isJobExisting

      public <J extends org.quartz.Job> boolean isJobExisting(Class<J> jobClass)
      Checks if a job exists
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
      Returns:
      true if exists, false otherwise
    • isTriggerExisting

      public <J extends org.quartz.Job> boolean isTriggerExisting(Class<J> jobClass)
      Checks if a trigger exists
      Type Parameters:
      J - the Job Object
      Parameters:
      jobClass - a class implementing the Job interface
      Returns:
      true if exists, false otherwise
    • getCurrentlyExecutingJobsNames

      public List<String> getCurrentlyExecutingJobsNames()
      Finds all jobs that are currently executed
      Returns:
      a list with the names of the jobs
    • getJobInfo

      public List<JobDTO> getJobInfo()
      Collects information about all existing jobs. The information collected is the job's name, group and next execution date
      Returns:
      a list of JobDTO containing the information about each job