Java Reference
In-Depth Information
In the prepare() method, you can prepare the MimeMessage object, which is precreated for
JavaMailSender . If there's any exception thrown, it will be converted into Spring's mail runtime
exception automatically.
6-5. Scheduling with Spring's JDK Timer Support
Your application has a basic scheduling requirement that you want to fulfill using JDK Timer. Moreover,
you want to configure your scheduling tasks in a declarative way.
Spring provides utility classes for JDK Timer to enable you to configure scheduling tasks in the bean
configuration file, without programming against the JDK Timer API.
How It Works
Creating a Timer Task
To use JDK Timer for scheduling, first create your task by extending the abstract class TimerTask . For
example, the following timer task executes the replicate() method of a file replicator:
package com.apress.springenterpriserecipes.replicator;
import java.util.TimerTask;
public class FileReplicationTask extends TimerTask {
private FileReplicator fileReplicator;
public void setFileReplicator(FileReplicator fileReplicator) {
this.fileReplicator = fileReplicator;
public void run() {
try {
} catch (IOException e) {
throw new RuntimeException(e);
Search WWH ::

Custom Search