|
Spring Framework example source code file (schedulingContext-timer.xml)
The Spring Framework schedulingContext-timer.xml source code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
- Scheduler context for Timer. Schedules "list images" and "check images" tasks.
- Note that TimerTasks are shared instances, in contrast to throwaway Quartz Jobs.
-->
<beans>
<!-- java.util.Timer, with pre-registered scheduled tasks -->
<!-- Will automatically start scheduling on context startup -->
<bean id="timer" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="listImagesScheduledTask"/>
<ref local="checkImagesScheduledTask"/>
</list>
</property>
</bean>
<!-- Task definition for ListImagesTimerTask -->
<!-- Lists the images in the image database and sends a corresponding mail -->
<bean id="listImagesTimerTask" class="org.springframework.samples.imagedb.scheduling.ListImagesTimerTask">
<property name="imageDatabase" ref="imageDatabase"/>
<property name="mailSender" ref="mailSender"/>
<property name="mailFrom" value="${mail.from}"/>
<property name="mailTo" value="${mail.to}"/>
</bean>
<!-- ScheduledTimerTask for the task defined above -->
<!-- Registered by the 'timer' bean -->
<bean id="listImagesScheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="listImagesTimerTask"/>
<property name="delay" value="10000"/>
<property name="period" value="10000"/>
</bean>
<!-- Job definition that delegates to the specified 'imageDatabase' method -->
<!-- Convenient way of invoking existing business logic instead of writing a task -->
<bean id="checkImagesTimerTask" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="imageDatabase"/>
<property name="targetMethod" value="checkImages"/>
</bean>
<!-- ScheduledTimerTask for the task defined above -->
<!-- Registered by the 'timer' bean -->
<bean id="checkImagesScheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="checkImagesTimerTask"/>
<property name="delay" value="5000"/>
<property name="period" value="5000"/>
</bean>
</beans>
Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework schedulingContext-timer.xml source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.