Top Description Fields Constructors Methods
org.springframework.scheduling.quartz

public abstract Class SchedulerAccessor

extends Object
implements ResourceLoaderAware
Class Inheritance
All Implemented Interfaces
org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.Aware
Known Direct Subclasses
org.springframework.scheduling.quartz.SchedulerAccessorBean, org.springframework.scheduling.quartz.SchedulerFactoryBean
Imports
java.util.ArrayList, .Arrays, .List, .Map, org.apache.commons.logging.Log, .LogFactory, org.quartz.Calendar, org.quartz.JobDetail, org.quartz.JobListener, org.quartz.ListenerManager, org.quartz.ObjectAlreadyExistsException, org.quartz.Scheduler, org.quartz.SchedulerException, org.quartz.SchedulerListener, org.quartz.Trigger, org.quartz.TriggerListener, org.quartz.spi.ClassLoadHelper, org.quartz.xml.XMLSchedulingDataProcessor, org.springframework.context.ResourceLoaderAware, org.springframework.core.io.ResourceLoader, org.springframework.lang.Nullable, org.springframework.transaction.PlatformTransactionManager, .TransactionDefinition, .TransactionException, .TransactionStatus

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

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

Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.

Authors
Juergen Hoeller, Stephane Nicoll
Since
2.5.6

Field Summary

Modifier and TypeField and Description
private Map<String, org.quartz.Calendar>
private org.quartz.JobListener[]
private org.quartz.TriggerListener[]
private List<org.quartz.JobDetail>
private String[]
protected final Log
private boolean
protected ResourceLoader
private org.quartz.SchedulerListener[]
private PlatformTransactionManager
private List<org.quartz.Trigger>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true if the job was actually added, false if it already existed before
addJobToScheduler
(org.quartz.JobDetail
the job to add
jobDetail
)

Add the given job to the Scheduler, if it doesn't already exist.

private boolean

Returns:

true if the trigger was actually added, false if it already existed before
addTriggerToScheduler
(org.quartz.Trigger
the trigger to add
trigger
)

Add the given trigger to the Scheduler, if it doesn't already exist.

protected abstract org.quartz.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.

public void
setCalendars(Map<String, org.quartz.Calendar>
a Map with calendar names as keys as Calendar objects as values
calendars
)

Register a list of Quartz Calendar objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.

public void
setGlobalJobListeners(org.quartz.JobListener... globalJobListeners)

Specify global Quartz JobListeners to be registered with the Scheduler.

public void
setGlobalTriggerListeners(org.quartz.TriggerListener... globalTriggerListeners)

Specify global Quartz TriggerListeners to be registered with the Scheduler.

public void
setJobDetails(org.quartz.JobDetail... jobDetails)

Register a list of JobDetail objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.

public void
setJobSchedulingDataLocation(String jobSchedulingDataLocation)

Set the location of a Quartz job definition XML file that follows the "job_scheduling_data_1_5" XSD or better.

public void
setJobSchedulingDataLocations(String... jobSchedulingDataLocations)

Set the locations of Quartz job definition XML files that follow the "job_scheduling_data_1_5" XSD or better.

public void
setOverwriteExistingJobs(boolean overwriteExistingJobs)

Set whether any jobs defined on this SchedulerFactoryBean should overwrite existing job definitions.

public void
setResourceLoader(ResourceLoader
the ResourceLoader object to be used by this object
resourceLoader
)

Implements org.springframework.context.ResourceLoaderAware.setResourceLoader.

Set the ResourceLoader that this object runs in.

This might be a ResourcePatternResolver, which can be checked through instanceof ResourcePatternResolver.

public void
setSchedulerListeners(org.quartz.SchedulerListener... schedulerListeners)

Specify Quartz SchedulerListeners to be registered with the Scheduler.

public void
setTransactionManager(PlatformTransactionManager transactionManager)

Set the transaction manager to be used for registering jobs and triggers that are defined by this SchedulerFactoryBean.

public void
setTriggers(org.quartz.Trigger... triggers)

Register a list of Trigger objects with the Scheduler that this FactoryBean creates.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

calendarsback to summary
private Map<String, org.quartz.Calendar> calendars
Annotations
@Nullable
globalJobListenersback to summary
private org.quartz.JobListener[] globalJobListeners
Annotations
@Nullable
globalTriggerListenersback to summary
private org.quartz.TriggerListener[] globalTriggerListeners
Annotations
@Nullable
jobDetailsback to summary
private List<org.quartz.JobDetail> jobDetails
Annotations
@Nullable
jobSchedulingDataLocationsback to summary
private String[] jobSchedulingDataLocations
Annotations
@Nullable
loggerback to summary
protected final Log logger
overwriteExistingJobsback to summary
private boolean overwriteExistingJobs
resourceLoaderback to summary
protected ResourceLoader resourceLoader
Annotations
@Nullable
schedulerListenersback to summary
private org.quartz.SchedulerListener[] schedulerListeners
Annotations
@Nullable
transactionManagerback to summary
private PlatformTransactionManager transactionManager
Annotations
@Nullable
triggersback to summary
private List<org.quartz.Trigger> triggers
Annotations
@Nullable

Constructor Detail

SchedulerAccessorback to summary
public SchedulerAccessor()

Method Detail

addJobToSchedulerback to summary
private boolean addJobToScheduler(org.quartz.JobDetail jobDetail) throws org.quartz.SchedulerException

Add the given job to the Scheduler, if it doesn't already exist. Overwrites the job in any case if "overwriteExistingJobs" is set.

Parameters
jobDetail:org.quartz.JobDetail

the job to add

Returns:boolean

true if the job was actually added, false if it already existed before

See Also
setOverwriteExistingJobs
addTriggerToSchedulerback to summary
private boolean addTriggerToScheduler(org.quartz.Trigger trigger) throws org.quartz.SchedulerException

Add the given trigger to the Scheduler, if it doesn't already exist. Overwrites the trigger in any case if "overwriteExistingJobs" is set.

Parameters
trigger:org.quartz.Trigger

the trigger to add

Returns:boolean

true if the trigger was actually added, false if it already existed before

See Also
setOverwriteExistingJobs
getSchedulerback to summary
protected abstract org.quartz.Scheduler getScheduler()

Template method that determines the Scheduler to operate on. To be implemented by subclasses.

registerJobsAndTriggersback to summary
protected void registerJobsAndTriggers() throws org.quartz.SchedulerException

Register jobs and triggers (within a transaction, if possible).

registerListenersback to summary
protected void registerListeners() throws org.quartz.SchedulerException

Register all specified listeners with the Scheduler.

setCalendarsback to summary
public void setCalendars(Map<String, org.quartz.Calendar> calendars)

Register a list of Quartz Calendar objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers.

Parameters
calendars:Map<String, org.quartz.Calendar>

a Map with calendar names as keys as Calendar objects as values

See Also
org.quartz.Calendar
setGlobalJobListenersback to summary
public void setGlobalJobListeners(org.quartz.JobListener... globalJobListeners)

Specify global Quartz JobListeners to be registered with the Scheduler. Such JobListeners will apply to all Jobs in the Scheduler.

setGlobalTriggerListenersback to summary
public void setGlobalTriggerListeners(org.quartz.TriggerListener... globalTriggerListeners)

Specify global Quartz TriggerListeners to be registered with the Scheduler. Such TriggerListeners will apply to all Triggers in the Scheduler.

setJobDetailsback to summary
public void setJobDetails(org.quartz.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.JobDetail
setJobSchedulingDataLocationback to summary
public void setJobSchedulingDataLocation(String jobSchedulingDataLocation)

Set the location of a Quartz job definition XML file that follows the "job_scheduling_data_1_5" XSD or better. 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
org.quartz.xml.XMLSchedulingDataProcessor
setJobSchedulingDataLocationsback to summary
public void setJobSchedulingDataLocations(String... jobSchedulingDataLocations)

Set the locations of Quartz job definition XML files that follow the "job_scheduling_data_1_5" XSD or better. 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
org.quartz.xml.XMLSchedulingDataProcessor
setOverwriteExistingJobsback to summary
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.

setResourceLoaderback to summary
public void setResourceLoader(ResourceLoader resourceLoader)

Implements org.springframework.context.ResourceLoaderAware.setResourceLoader.

Doc from org.springframework.context.ResourceLoaderAware.setResourceLoader.

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.

Parameters
resourceLoader:ResourceLoader

the ResourceLoader object to be used by this object

Annotations
@Override
setSchedulerListenersback to summary
public void setSchedulerListeners(org.quartz.SchedulerListener... schedulerListeners)

Specify Quartz SchedulerListeners to be registered with the Scheduler.

setTransactionManagerback to summary
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.

setTriggersback to summary
public void setTriggers(org.quartz.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