Thursday, September 18, 2008

Quartz Scheduler First Impression

Quartz Scheduler is used to make a scheduling job. In this post we will make a scheduler to generate daily report for persons report that have we made before for each one minute. Here we start. Download first Quartz library and copy it into spring lib folder. In package com.ndung.service create two interfaces named and

package com.ndung.service;

public interface EODManager {
void executeEOD();

package com.ndung.service;

public interface Executable {
void execute() throws Exception;

In package com.ndung.service.impl add a class named

package com.ndung.service.impl;

import java.util.List;
import com.ndung.service.EODManager;
import com.ndung.service.Executable;

public class EODManagerImpl implements EODManager {
private List<Executable> executables;
public void setExecutables(List<Executable> executables) {
this.executables = executables;
public void executeEOD() {
for (Executable executable : executables) {
try { executable.execute(); }
catch (Exception e) { e.printStackTrace(); }

Edit and like belows.

public interface PersonManager extends Manager, Executable{
public void generateDailyReport();

public void generateDailyReport() {
File dirPath = new File("report");
if (!dirPath.exists()) {
File filePath = new File(dirPath+"/PersonReport.pdf");
Map<String, Object> mapReport = new HashMap<String, Object>();
mapReport.put("title", "Persons Report");
mapReport.put("date", new Date());
ReportUtil.generateReport("PersonsReport.jrxml", filePath.getAbsolutePath(),
dao.getPersons(null), mapReport, "pdf");
public void execute() throws Exception {

Add a bean in applicationContext-service.xml for eodManager.

<bean id="eodManager" class="com.ndung.service.impl.EODManagerImpl">
<property name="executables">
<ref bean="personManager" />

In folder web/WEB-INF create applicationContext file named applicationContext-schedule.xml

<?xml version="1.0" encoding="UTF-8"?>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<ref local="cronTrigger" />

<bean id="cronTrigger"
<property name="jobDetail">
<ref bean="methodInvokingJobDetail" />
<property name="cronExpression">
<value>0 0/1 * * * ?</value>

<bean id="methodInvokingJobDetail"
<property name="targetObject">
<ref bean="eodManager" />
<property name="targetMethod">

Run our application and check out if there a file in report/PersonReport.pdf in our computer.


Anonymous said...

miley cyrus nude [url=]miley cyrus nude[/url] paris hilton nude [url=]paris hilton nude[/url] kim kardashian nude [url=]kim kardashian nude[/url] kim kardashian nude [url=]kim kardashian nude[/url]

Anonymous said...


Related keywords:
buy cheap prescription Tramadol
buy Tramadol cheap
next day air ups Tramadol
50 mg Tramadol
what does Tramadol look like
Tramadol online without presciption
key Tramadol
Tramadol side efforts
[url=]Tramadol side efforts [/url]
Tramadol for opiate withdrawal
buying Tramadol online
50 mg Tramadol
Tramadol no prescription overnight delivery
debt negotiation buy Tramadol
purchase Tramadol
buy no perscription Tramadol

Anonymous said...

I think, that you are mistaken. I can defend the position. Write to me in PM, we will discuss.

Anonymous said...

I can not participate now in discussion - there is no free time. But I will return - I will necessarily write that I think on this question.

Anonymous said...

Lovingly done is richer reconsider than extravagantly said.

Anonymous said...

Well done is better than spectacularly said.

Anonymous said...

Splendidly done is better than comfortably said.

Anonymous said...

A man who dares to atrophy one hour of time has not discovered the value of life.



Anonymous said...

We should be meticulous and discriminating in all the information we give. We should be especially careful in giving guidance that we would not think of following ourselves. Most of all, we ought to evade giving advise which we don't imitate when it damages those who depreciate us at our word.

nail sets

[url=]nail sets[/url]

Anonymous said...

A human beings begins scathing his wisdom teeth the senior without surcease he bites out more than he can chew.

Anonymous said...

To be a adroit charitable being is to be enduring a amiable of openness to the in the seventh heaven, an skill to guardianship uncertain things beyond your own manage, that can govern you to be shattered in hugely exceptionally circumstances for which you were not to blame. That says something exceedingly outstanding about the get of the principled autobiography: that it is based on a trustworthiness in the unpredictable and on a willingness to be exposed; it's based on being more like a weed than like a sparkler, something fairly dainty, but whose mere particular attractiveness is inseparable from that fragility.

Anonymous said...

To be a noble benign being is to procure a kind of openness to the world, an cleverness to trust unsure things beyond your own control, that can take you to be shattered in hugely outermost circumstances for which you were not to blame. That says something uncommonly outstanding thither the condition of the righteous autobiography: that it is based on a trustworthiness in the fitful and on a willingness to be exposed; it's based on being more like a spy than like a jewel, something fairly dainty, but whose acutely item attractiveness is inseparable from that fragility.

Anonymous said...

In everyone's life, at some pass‚, our inner throw goes out. It is then break asunder into zeal beside an face with another benign being. We should all be glad for those people who rekindle the inner spirit

Anonymous said...

Restaurants in the United States. Search or browse list of restaurants.

Anonymous said...

Directory of insurance agencies organized by states

Anonymous said...

My brother suggested I would possibly like this website.

He used to be totally right. This submit actually made my
day. You can not imagine simply how much time I had spent
for this information! Thanks!

my webpage coffee flavorings

Anonymous said...

I was suggested this web site by my cousin. I'm not sure whether this post is written by him as no one else know such detailed about my trouble. You are wonderful! Thanks!

my homepage

Anonymous said...
Finding A Lover
This can be going to be the places all your family members come to mind to understand more about as part about your daily routine,including the offices that your family hang around town allowing you to have That means at have the desired effect at church at going to be the nightclub allowing an individual your colleagues at the fitness where your family have the desired effect around town and also so many of the various great sources as well as for potential lovers. If you have singles all around the your social corporations this can be of assistance Although a number of people worry about it's some of the best do not for additional details on have a go at your luck providing some one your partner's friends or otherwise family.

ciri ciri vimax asli said...

thanks I like it this really good information
Vimax Canada Vimax asli