Created
February 13, 2015 22:09
-
-
Save mattraykowski/94fa8b5f76512fbb299e to your computer and use it in GitHub Desktop.
Shutting down a Scheduler on context destruction.
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
@Configuration | |
public class SpringConfiguration { | |
@Bean(destroyMethod="shutdown") | |
public Scheduler helloJob() { | |
JobDetail job = new JobDetail(); | |
job.setName("dummyJobName"); | |
job.setJobClass(HelloJob.class); | |
CronTrigger trigger = new CronTrigger(); | |
trigger.setName("thirtySecondsTrigger"); | |
trigger.setCronExpression("0/30 * * * * ?"); | |
Scheduler scheduler = new StdSchedulerFactory().getScheduler(); | |
scheduler.start(); | |
scheduler.scheduleJob(job, trigger); | |
return scheduler; | |
} | |
} | |
public class HelloJob implements Job { | |
public void execute(JobExecutionContext context) throws JobExecutionException { | |
System.out.println("Hello Quartz!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment