public abstract class SchedulerAccessor extends java.lang.Object implements ResourceLoaderAware
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.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,Calendar> |
calendars |
private JobListener[] |
globalJobListeners |
private TriggerListener[] |
globalTriggerListeners |
private java.util.List<JobDetail> |
jobDetails |
private java.lang.String[] |
jobSchedulingDataLocations |
protected Log |
logger |
private boolean |
overwriteExistingJobs |
protected ResourceLoader |
resourceLoader |
private SchedulerListener[] |
schedulerListeners |
private PlatformTransactionManager |
transactionManager |
private java.util.List<Trigger> |
triggers |
Constructor and Description |
---|
SchedulerAccessor() |
Modifier and Type | Method and Description |
---|---|
private boolean |
addJobToScheduler(JobDetail jobDetail)
Add the given job to the Scheduler, if it doesn't already exist.
|
private boolean |
addTriggerToScheduler(Trigger trigger)
Add the given trigger to the Scheduler, if it doesn't already exist.
|
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(java.util.Map<java.lang.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 |
setJobSchedulingDataLocation(java.lang.String jobSchedulingDataLocation)
Set the location of a Quartz job definition XML file that follows the
"job_scheduling_data_1_5" XSD or better.
|
void |
setJobSchedulingDataLocations(java.lang.String... jobSchedulingDataLocations)
Set the locations of Quartz job definition XML files that follow the
"job_scheduling_data_1_5" XSD or better.
|
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 |
setTriggers(Trigger... triggers)
Register a list of Trigger objects with the Scheduler that
this FactoryBean creates.
|
protected final Log logger
private boolean overwriteExistingJobs
private java.lang.String[] jobSchedulingDataLocations
private java.util.List<JobDetail> jobDetails
private java.util.Map<java.lang.String,Calendar> calendars
private java.util.List<Trigger> triggers
private SchedulerListener[] schedulerListeners
private JobListener[] globalJobListeners
private TriggerListener[] globalTriggerListeners
private PlatformTransactionManager transactionManager
protected ResourceLoader resourceLoader
public void setOverwriteExistingJobs(boolean overwriteExistingJobs)
public void setJobSchedulingDataLocation(java.lang.String jobSchedulingDataLocation)
org.quartz.xml.XMLSchedulingDataProcessor
public void setJobSchedulingDataLocations(java.lang.String... jobSchedulingDataLocations)
org.quartz.xml.XMLSchedulingDataProcessor
public void setJobDetails(JobDetail... jobDetails)
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.
setTriggers(Trigger...)
,
org.quartz.JobDetail
public void setCalendars(java.util.Map<java.lang.String,Calendar> calendars)
calendars
- Map with calendar names as keys as Calendar
objects as valuesorg.quartz.Calendar
public void setTriggers(Trigger... triggers)
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.
setJobDetails(JobDetail...)
,
org.quartz.JobDetail
public void setSchedulerListeners(SchedulerListener... schedulerListeners)
public void setGlobalJobListeners(JobListener... globalJobListeners)
public void setGlobalTriggerListeners(TriggerListener... globalTriggerListeners)
public void setTransactionManager(PlatformTransactionManager transactionManager)
public void setResourceLoader(ResourceLoader resourceLoader)
ResourceLoaderAware
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
.
setResourceLoader
in interface ResourceLoaderAware
resourceLoader
- ResourceLoader object to be used by this objectResourcePatternResolver
,
ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
protected void registerJobsAndTriggers() throws SchedulerException
SchedulerException
private boolean addJobToScheduler(JobDetail jobDetail) throws SchedulerException
jobDetail
- the job to addtrue
if the job was actually added,
false
if it already existed beforeSchedulerException
setOverwriteExistingJobs(boolean)
private boolean addTriggerToScheduler(Trigger trigger) throws SchedulerException
trigger
- the trigger to addtrue
if the trigger was actually added,
false
if it already existed beforeSchedulerException
setOverwriteExistingJobs(boolean)
protected void registerListeners() throws SchedulerException
SchedulerException
protected abstract Scheduler getScheduler()