Fix outdated references to JobDetailBean
Issue: SPR-12306
This commit is contained in:
@@ -47690,30 +47690,30 @@ classes that simplify the usage of Quartz within Spring-based applications.
|
|||||||
|
|
||||||
|
|
||||||
[[scheduling-quartz-jobdetail]]
|
[[scheduling-quartz-jobdetail]]
|
||||||
==== Using the JobDetailBean
|
==== Using the JobDetailFactoryBean
|
||||||
`JobDetail` objects contain all information needed to run a job. The Spring Framework
|
Quartz `JobDetail` objects contain all information needed to run a job. Spring provides a
|
||||||
provides a `JobDetailBean` that makes the `JobDetail` more of an actual JavaBean with
|
`JobDetailFactoryBean` which provides bean-style properties for XML configuration purposes.
|
||||||
sensible defaults. Let's have a look at an example:
|
Let's have a look at an example:
|
||||||
|
|
||||||
[source,xml,indent=0]
|
[source,xml,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
|
<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
||||||
<property name="jobClass" value="example.ExampleJob" />
|
<property name="jobClass" value="example.ExampleJob"/>
|
||||||
<property name="jobDataAsMap">
|
<property name="jobDataAsMap">
|
||||||
<map>
|
<map>
|
||||||
<entry key="timeout" value="5" />
|
<entry key="timeout" value="5"/>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
The job detail bean has all information it needs to run the job ( `ExampleJob`). The
|
The job detail configuration has all information it needs to run the job (`ExampleJob`).
|
||||||
timeout is specified in the job data map. The job data map is available through the
|
The timeout is specified in the job data map. The job data map is available through the
|
||||||
`JobExecutionContext` (passed to you at execution time), but the `JobDetailBean` also
|
`JobExecutionContext` (passed to you at execution time), but the `JobDetail` also gets
|
||||||
maps the properties from the job data map to properties of the actual job. So in this
|
its properties from the job data mapped to properties of the job instance. So in this
|
||||||
case, if the `ExampleJob` contains a property named `timeout`, the `JobDetailBean` will
|
case, if the `ExampleJob` contains a bean property named `timeout`, the `JobDetail`
|
||||||
automatically apply it:
|
will have it applied automatically:
|
||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
@@ -47726,7 +47726,7 @@ automatically apply it:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter called after the ExampleJob is instantiated
|
* Setter called after the ExampleJob is instantiated
|
||||||
* with the value from the JobDetailBean (5)
|
* with the value from the JobDetailFactoryBean (5)
|
||||||
*/
|
*/
|
||||||
public void setTimeout(int timeout) {
|
public void setTimeout(int timeout) {
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@@ -47739,13 +47739,13 @@ automatically apply it:
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
All additional settings from the job detail bean are of course available to you as well.
|
All additional properties from the job data map are of course available to you as well.
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
Using the `name` and `group` properties, you can modify the name and the group
|
Using the `name` and `group` properties, you can modify the name and the group
|
||||||
of the job, respectively. By default, the name of the job matches the bean name of the
|
of the job, respectively. By default, the name of the job matches the bean name
|
||||||
job detail bean (in the example above, this is `exampleJob`).
|
of the `JobDetailFactoryBean` (in the example above, this is `exampleJob`).
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
@@ -47760,8 +47760,8 @@ Often you just need to invoke a method on a specific object. Using the
|
|||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||||
<property name="targetObject" ref="exampleBusinessObject" />
|
<property name="targetObject" ref="exampleBusinessObject"/>
|
||||||
<property name="targetMethod" value="doIt" />
|
<property name="targetMethod" value="doIt"/>
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -47803,9 +47803,9 @@ job will not start before the first one has finished. To make jobs resulting fro
|
|||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||||
<property name="targetObject" ref="exampleBusinessObject" />
|
<property name="targetObject" ref="exampleBusinessObject"/>
|
||||||
<property name="targetMethod" value="doIt" />
|
<property name="targetMethod" value="doIt"/>
|
||||||
<property name="concurrent" value="false" />
|
<property name="concurrent" value="false"/>
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -47837,17 +47837,17 @@ Find below a couple of examples:
|
|||||||
----
|
----
|
||||||
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
|
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
|
||||||
<!-- see the example of method invoking job above -->
|
<!-- see the example of method invoking job above -->
|
||||||
<property name="jobDetail" ref="jobDetail" />
|
<property name="jobDetail" ref="jobDetail"/>
|
||||||
<!-- 10 seconds -->
|
<!-- 10 seconds -->
|
||||||
<property name="startDelay" value="10000" />
|
<property name="startDelay" value="10000"/>
|
||||||
<!-- repeat every 50 seconds -->
|
<!-- repeat every 50 seconds -->
|
||||||
<property name="repeatInterval" value="50000" />
|
<property name="repeatInterval" value="50000"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||||
<property name="jobDetail" ref="exampleJob" />
|
<property name="jobDetail" ref="exampleJob"/>
|
||||||
<!-- run every morning at 6 AM -->
|
<!-- run every morning at 6 AM -->
|
||||||
<property name="cronExpression" value="0 0 6 * * ?" />
|
<property name="cronExpression" value="0 0 6 * * ?"/>
|
||||||
</bean>
|
</bean>
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -47861,8 +47861,8 @@ seconds and one every morning at 6 AM. To finalize everything, we need to set up
|
|||||||
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||||
<property name="triggers">
|
<property name="triggers">
|
||||||
<list>
|
<list>
|
||||||
<ref bean="cronTrigger" />
|
<ref bean="cronTrigger"/>
|
||||||
<ref bean="simpleTrigger" />
|
<ref bean="simpleTrigger"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|||||||
Reference in New Issue
Block a user