<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lstierneyltd &#187; quartz</title>
	<atom:link href="http://lstierneyltd.com/blog/tag/quartz/feed/" rel="self" type="application/rss+xml" />
	<link>http://lstierneyltd.com/blog</link>
	<description>Yet another development blog</description>
	<lastBuildDate>Wed, 13 Jul 2011 12:55:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Use Quartz to schedule tasks in Spring</title>
		<link>http://lstierneyltd.com/blog/development/use-quartz-to-schedule-tasks-in-spring/</link>
		<comments>http://lstierneyltd.com/blog/development/use-quartz-to-schedule-tasks-in-spring/#comments</comments>
		<pubDate>Fri, 07 May 2010 16:47:56 +0000</pubDate>
		<dc:creator>lawrence</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[How to's]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[quartz]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://lstierneyltd.com/blog/?p=87</guid>
		<description><![CDATA[Quartz is a full-featured, open source job scheduling service that can be integrated with, or used along side virtually any Java EE or Java SE application. In this simple example (notionally checking Twitter for updates) we integrate it with Spring. Spring Config &#60;bean name="checkTwitterForUpdates" class="org.springframework.scheduling.quartz.JobDetailBean"&#62; &#60;property name="jobClass" value="test.twitterReader" /&#62; &#60;/bean&#62; &#60;bean id="cronTwitterUpdateCheckTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean"&#62; &#60;property name="jobDetail" [...]]]></description>
			<content:encoded><![CDATA[<p>Quartz is a full-featured, open source job scheduling service that can be integrated with, or used along side virtually any Java EE or Java SE application.</p>
<p>In this simple example (notionally checking Twitter for updates) we integrate it with Spring.<br />
<code><span id="more-87"></span></code></p>
<h4>Spring Config</h4>
<pre>
&lt;bean name="checkTwitterForUpdates"
  class="org.springframework.scheduling.quartz.JobDetailBean"&gt;

       &lt;property name="jobClass" value="test.twitterReader" /&gt;
&lt;/bean&gt;

&lt;bean id="cronTwitterUpdateCheckTriggerBean"
  class="org.springframework.scheduling.quartz.CronTriggerBean"&gt;

       &lt;property name="jobDetail" ref="checkTwitterForUpdates" /&gt;
       &lt;!-- Run every day at noon --&gt;
       &lt;property name="cronExpression" value="0 0 12 * * ?" /&gt;
&lt;/bean&gt;

&lt;bean id="scheduler"
  class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;

       &lt;property name="triggers"&gt;
           &lt;list&gt;
               &lt;ref bean="cronTwitterUpdateCheckTriggerBean" /&gt;
           &lt;/list&gt;
       &lt;/property&gt;
&lt;/bean&gt;
</pre>
<p>You may just want to call a method on an existing object (perhaps a business object). We can use MethodInvokingJobDetailFactoryBean to do just this:</p>
<p> Often you just need to invoke a method on a specific object. Using the MethodInvokingJobDetailFactoryBean you can do exactly this:</p>
<pre>
&lt;bean id="jobDetail"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"&gt;
    &lt;property name="targetObject" ref="someBusinessObject"/&gt;
    &lt;property name="targetMethod" value="someMethod"/&gt;
&lt;/bean&gt;
</pre>
<h4>Java</h4>
<pre>
package twitter;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class twitterReader extends QuartzJobBean {
    protected void executeInternal(JobExecutionContext ctx)
      throws JobExecutionException {

      // Like whatever.......
    }
}
</pre>
<h4>Libraries</h4>
<p>You can get get Quartz <a href="http://www.quartz-scheduler.org/">here</a></p>
<p>You may also need:<br />
<a href="http://www.slf4j.org/">Simple Logging Facade for Java (SLF4J)</a> and</p>
]]></content:encoded>
			<wfw:commentRss>http://lstierneyltd.com/blog/development/use-quartz-to-schedule-tasks-in-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

