java.lang.Object
io.jooby.quartz.QuartzModule
- All Implemented Interfaces:
io.jooby.Extension
Scheduler module using Quartz: http://www.quartz-scheduler.org.
{
install(new QuartzModule(SampleJob.class));
}
public class SampleJob implements Job {
#64;Scheduled("10m")
public void execute(JobExecutionContext context) {
}
}
Implementation of Job is optional:
public class MyJobs {
#64;Scheduled("1m")
public void everyMinute() {
....
}
#64;Scheduled("1h")
* public void everyHour() {
* ....
* }
}
Cron expression are supported too. Check the Scheduled annotation for possible schedule
expressions.
Job key are generated from container class and method name. Example: SampleJob.execute, MyJob.everyMinute, MyJob.everyHour.
Jobs can be enabled/disabled (paused) at start up time by setting the enabled
property for each job key:
org.quartz.jobs.SampleJob.execute.enabled = falseNow the
SampleJob.execute is going to be paused at startup time.
The QuartzApp added a REST API to trigger, interrupt, pause, resume jobs.
- Since:
- 2.5.1
- Author:
- edgar
-
Constructor Summary
ConstructorsConstructorDescriptionQuartzModule(Class<?>... jobs) Creates Quartz module and register the given jobs.QuartzModule(List<Class<?>> jobs) Creates Quartz module and register the given jobs.QuartzModule(org.quartz.Scheduler scheduler, Class<?>... jobs) Creates Quartz module and register the given jobs.QuartzModule(org.quartz.Scheduler scheduler, List<Class<?>> jobs) Creates Quartz module and register the given jobs. -
Method Summary
Modifier and TypeMethodDescriptioncleanJobs(boolean cleanJobs) Safely clear/delete all jobs before schedule startup.cleanStaleJobs(boolean cleanStaleJobs) Lookup for existing (persisted) jobs and compare with the job list fromQuartzModule(Class[]).voidinstall(io.jooby.Jooby application) static org.quartz.impl.StdSchedulerFactorynewScheduleFactory(io.jooby.Jooby application) Creates a new scheduler factory.static org.quartz.SchedulernewScheduler(io.jooby.Jooby application) Creates a new scheduler.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jooby.Extension
lateinit
-
Constructor Details
-
QuartzModule
Creates Quartz module and register the given jobs.- Parameters:
jobs- Job classes.
-
QuartzModule
Creates Quartz module and register the given jobs.- Parameters:
jobs- Job classes.
-
QuartzModule
Creates Quartz module and register the given jobs. Uses an user provided schedule, schedule is started at application start up time and shutdown on application shutdown.- Parameters:
scheduler- Provided scheduler.jobs- Job classes.
-
QuartzModule
Creates Quartz module and register the given jobs. Uses an user provided schedule, schedule is started at application start up time and shutdown on application shutdown.- Parameters:
scheduler- Provided scheduler.jobs- Job classes.
-
-
Method Details
-
cleanStaleJobs
Lookup for existing (persisted) jobs and compare with the job list fromQuartzModule(Class[]). Delete any persisted job that is not in the list.- Parameters:
cleanStaleJobs- True to clear/delete stale job and triggers.- Returns:
- This module.
-
cleanJobs
Safely clear/delete all jobs before schedule startup. Use with caution.- Parameters:
cleanJobs- True to clear/delete all jobs and triggers.- Returns:
- This module.
-
install
- Specified by:
installin interfaceio.jooby.Extension- Throws:
Exception
-
newScheduler
@NonNull public static org.quartz.Scheduler newScheduler(@NonNull io.jooby.Jooby application) Creates a new scheduler.- Parameters:
application- Application.- Returns:
- New scheduler.
-
newScheduleFactory
@NonNull public static org.quartz.impl.StdSchedulerFactory newScheduleFactory(@NonNull io.jooby.Jooby application) Creates a new scheduler factory.- Parameters:
application- Application.- Returns:
- New scheduler factory.
-