img
The task: The task is the piece of business logic that needs to be scheduled. In
·
Spring, a task can be specified as a method within any Spring bean.
The TaskScheduler interface: The org.springframework.scheduling.TaskScheduler
·
interface provides support for task scheduling. Spring provides three
implementation classes of the TaskScheduler interface. The
TimerManagerTaskScheduler class (under the package
org.springframework.scheduling.commonj) wraps CommonJ's
commonj.timers.TimerManager interface, which is commonly used in commercial
JEE application servers such as WebSphere, WebLogic, and so on. The
ConcurrentTaskScheduler and ThreadPoolTaskScheduler (both under the package
org.springframework.scheduling.concurrent) classes wrap the
java.util.concurrent.ScheduledThreadPoolExecutor class. Both classes support
task execution from a shared thread pool.
Figure 15-1 shows the relationships between the Trigger interface, the TaskScheduler interface, and
the task (that implements the java.lang.Runnable interface).
Figure 15-1. Relationship between trigger, task, and scheduler
To schedule tasks using Spring's TaskScheduler abstraction, you have two options. One is to use the
task-namespace in Spring's XML configuration, and the other is to use annotations. Let's go through each
of them.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home