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

public Class SpringBeanJobFactory

extends AdaptableJobFactory
implements ApplicationContextAware, SchedulerContextAware
Class Inheritance
All Implemented Interfaces
org.springframework.scheduling.quartz.SchedulerContextAware, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Imports
org.quartz.SchedulerContext, org.quartz.spi.TriggerFiredBundle, org.springframework.beans.BeanWrapper, .MutablePropertyValues, .PropertyAccessorFactory, org.springframework.context.ApplicationContext, .ApplicationContextAware, org.springframework.lang.Nullable

Subclass of AdaptableJobFactory that also supports Spring-style dependency injection on bean properties. This is essentially the direct equivalent of Spring's QuartzJobBean in the shape of a Quartz org.quartz.spi.JobFactory.

Applies scheduler context, job data map and trigger data map entries as bean property values. If no matching bean property is found, the entry is by default simply ignored. This is analogous to QuartzJobBean's behavior.

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

Author
Juergen Hoeller
Since
2.0
See Also
SchedulerFactoryBean#setJobFactory, QuartzJobBean

Field Summary

Modifier and TypeField and Description
private ApplicationContext
private String[]
private org.quartz.SchedulerContext

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
createJobInstance(org.quartz.spi.TriggerFiredBundle
the TriggerFiredBundle from which the JobDetail and other info relating to the trigger firing can be obtained
bundle
)

Overrides org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance.

Create the job instance, populating it with property values taken from the scheduler context, job data map and trigger data map.

protected boolean
isEligibleForPropertyPopulation(Object
the job object to introspect
jobObject
)

Return whether the given job object is eligible for having its bean properties populated.

public void
setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object
applicationContext
)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

public void
setIgnoredUnknownProperties(String... ignoredUnknownProperties)

Specify the unknown properties (not found in the bean) that should be ignored.

public void
setSchedulerContext(org.quartz.SchedulerContext schedulerContext)

Implements org.springframework.scheduling.quartz.SchedulerContextAware.setSchedulerContext.

Set the SchedulerContext of the current Quartz Scheduler.

Inherited from org.springframework.scheduling.quartz.AdaptableJobFactory:
adaptJobnewJob

Field Detail

applicationContextback to summary
private ApplicationContext applicationContext
Annotations
@Nullable
ignoredUnknownPropertiesback to summary
private String[] ignoredUnknownProperties
Annotations
@Nullable
schedulerContextback to summary
private org.quartz.SchedulerContext schedulerContext
Annotations
@Nullable

Constructor Detail

SpringBeanJobFactoryback to summary
public SpringBeanJobFactory()

Method Detail

createJobInstanceback to summary
protected Object createJobInstance(org.quartz.spi.TriggerFiredBundle bundle) throws Exception

Overrides org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance.

Create the job instance, populating it with property values taken from the scheduler context, job data map and trigger data map.

Parameters
bundle:org.quartz.spi.TriggerFiredBundle

Doc from org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance.

the TriggerFiredBundle from which the JobDetail and other info relating to the trigger firing can be obtained

Returns:Object

Doc from org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance.

the job instance

Annotations
@Override
Exceptions
Exception:

Doc from org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance.

if job instantiation failed

isEligibleForPropertyPopulationback to summary
protected boolean isEligibleForPropertyPopulation(Object jobObject)

Return whether the given job object is eligible for having its bean properties populated.

The default implementation ignores QuartzJobBean instances, which will inject bean properties themselves.

Parameters
jobObject:Object

the job object to introspect

See Also
QuartzJobBean
setApplicationContextback to summary
public void setApplicationContext(ApplicationContext applicationContext)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

Doc from org.springframework.context.ApplicationContextAware.setApplicationContext.

Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

Invoked after population of normal bean properties but before an init callback such as org.springframework.beans.factory.InitializingBean#afterPropertiesSet() or a custom init-method. Invoked after ResourceLoaderAware#setResourceLoader, ApplicationEventPublisherAware#setApplicationEventPublisher and MessageSourceAware, if applicable.

Parameters
applicationContext:ApplicationContext

the ApplicationContext object to be used by this object

Annotations
@Override
setIgnoredUnknownPropertiesback to summary
public void setIgnoredUnknownProperties(String... ignoredUnknownProperties)

Specify the unknown properties (not found in the bean) that should be ignored.

Default is null, indicating that all unknown properties should be ignored. Specify an empty array to throw an exception in case of any unknown properties, or a list of property names that should be ignored if there is no corresponding property found on the particular job class (all other unknown properties will still trigger an exception).

setSchedulerContextback to summary
public void setSchedulerContext(org.quartz.SchedulerContext schedulerContext)

Implements org.springframework.scheduling.quartz.SchedulerContextAware.setSchedulerContext.

Doc from org.springframework.scheduling.quartz.SchedulerContextAware.setSchedulerContext.

Set the SchedulerContext of the current Quartz Scheduler.

Annotations
@Override