quartzの使用例
1388 ワード
:1. Job
2. Job ,
SchedulerFactory sf = new StdSchedulerFactory();
try {
scheduler = sf.getScheduler();
JobDetail job = JobBuilder.newJob(Job.class).build();
job.getJobDataMap().put("sourceDir", sourceDir);
job.getJobDataMap().put("br", br);
job.getJobDataMap().put("cqm", cqm);
job.getJobDataMap().put("fqm", fqm);
Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(CronScheduleBuilder.cronSchedule(“* * * * * ?”))
.build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
String sourceDir = (String) context.getJobDetail().getJobDataMap().get("sourceDir");
BreakpointRecorder br = (BreakpointRecorder) context.getJobDetail().getJobDataMap().get("br");
CollectQualityMonitoring cqm = (CollectQualityMonitoring) context.getJobDetail().getJobDataMap().get("cqm");
FilterQualityMonitoring fqm = (FilterQualityMonitoring) context.getJobDetail().getJobDataMap().get("fqm");
recursiveSourceDir(sourceDir, br, cqm, fqm);
}