use of org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean in project opennms by OpenNMS.
the class Statsd method scheduleReport.
private void scheduleReport(ReportDefinition reportDef) throws ClassNotFoundException, NoSuchMethodException, ParseException, SchedulerException, Exception {
//this is most likely reentrant since the method is private and called from start via plural version.
synchronized (m_scheduler) {
MethodInvokingJobDetailFactoryBean jobFactory = new MethodInvokingJobDetailFactoryBean();
jobFactory.setTargetObject(this);
jobFactory.setTargetMethod("runReport");
jobFactory.setArguments(new Object[] { reportDef });
jobFactory.setConcurrent(false);
jobFactory.setBeanName(reportDef.getDescription());
jobFactory.afterPropertiesSet();
JobDetail jobDetail = (JobDetail) jobFactory.getObject();
CronTriggerFactoryBean cronReportTrigger = new CronTriggerFactoryBean();
cronReportTrigger.setBeanName(reportDef.getDescription());
cronReportTrigger.setJobDetail(jobDetail);
cronReportTrigger.setCronExpression(reportDef.getCronExpression());
cronReportTrigger.afterPropertiesSet();
m_scheduler.scheduleJob(jobDetail, cronReportTrigger.getObject());
LOG.debug("Schedule report {}", cronReportTrigger);
}
}
Aggregations