Created
November 29, 2010 23:59
-
-
Save sharrissf/720867 to your computer and use it in GitHub Desktop.
Compare the construction of Quartz jobs between Quartz 1.8.4 and Quartz 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Quartz 1.8.4 Example 2 | |
// First we must get a reference to a scheduler | |
SchedulerFactory sf = new StdSchedulerFactory(); | |
Scheduler sched = sf.getScheduler(); | |
log.info("------- Initialization Complete -----------"); | |
log.info("------- Scheduling Jobs -------------------"); | |
// computer a time that is on the next round minute | |
Date runTime = TriggerUtils.getEvenMinuteDate(new Date()); | |
// define the job and tie it to our HelloJob class | |
JobDetail job = new JobDetail("job1", "group1", HelloJob.class); | |
// Trigger the job to run on the next round minute | |
SimpleTrigger trigger = | |
new SimpleTrigger("trigger1", "group1", runTime); | |
// Tell quartz to schedule the job using our trigger | |
sched.scheduleJob(job, trigger); | |
// Quartz 2.0 Example 2 | |
SchedulerFactory sf = new StdSchedulerFactory(); | |
Scheduler sched = sf.getScheduler(); | |
log.info("------- Initialization Complete -----------"); | |
// computer a time that is on the next round minute | |
Date runTime = DateBuilder.evenMinuteDate(new Date()); | |
log.info("------- Scheduling Job -------------------"); | |
// define the job and tie it to our HelloJob class | |
JobDetail job = newJob(HelloJob.class) | |
.withIdentity("job1", "group1") | |
.build(); | |
// Trigger the job to run on the next round minute | |
Trigger trigger = newTrigger() | |
.withIdentity("trigger1", "group1") | |
.startAt(runTime) | |
.build(); | |
// Tell quartz to schedule the job using our trigger | |
sched.scheduleJob(job, trigger); | |
log.info(job.getKey() + " will run at: " + runTime); | |
// Start up the scheduler (nothing can actually run until the | |
// scheduler has been started) | |
sched.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment