|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.scheduling.quartz.SchedulerFactoryBean
FactoryBean that sets up a Quartz Scheduler and exposes it for bean references.
Allows registration of JobDetails, Calendars and Triggers, automatically starting the scheduler on initialization and shutting it down on destruction. In typical scenarios, there is no need to access the Scheduler instance itself in application code.
Note that Quartz instantiates a new Job for each execution, in contrast to Timer which uses a TimerTask instance that is shared between repeated executions. Just JobDetail descriptors are shared.
Scheduler
,
StdSchedulerFactory
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
SchedulerFactoryBean()
|
Method Summary | |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected org.quartz.Scheduler |
createScheduler(org.quartz.SchedulerFactory schedulerFactory,
java.lang.String schedulerName)
Create the Scheduler instance for the given factory and scheduler name. |
void |
destroy()
This implementation shuts down the Quartz scheduler, stopping all scheduled jobs. |
java.lang.Object |
getObject()
Return an instance (possibly shared or independent) of the object managed by this factory. |
java.lang.Class |
getObjectType()
Return the type of object that this FactoryBean creates, or null if not known in advance. |
boolean |
isSingleton()
Is the bean managed by this factory a singleton or a prototype? That is, will getObject() always return the same object? |
void |
setCalendars(java.util.Map calendars)
Register a list of Quartz Calendar objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers. |
void |
setConfigLocation(Resource configLocation)
Set the location of the Quartz properties config file, for example as classpath resource "classpath:quartz.properties". |
void |
setJobDetails(org.quartz.JobDetail[] jobDetails)
Register a list of JobDetail objects with the Scheduler that this FactoryBean creates, to be referenced by Triggers. |
void |
setQuartzProperties(java.util.Properties quartzProperties)
Set Quartz properties, like "org.quartz.threadPool.class". |
void |
setSchedulerFactoryClass(java.lang.Class schedulerFactoryClass)
Set the Quartz SchedulerFactory implementation to use. |
void |
setSchedulerName(java.lang.String schedulerName)
Set the name of the Scheduler to fetch from the SchedulerFactory. |
void |
setTriggers(org.quartz.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 |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public SchedulerFactoryBean()
Method Detail |
public void setSchedulerFactoryClass(java.lang.Class schedulerFactoryClass)
Default is StdSchedulerFactory, reading in the standard quartz.properties from quartz.jar. To use custom Quartz properties, specify "configLocation" or "quartzProperties".
StdSchedulerFactory
,
setConfigLocation(org.springframework.core.io.Resource)
,
setQuartzProperties(java.util.Properties)
public void setSchedulerName(java.lang.String schedulerName)
SchedulerFactory.getScheduler(String)
,
SchedulerFactory.getScheduler()
public void setConfigLocation(Resource configLocation)
Note: Can be omitted when all necessary properties are specified locally via this bean.
public void setQuartzProperties(java.util.Properties quartzProperties)
Can be used to override values in a Quartz properties config file, or to specify all necessary properties locally.
public void setJobDetails(org.quartz.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(org.quartz.Trigger[])
,
JobDetail
,
JobDetailBean
,
JobDetailAwareTrigger
,
Trigger.setJobName(java.lang.String)
public void setCalendars(java.util.Map calendars)
calendars
- Map with calendar names as keys as Calendar
objects as valuesCalendar
,
Trigger.setCalendarName(java.lang.String)
public void setTriggers(org.quartz.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(org.quartz.JobDetail[])
,
JobDetail
,
JobDetailAwareTrigger
,
CronTriggerBean
,
SimpleTriggerBean
public void afterPropertiesSet() throws java.io.IOException, org.quartz.SchedulerException
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
java.io.IOException
org.quartz.SchedulerException
protected org.quartz.Scheduler createScheduler(org.quartz.SchedulerFactory schedulerFactory, java.lang.String schedulerName) throws org.quartz.SchedulerException
Default implementation invokes the corresponding getScheduler methods of SchedulerFactory. Can be overridden for custom Scheduler creation.
schedulerFactory
- the factory to create the Scheduler withschedulerName
- the name of the scheduler to create
org.quartz.SchedulerException
- if thrown by Quartz methodsafterPropertiesSet()
,
SchedulerFactory.getScheduler()
,
SchedulerFactory.getScheduler(String)
public java.lang.Object getObject()
FactoryBean
getObject
in interface FactoryBean
public java.lang.Class getObjectType()
FactoryBean
For a singleton, this can simply return getObject().getClass(), or even null, as autowiring will always check the actual objects for singletons. For prototypes, returning a meaningful type here is highly advisable, as autowiring will simply ignore them else.
getObjectType
in interface FactoryBean
ListableBeanFactory.getBeansOfType(java.lang.Class, boolean, boolean)
public boolean isSingleton()
FactoryBean
The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory.
isSingleton
in interface FactoryBean
public void destroy() throws org.quartz.SchedulerException
destroy
in interface DisposableBean
org.quartz.SchedulerException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |