Click here to Skip to main content
15,891,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I get a quartz scheduler which created in another java class.
ex:

I started a scheduler :

Java
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
JobDetail jobDetail = new JobDetail("gr1", "GTLPL", AutoRunJobClass.class);
CronTrigger cronTrigger = new CronTrigger("tr1", "GTLCL", cronExpTrigger);
cronTrigger.setStartTime(startDate.getTime());
cronTrigger.setEndTime(endDate.getTime());
scheduler.scheduleJob(jobDetail, cronTrigger);
scheduler.start();


it is in java class ClassA.

and I want to shutdown/standby scheduler in another class named ClassB.

How can I do it
Posted

Pass the scheduler object from the classA object to the classB object, via some method. e.g.
Java
ClassB bObject = new ClassB();
bObject.method(scheduler);
 
Share this answer
 
Hello,

Generally you are expected to call StdSchedulerFactory.getDefaultScheduler() method. The factory will create the default scheduler instance and register it inside a SchedularRepository which is a singleton. So once the scheduler is up and running you can always obtain the reference for the default scheduler instance via StdSchedulerFactory.getDefaultScheduler() method. Provided the requesting class resides in the same JVM.

Regards,
 
Share this answer
 
Comments
gavkk 5-Apr-13 3:40am    
I am using Quartz 1.6.6.
I think there is no such method StdSchedulerFactory.getDefaultScheduler() there.
let me know can I use schedulerFactory.getScheduler() instead
Prasad Khandekar 5-Apr-13 3:53am    
it's a static method of StdSchedulerFactory (http://quartz-scheduler.org/api/2.1.7/org/quartz/impl/StdSchedulerFactory.html), available in 1.8.x, 2.0x & 2.1.x version.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900