Interface Scheduler

  • All Known Implementing Classes:
    PersistentQuartzScheduler, QuartzScheduler, VolatileQuartScheduler

    public interface Scheduler
    It is the main interface of a Silverpeas scheduler. It provides the features needed by Silverpeas components to schedule some jobs at given moments in time or at regular time. A Scheduler object should maintain a registry of Job and Trigger instances. Once registered, the scheduler is responsible for executing the jobs when their associated trigger fires (when their scheduled time arrives). A job can be executed in a two ways: by an event listener at trigger firing event reception or by a Job object carrying the operation to run. A listener of scheduler's events can be specified at job registering to handle, for example, the status of the job execution or to perform some non-business operations out of the job. Scheduler instances are produced by a SchedulerFactory that encapsulates the actual backend used to implement the scheduling system. Whatever the instances returned by the factory, they share a single entry point to the scheduling backend so that a job scheduled with an instance can be found with another one.
    • Method Detail

      • scheduleJob

        ScheduledJob scheduleJob​(String jobName,
                                 JobTrigger trigger,
                                 SchedulerEventListener listener)
                          throws SchedulerException
        Schedules a job under the specified name, that will be fired with the specified trigger, and by setting the specified listener to recieve the events mapped with the job execution state. A scheduled job will be registered in the scheduler under the specified name and its execution will be fired by the specified trigger. The computation of the job will be delegated to the event listener when the associated trigger fires (it will recieve the event mapped with this trigger firing). If a job is already scheduled under the specified name, then a SchedulerException exception is thrown.
        Parameters:
        jobName - the name under which the job should be registered in this scheduler.
        trigger - the trigger that will command the job execution in the timeline.
        listener - a listener of scheduler's events. It will recieve the different events fired by the scheduler and mapped with the job execution state. It is expected it will accomplish the job itself at trigger firing. It is required.
        Returns:
        the job scheduled in the scheduler.
        Throws:
        SchedulerException - if either a job is already scheduled under the specified name or if the job scheduling fails.
      • scheduleJob

        ScheduledJob scheduleJob​(Job theJob,
                                 JobTrigger trigger,
                                 SchedulerEventListener listener)
                          throws SchedulerException
        Schedules the specified job. It will be fired with the specified trigger and the specified event listener will recieve the events mapped with the state of the job execution. The specified job will be registered as a scheduled job in the scheduler under its name and its execution will be fired by the specified trigger. In the case an event listener is specified, it will recieve the events mapped with the state of the job execution. If a job is already scheduled under the same name of the specified job, then a SchedulerException exception is thrown.
        Parameters:
        theJob - the job to schedule.
        trigger - the trigger that will fire the job execution.
        listener - a listener of scheduler's events mapped with the state of the job execution. Null means no listener to register with the job.
        Returns:
        the job scheduled in the scheduler.
        Throws:
        SchedulerException - if either a job is already scheduled under the same name that the specified job or if the job scheduling fails.
      • scheduleJob

        ScheduledJob scheduleJob​(Job theJob,
                                 JobTrigger trigger)
                          throws SchedulerException
        Schedules the specified job. It will be fired with the specified trigger. The specified job will be registered as a scheduled job in the scheduler under its name and its execution will be fired by the specified trigger. If a job is already scheduled under the same name of the specified job, then a SchedulerException exception is thrown.
        Parameters:
        theJob - the job to schedule.
        trigger - the trigger that will fire the job execution.
        Returns:
        the job scheduled in the scheduler.
        Throws:
        SchedulerException - if either a job is already scheduled under the same name that the specified job or if the job scheduling fails.
      • unscheduleJob

        void unscheduleJob​(String jobName)
                    throws SchedulerException
        Unschedules the job with the specified name. If no job is scheduled under the specified name, nothing is done.
        Parameters:
        jobName - the name of the job to unschedule.
        Throws:
        SchedulerException - if the specified job cannot be unscheduled.
      • isJobScheduled

        boolean isJobScheduled​(String jobName)
        Is the job identified by the specified name is scheduled by this scheduler?
        Parameters:
        jobName - the job name.
        Returns:
        true if the job identified by the specified name is scheduled by this scheduler, false otherwise.
      • getScheduledJob

        Optional<ScheduledJob> getScheduledJob​(String jobName)
        Gets detail about the job that was scheduled under the specified name.
        Parameters:
        jobName - a name of a scheduled job.
        Returns:
        optionally the scheduled job or nothing if no such job is scheduled.
      • shutdown

        void shutdown()
               throws SchedulerException
        Shutdowns this scheduler. The firing of triggers are halted and the jobs removed. All of the resources are cleaned up. Once shutdown done, the scheduler cannot be restarted and used for scheduling new jobs.
        Throws:
        SchedulerException - if the scheduler shutdown failed.