Using TriggerUtils with the CronTrigger

Chapter 4, "Scheduling Jobs," introduced the triggerUtils class in the org.quartz package, which simplifies the creation of triggers of both types. When possible, you should attempt to use the methods within the triggerUtils class to create your triggers.

For example, if you needed to execute a job every day at 5:30 PM, you could use the following code:

try {

 // A CronTrigger that fires @ 5:30PM
 CronTrigger trigger =
new CronTrigger("CronTrigger", null, "0 30 17 ? * *");

} catch (ParseException ex) {
logger.error("Couldn't parse cron expression", ex);
}

Or you could use the triggerUtils like this:

 // A CronTrigger that fires @ 5:30PM
Trigger trigger = TriggerUtils.makeDailyTrigger(17, 30);
trigger.setName("CronTrigger");

TRiggerUtils makes it easier and more convenient to use triggers, without giving up too much of the flexibility.


Using CronTriggers in the JobInitializationPlugin

Scheduling in the Enterprise

Getting Started with Quartz

Hello, Quartz

Scheduling Jobs

Cron Triggers and More

JobStores and Persistence

Implementing Quartz Listeners

Using Quartz Plug-Ins

Using Quartz Remotely

Using Quartz with J2EE

Clustering Quartz

Quartz Cookbook

Quartz and Web Applications

Using Quartz with Workflow

Appendix A. Quartz Configuration Reference



Quartz Job Scheduling Framework(c) Building Open Source Enterprise Applications
Quartz Job Scheduling Framework: Building Open Source Enterprise Applications
ISBN: 0131886703
EAN: 2147483647
Year: N/A
Pages: 148

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net