Class PersistentQuartzScheduler

  • All Implemented Interfaces:
    Initialization, Scheduler

    @Service
    @Singleton
    @PersistentScheduling
    public class PersistentQuartzScheduler
    extends QuartzScheduler
    A persistent scheduler implementation using Quartz as scheduling backend. It wraps a Quartz scheduler and delegates to it all of the calls after transforming the parameters into their Quartz counterparts. The Quartz scheduler is configured to use a JDBC Job store instead of a RAM Job store so that all the jobs being scheduled are also persisted and then can be retrieved after a restart of the scheduling backend. Because of the persistence of the jobs and of the triggers, the scheduler mechanism is more weighty and takes more time to fire jobs. This is why such scheduler should be use with care and only for very short-time jobs.
    Author:
    mmoquillon
    • Constructor Detail

      • PersistentQuartzScheduler

        protected PersistentQuartzScheduler()
        Constructs a new persistent scheduler.
    • Method Detail

      • init

        public void init()
        Description copied from interface: Initialization
        Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.
      • release

        public void release()
                     throws Exception
        Description copied from interface: Initialization
        Releases the previously initialized resources at Silverpeas shutdown. The implementation of this method is optional. By default it does nothing.
        Throws:
        Exception - if an error occurs during the shutdown process. In this case, a log will be outputed and the shutdown goes one.
      • encodeJob

        protected String encodeJob​(Job job)
        Description copied from class: QuartzScheduler
        Encodes the specified job into an object ready to be handled by the job executor related to this scheduler. Each type of scheduler has its own way to encode a job in order to be retrieved by the job executor related by the scheduler.
        Specified by:
        encodeJob in class QuartzScheduler
        Parameters:
        job - the job to encode for the job executor related to this scheduler.
        Returns:
        the encoded job.
      • encodeEventListener

        protected String encodeEventListener​(SchedulerEventListener listener)
        Description copied from class: QuartzScheduler
        Encodes the specified scheduler event listener into an object ready to be handled by the job executor related to this scheduler. Each type of scheduler has its own way to encode an event listener in order to be retrieved by the job executor related by the scheduler.
        Specified by:
        encodeEventListener in class QuartzScheduler
        Parameters:
        listener - the event listener to encode for the job executor related to this scheduler.
        Returns:
        the encoded scheduler event listener.
      • execute

        protected <T> void execute​(QuartzScheduler.SchedulingTask<T> schedulingTask)
                            throws org.quartz.SchedulerException
        Description copied from class: QuartzScheduler
        Executes the specified task. The execution of the task is delegated to this method that can wraps the task execution within a peculiar execution context like a transaction for example for persistent jobs.
        Specified by:
        execute in class QuartzScheduler
        Parameters:
        schedulingTask - the scheduling task to execute.
        Throws:
        org.quartz.SchedulerException