org.springframework.scheduling.quartz
Class SchedulerAccessor

java.lang.Object
  extended by org.springframework.scheduling.quartz.SchedulerAccessor
All Implemented Interfaces:
Aware, ResourceLoaderAware
Direct Known Subclasses:
SchedulerAccessorBean, SchedulerFactoryBean

public abstract class SchedulerAccessor
extends Object
implements ResourceLoaderAware

Common base class for accessing a Quartz Scheduler, i.e. for registering jobs, triggers and listeners on a Scheduler instance.

For concrete usage, check out the SchedulerFactoryBean and SchedulerAccessorBean classes.

Compatible with Quartz 1.5+ as well as Quartz 2.0/2.1, as of Spring 3.1.

Since:
2.5.6
Author:
Juergen Hoeller

Field Summary
protected  Log logger
           
protected  ResourceLoader resourceLoader
           
 
Constructor Summary
SchedulerAccessor()
           
 
Method Summary
protected abstract  Scheduler getScheduler()
          Template method that determines the Scheduler to operate on.
protected  void registerJobsAndTriggers()
          Register jobs and triggers (within a transaction, if possible).
protected  void registerListeners()
          Register all specified listeners with the Scheduler.
 void setCalendars(Map<String,Calendar> calendars)
          Register a list of Quartz Calendar objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.
 void setGlobalJobListeners(JobListener[] globalJobListeners)
          Specify global Quartz JobListeners to be registered with the Scheduler.
 void setGlobalTriggerListeners(TriggerListener[] globalTriggerListeners)
          Specify global Quartz TriggerListeners to be registered with the Scheduler.
 void setJobDetails(JobDetail[] jobDetails)
          Register a list of JobDetail objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.
 void setJobListeners(JobListener[] jobListeners)
          Specify named Quartz JobListeners to be registered with the Scheduler.
 void setJobSchedulingDataLocation(String jobSchedulingDataLocation)
          Set the location of a Quartz job definition XML file that follows the "job_scheduling_data_1_5" XSD.
 void setJobSchedulingDataLocations(String[] jobSchedulingDataLocations)
          Set the locations of Quartz job definition XML files that follow the "job_scheduling_data_1_5" XSD.
 void setOverwriteExistingJobs(boolean overwriteExistingJobs)
          Set whether any jobs defined on this SchedulerFactoryBean should overwrite existing job definitions.
 void setResourceLoader(ResourceLoader resourceLoader)
          Set the ResourceLoader that this object runs in.
 void setSchedulerListeners(SchedulerListener[] schedulerListeners)
          Specify Quartz SchedulerListeners to be registered with the Scheduler.
 void setTransactionManager(PlatformTransactionManager transactionManager)
          Set the transaction manager to be used for registering jobs and triggers that are defined by this SchedulerFactoryBean.
 void setTriggerListeners(TriggerListener[] triggerListeners)
          Specify named Quartz TriggerListeners to be registered with the Scheduler.
 void setTriggers(Trigger[] triggers)
          Register a list of Trigger objects with the Scheduler that this FactoryBean creates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger

resourceLoader

protected ResourceLoader resourceLoader
Constructor Detail

SchedulerAccessor

public SchedulerAccessor()
Method Detail

setOverwriteExistingJobs

public void setOverwriteExistingJobs(boolean overwriteExistingJobs)
Set whether any jobs defined on this SchedulerFactoryBean should overwrite existing job definitions. Default is "false", to not overwrite already registered jobs that have been read in from a persistent job store.


setJobSchedulingDataLocation

public void setJobSchedulingDataLocation(String jobSchedulingDataLocation)
Set the location of a Quartz job definition XML file that follows the "job_scheduling_data_1_5" XSD. Can be specified to automatically register jobs that are defined in such a file, possibly in addition to jobs defined directly on this SchedulerFactoryBean.

See Also:
JobSchedulingDataProcessor

setJobSchedulingDataLocations

public void setJobSchedulingDataLocations(String[] jobSchedulingDataLocations)
Set the locations of Quartz job definition XML files that follow the "job_scheduling_data_1_5" XSD. Can be specified to automatically register jobs that are defined in such files, possibly in addition to jobs defined directly on this SchedulerFactoryBean.

See Also:
JobSchedulingDataProcessor

setJobDetails

public void setJobDetails(JobDetail[] jobDetails)
Register a list of JobDetail objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.

This is not necessary when a Trigger determines the JobDetail itself: In this case, the JobDetail will be implicitly registered in combination with the Trigger.

See Also:
setTriggers(org.quartz.Trigger[]), JobDetail, JobDetailBean, JobDetailAwareTrigger, Trigger.setJobName(java.lang.String)

setCalendars

public void setCalendars(Map<String,Calendar> calendars)
Register a list of Quartz Calendar objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.

Parameters:
calendars - Map with calendar names as keys as Calendar objects as values
See Also:
Calendar, Trigger.setCalendarName(java.lang.String)

setTriggers

public void setTriggers(Trigger[] triggers)
Register a list of Trigger objects with the Scheduler that this FactoryBean creates.

If the Trigger determines the corresponding JobDetail itself, the job will be automatically registered with the Scheduler. Else, the respective JobDetail needs to be registered via the "jobDetails" property of this FactoryBean.

See Also:
setJobDetails(org.quartz.JobDetail[]), JobDetail, JobDetailAwareTrigger, CronTriggerBean, SimpleTriggerBean

setSchedulerListeners

public void setSchedulerListeners(SchedulerListener[] schedulerListeners)
Specify Quartz SchedulerListeners to be registered with the Scheduler.


setGlobalJobListeners

public void setGlobalJobListeners(JobListener[] globalJobListeners)
Specify global Quartz JobListeners to be registered with the Scheduler. Such JobListeners will apply to all Jobs in the Scheduler.


setJobListeners

public void setJobListeners(JobListener[] jobListeners)
Specify named Quartz JobListeners to be registered with the Scheduler. Such JobListeners will only apply to Jobs that explicitly activate them via their name.

See Also:
JobListener.getName(), JobDetail.addJobListener(java.lang.String), JobDetailBean.setJobListenerNames(java.lang.String[])

setGlobalTriggerListeners

public void setGlobalTriggerListeners(TriggerListener[] globalTriggerListeners)
Specify global Quartz TriggerListeners to be registered with the Scheduler. Such TriggerListeners will apply to all Triggers in the Scheduler.


setTriggerListeners

public void setTriggerListeners(TriggerListener[] triggerListeners)
Specify named Quartz TriggerListeners to be registered with the Scheduler. Such TriggerListeners will only apply to Triggers that explicitly activate them via their name.

See Also:
TriggerListener.getName(), Trigger.addTriggerListener(java.lang.String), CronTriggerBean.setTriggerListenerNames(java.lang.String[]), SimpleTriggerBean.setTriggerListenerNames(java.lang.String[])

setTransactionManager

public void setTransactionManager(PlatformTransactionManager transactionManager)
Set the transaction manager to be used for registering jobs and triggers that are defined by this SchedulerFactoryBean. Default is none; setting this only makes sense when specifying a DataSource for the Scheduler.


setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Description copied from interface: ResourceLoaderAware
Set the ResourceLoader that this object runs in.

This might be a ResourcePatternResolver, which can be checked through instanceof ResourcePatternResolver. See also the ResourcePatternUtils.getResourcePatternResolver method.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

Specified by:
setResourceLoader in interface ResourceLoaderAware
Parameters:
resourceLoader - ResourceLoader object to be used by this object
See Also:
ResourcePatternResolver, ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)

registerJobsAndTriggers

protected void registerJobsAndTriggers()
                                throws SchedulerException
Register jobs and triggers (within a transaction, if possible).

Throws:
SchedulerException

registerListeners

protected void registerListeners()
                          throws SchedulerException
Register all specified listeners with the Scheduler.

Throws:
SchedulerException

getScheduler

protected abstract Scheduler getScheduler()
Template method that determines the Scheduler to operate on. To be implemented by subclasses.