I'm trying to wire together Guice (Java), Quartz scheduler and iBatis (iBaGuice) to do the following:
- Start command line utility-scanner using
main()
- Periodically scan directory (provided as argument) for files containing formatted output (XML or YAML)
- When file is detected, parse and output result to the database
The problems:
- I used this example to wire Guice and Quartz. However I'm missing some important details which I'm asking in the comments but the post is somewhat dated so I'm quoting it here also:
- 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();
}
}