com.silverpeas.scheduler.quartz
Class QuartzScheduler

java.lang.Object
  extended by com.silverpeas.scheduler.quartz.QuartzScheduler
All Implemented Interfaces:
Scheduler

@Named(value="scheduler")
public class QuartzScheduler
extends Object
implements Scheduler

A scheduler implementation using Quartz as scheduling backend. It wraps a Quartz scheduler and delegates to it all of the call after transforming the parameters into their Quartz counterparts.


Nested Class Summary
static class QuartzScheduler.QuartzJob
          A job as registered within the Quartz scheduler.
 
Constructor Summary
protected QuartzScheduler()
          Constructs a new scheduler and bootstraps the Quartz scheduler backend.
 
Method Summary
 boolean isJobScheduled(String jobName)
          Is the job identified by the specified name is scheduled by this scheduler?
 ScheduledJob scheduleJob(Job theJob, JobTrigger trigger)
          Schedules the specified job.
 ScheduledJob scheduleJob(Job theJob, JobTrigger trigger, SchedulerEventListener listener)
          Schedules the specified job.
 ScheduledJob scheduleJob(String jobName, JobTrigger trigger, SchedulerEventListener listener)
          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.
 void shutdown()
          Shutdowns this scheduler.
 void unscheduleJob(String jobName)
          Unschedules the job with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuartzScheduler

protected QuartzScheduler()
                   throws SchedulerException
Constructs a new scheduler and bootstraps the Quartz scheduler backend.

Throws:
SchedulerException - if the unerlying Quartz scheduler setting up fails.
Method Detail

scheduleJob

public ScheduledJob scheduleJob(String jobName,
                                JobTrigger trigger,
                                SchedulerEventListener listener)
                         throws SchedulerException
Description copied from interface: Scheduler
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.

Specified by:
scheduleJob in interface Scheduler
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

public ScheduledJob scheduleJob(Job theJob,
                                JobTrigger trigger,
                                SchedulerEventListener listener)
                         throws SchedulerException
Description copied from interface: Scheduler
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.

Specified by:
scheduleJob in interface Scheduler
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

public ScheduledJob scheduleJob(Job theJob,
                                JobTrigger trigger)
                         throws SchedulerException
Description copied from interface: Scheduler
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.

Specified by:
scheduleJob in interface Scheduler
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

public void unscheduleJob(String jobName)
                   throws SchedulerException
Description copied from interface: Scheduler
Unschedules the job with the specified name. If no job is scheduled under the specified name, nothing is done.

Specified by:
unscheduleJob in interface Scheduler
Parameters:
jobName - the name of the job to unschedule.
Throws:
SchedulerException - if the specified job cannot be unscheduled.

isJobScheduled

public boolean isJobScheduled(String jobName)
Description copied from interface: Scheduler
Is the job identified by the specified name is scheduled by this scheduler?

Specified by:
isJobScheduled in interface Scheduler
Parameters:
jobName - the job name.
Returns:
true if the job identified by the specified name is scheduled by this scheduler, false otherwise.

shutdown

public void shutdown()
              throws SchedulerException
Description copied from interface: Scheduler
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.

Specified by:
shutdown in interface Scheduler
Throws:
SchedulerException - if the scheduler shutdown failed.


Copyright © 2016 Silverpeas. All Rights Reserved.