Quartz - Accept list in constructor
Quartz module - accept list in constructor to avoid copying list to a new array.
@@ -109,6 +109,15 @@ public class QuartzModule implements Extension {
this.jobs = Arrays.asList(jobs);
}
+ /**
+ * Creates Quartz module and register the given jobs.
+ *
+ * @param jobs Job classes.
+ */
+ public QuartzModule(final List<Class<?>> jobs) {
+ this.jobs = jobs;
+ }
+
/**
* 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.
@@ -121,6 +130,18 @@ public class QuartzModule implements Extension {
this.jobs = Arrays.asList(jobs);
}
+ /**
+ * 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.
+ *
+ * @param scheduler Provided scheduler.
+ * @param jobs Job classes.
+ */
+ public QuartzModule(@Nonnull Scheduler scheduler, final List<Class<?>> jobs) {
+ this.scheduler = scheduler;
+ this.jobs = jobs;
+ }
+
@Override public void install(@Nonnull Jooby application) throws Exception {
Config config = application.getConfig();
Map<JobDetail, Trigger> jobMap = JobGenerator.build(application, jobs);
