File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Spring and Quartz integration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring and Quartz integration" Watch "Spring and Quartz integration" New topic

Spring and Quartz integration

Chris Bojinca

Joined: Oct 14, 2002
Posts: 13

I want to use the Scheduler component of Spring (in particular the Quartz scheduler), I configured the class that extends QuartzJobBean and the CronTriggerBean and also the XML Spring config file but I don't know what to run in order to start the scheduler.
Any help?

Thank you.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Let's move this to the Application Framework forum, where the Spring-savvy folks hang out.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

You would need to configure a SchedulerFactoryBean, specifying the list of triggers that would be created by the factory, then create an ApplicationContext. When the ApplicationContext is created, the Quartz scheduler will be created and started.

Junilu - [How to Ask Questions] [How to Answer Questions]
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

As far as only quartz concern,
This three line of code you have to implement
String configFile = getServletContext().getRealPath("\\WEB-INF\\");//cfg.getInitParameter("config-file");
SchedulerFactory sf = new StdSchedulerFactory(configFile);
scheduler = sf.getScheduler();
JobDetail jobDetail = new JobDetail("QuARTZJOB",Scheduler.DEFAULT_GROUP,QuartZJob.class);
CronTrigger trigger = new CronTrigger("QUARTZJOBTrigger","QUARTZCollectionTriggerGroup");
scheduler.scheduleJob(jobDetail, trigger);

the above code you need to write in the servlet init method. The deploy the servlet when application starts. Mention your trigger in config parameter.

I have not worked with Spring, but I believe Quartz is indepened application. You just need to deploy the quartz servlet and mention triggers.
I agree. Here's the link:
subject: Spring and Quartz integration
It's not a secret anymore!