spring-framework / org.springframework.scheduling.quartz / MethodInvokingJobDetailFactoryBean

MethodInvokingJobDetailFactoryBean

open class MethodInvokingJobDetailFactoryBean : ArgumentConvertingMethodInvoker, FactoryBean<JobDetail>, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean

org.springframework.beans.factory.FactoryBean that exposes a org.quartz.JobDetail object which delegates job execution to a specified (static or non-static) method. Avoids the need for implementing a one-line Quartz Job that just invokes an existing service method on a Spring-managed target bean.

Inherits common configuration properties from the MethodInvoker base class, such as "targetObject" and "targetMethod", adding support for lookup of the target bean by name through the "targetBeanName" property (as alternative to specifying a "targetObject" directly, allowing for non-singleton target objects).

Supports both concurrently running jobs and non-currently running jobs through the "concurrent" property. Jobs created by this MethodInvokingJobDetailFactoryBean are by default volatile and durable (according to Quartz terminology).

NOTE: JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.

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

Author
Juergen Hoeller

Author
Alef Arendsen

Since
18.02.2004

See Also
#setTargetBeanName#setTargetObject#setTargetMethod#setConcurrent

Constructors

<init>

MethodInvokingJobDetailFactoryBean()

org.springframework.beans.factory.FactoryBean that exposes a org.quartz.JobDetail object which delegates job execution to a specified (static or non-static) method. Avoids the need for implementing a one-line Quartz Job that just invokes an existing service method on a Spring-managed target bean.

Inherits common configuration properties from the MethodInvoker base class, such as "targetObject" and "targetMethod", adding support for lookup of the target bean by name through the "targetBeanName" property (as alternative to specifying a "targetObject" directly, allowing for non-singleton target objects).

Supports both concurrently running jobs and non-currently running jobs through the "concurrent" property. Jobs created by this MethodInvokingJobDetailFactoryBean are by default volatile and durable (according to Quartz terminology).

NOTE: JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.

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

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

getObject

open fun getObject(): JobDetail

getObjectType

open fun getObjectType(): Class<out JobDetail>

getTargetClass

open fun getTargetClass(): Class<*>

Overridden to support the "targetBeanName" feature.

getTargetObject

open fun getTargetObject(): Any

Overridden to support the "targetBeanName" feature.

isSingleton

open fun isSingleton(): Boolean

setBeanClassLoader

open fun setBeanClassLoader(classLoader: ClassLoader): Unit

setBeanFactory

open fun setBeanFactory(beanFactory: BeanFactory): Unit

setBeanName

open fun setBeanName(beanName: String): Unit

setConcurrent

open fun setConcurrent(concurrent: Boolean): Unit

Specify whether or not multiple jobs should be run in a concurrent fashion. The behavior when one does not want concurrent jobs to be executed is realized through adding the @PersistJobDataAfterExecution and @DisallowConcurrentExecution markers. More information on stateful versus stateless jobs can be found here.

The default setting is to run jobs concurrently.

setGroup

open fun setGroup(group: String): Unit

Set the group of the job.

Default is the default group of the Scheduler.

setName

open fun setName(name: String): Unit

Set the name of the job.

Default is the bean name of this FactoryBean.

setTargetBeanName

open fun setTargetBeanName(targetBeanName: String): Unit

Set the name of the target bean in the Spring BeanFactory.

This is an alternative to specifying "targetObject", allowing for non-singleton beans to be invoked. Note that specified "targetObject" and "targetClass" values will override the corresponding effect of this "targetBeanName" setting (i.e. statically pre-define the bean type or even the bean object).

Inherited Functions

getTypeConverter

open fun getTypeConverter(): TypeConverter

Return the TypeConverter used for argument type conversion.

Can be cast to org.springframework.beans.PropertyEditorRegistry if direct access to the underlying PropertyEditors is desired (provided that the present TypeConverter actually implements the PropertyEditorRegistry interface).

registerCustomEditor

open fun registerCustomEditor(requiredType: Class<*>, propertyEditor: PropertyEditor): Unit

Register the given custom property editor for all properties of the given type.

Typically used in conjunction with the default org.springframework.beans.SimpleTypeConverter; will work with any TypeConverter that implements the PropertyEditorRegistry interface as well.

setTypeConverter

open fun setTypeConverter(typeConverter: TypeConverter): Unit

Set a TypeConverter to use for argument type conversion.

Default is a org.springframework.beans.SimpleTypeConverter. Can be overridden with any TypeConverter implementation, typically a pre-configured SimpleTypeConverter or a BeanWrapperImpl instance.