alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (schedulingContext-quartz.xml)

This example Spring Framework source code file (schedulingContext-quartz.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

doctype, job, job, listimagesquartzjob, quartz, quartz, registered, registered, scheduler, schedules, timertasks, trigger, trigger, will

The Spring Framework schedulingContext-quartz.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 Quartz. Schedules "list images" and "check images" jobs.
  - Note that Quartz Jobs are throwaway objects, in contrast to shared TimerTasks.
  -->
<beans>

	<!-- Quartz Scheduler, with pre-registered triggers -->
	<!-- Will automatically start scheduling on context startup -->
	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref local="listImagesTrigger"/>
				<ref local="checkImagesTrigger"/>
			</list>
		</property>
	</bean>

	<!-- Job definition for ListImagesQuartzJob -->
	<!-- Lists the images in the image database and sends a corresponding mail -->
	<bean id="listImagesJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value="org.springframework.samples.imagedb.scheduling.ListImagesQuartzJob"/>
		<property name="jobDataAsMap">
			<map>
				<entry key="imageDatabase" value-ref="imageDatabase"/>
				<entry key="mailSender" value-ref="mailSender"/>
				<entry key="mailFrom" value="${mail.from}"/>
				<entry key="mailTo" value="${mail.to}"/>
			</map>
		</property>
	</bean>

	<!-- Trigger for the job defined above -->
	<!-- Registered by the 'scheduler' bean -->
	<bean id="listImagesTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
		<property name="jobDetail" ref="listImagesJobDetail"/>
		<property name="startDelay" value="10000"/>
		<property name="repeatInterval" value="10000"/>
	</bean>

	<!-- Job definition that delegates to the specified 'imageDatabase' method -->
	<!-- Convenient way of invoking existing business logic instead of writing a job -->
	<bean id="checkImagesJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="imageDatabase"/>
		<property name="targetMethod" value="checkImages"/>
	</bean>

	<!-- Trigger for the job defined above -->
	<!-- Registered by the 'scheduler' bean -->
	<bean id="checkImagesTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="checkImagesJobDetail"/>
		<property name="cronExpression" value="0/5 * * * * ?"/>
	</bean>

</beans>

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework schedulingContext-quartz.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.