I'm trying to wire together Guice (Java), Quartz scheduler and iBatis (iBaGuice) to do the following:
main()
The problems:
- It's not obvious how to set-up the scheduler. Where and how would I wire the
Trigger
(I can useTrigger#makeMinutelyTrigger
)?- I really have just one type of job I will be executing, I understand that details in the JobFactory#newJob are coming from the
TriggerFiredBundle
parameter but where/how do I wire that? And where/how do I create or wire concrete Job?
P.S. I got a little bit further by creating and wiring ScheduleProvider. Now I'm stuck with how to actually schedule the Job in this following snippet. It seams that my JobFactory#newJob
method is never called
public class CollectorServiceImpl implements CollectorService {
Scheduler scheduler;
/**
* @throws SchedulerException
*/
@Inject
public CollectorServiceImpl(final SchedulerFactory factory, final GuiceJobFactory jobFactory)
throws SchedulerException {
scheduler = factory.getScheduler();
scheduler.setJobFactory(jobFactory);
}
/**
* @throws SchedulerException
* @see teradata.quantum.reporting.collector.service.CollectorService#start()
*/
@Override
public void start() throws SchedulerException {
Trigger trigger = TriggerUtils.makeMinutelyTrigger("MIN_TRIGGER");
scheduler.scheduleJob(trigger); // this fails trigger validation since no job name is provided
scheduler.start();
}
}
core to your problem is, you don´t actually schedule a job class:
getScheduler().scheduleJob(new JobDetail("myFooJob", null, FooJob.class),
TriggerUtils.makeMinutelyTrigger("MIN_TRIGGER"));
full answer & demo code on http://www.codesmell.org/blog/2009/01/quartz-fits/