in the Bundle class :
private void createBundle() {
try {
trigger = new CronTrigger("myCronTrigger", "CronTriggerGroup", "0 42 7/1 ? * *");
} catch (ParseException e) {
e.printStackTrace();
}
jobDetail = new JobDetail("myJob", null, CrawlingJob.class);
jobDetail.getJobDataMap().put("crawlingJob", crawlingJob);
jobDetail.getJobDataMap().put("crawler", crawler);
}
I'm adding the job (crawlingJob) and the actual services (crawler) into the job data map. So in the Job class :
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Execute job Scheduled Crawler at : " + new Date());
Crawler crawler = (Crawler) context.getJobDetail().getJobDataMap().get("crawler");
crawler.updateData(CrawlAjax.URL);
}
we only need to extract the service class from the context and then execute the real method. As simple as that. And the AFAIK the minimum library you need to include to make it work is :
- chenillekit-quartz-1.0.2.jar
- commons-codec-1.4.jar
- commons-collections-3.1.jar
- quartz-all-1.6.5.jar
No comments:
Post a Comment