Code snippets for article BAEL-818 (#1934)

* Quartz example for article: Introduction to Quartz

* Adding new module for Java Quartz

* Removing Quartz code from jee7 module

* Fixing folder structure

* Removing java-quartz module and adding code snippets in libraries module
This commit is contained in:
Alex Vargas
2017-05-25 14:45:53 -07:00
committed by Zeger Hendrikse
parent a2e2192494
commit 772038390f
5 changed files with 7 additions and 71 deletions
@@ -0,0 +1,42 @@
package com.baeldung.quartz;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
public class QuartzExample {
public static void main(String args[]) {
SchedulerFactory schedFact = new StdSchedulerFactory();
try {
Scheduler sched = schedFact.getScheduler();
JobDetail job = JobBuilder.newJob(SimpleJob.class)
.withIdentity("myJob", "group1")
.build();
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("myTrigger", "group1")
.startNow()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
sched.scheduleJob(job, trigger);
sched.start();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,13 @@
package com.baeldung.quartz;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class SimpleJob implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("This is a quartz job!");
}
}