Java Reference
In-Depth Information
<bean id="scheduledDocumentReplicationTask"
<property name="timerTask" ref="documentReplicationTask" />
<property name="delay" value="5000" />
<property name="period" value="60000" />
Finally, you can configure a TimerFactoryBean instance to create and set up a Timer to run your
ScheduledTimerTask instance. You can specify multiple tasks in this factory bean.
<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<ref local="scheduledDocumentReplicationTask" />
Now you can simply start your timer with the following Main class. In this way, you don't require a
single line of code for scheduling tasks.
package com.apress.springenterpriserecipes.replicator;
public class Main {
public static void main(String[] args) throws Exception {
new ClassPathXmlApplicationContext("beans.xml");
6-6. Scheduling with Spring's Quartz Support
Your application has an advanced scheduling requirement that you want to fulfill using Quartz
Scheduler. Such a requirement might be something seemingly complex like the ability to run at arbitrary
times, or at strange intervals (“every other Thursday, but only after 10 am and before 2 pm”). Moreover,
you want to configure your scheduling jobs in a declarative way.
Spring provides utility classes for Quartz to enable you to configure scheduling jobs in the bean
configuration file, without programming against the Quartz API.
Search WWH ::

Custom Search