I'm using Quartz Scheduler v1.8.3 and is integrated into Apache Tomcat v6.0.10, and hence scheduler is initialized from within servlet container. Jobs are also added/scheduled to scheduler from within Apache Tomcat.
I'm designing a JSP web front end page (quartzAdmin.jsp) from where I only want to see scheduler information like meta-data values, all job details along with its triggers, currently executing jobs, etc.
My question is, in order to get a handle to the scheduler, which one of the below 2 option is recommended:
Option 1: Getting handle by directly calling schedulerFactory.getScheduler()
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler scheduler = sf.getScheduler();
Option 2: Getting handle by implementing singleton pattern
public class Quartz {
private Quartz() {
}
private static Scheduler scheduler = null;
public static Scheduler getScheduler() {
if(scheduler == null) {
SchedulerFactory sf = new StdSchedulerFactory();
scheduler = sf.getScheduler();
}
return scheduler;
}
}
Then in my quartzAdmin.jsp, just a call Quartz.getScheduler() would return a handle to the scheduler.