Search in sources :

Example 1 with MethodInvokingJobDetailFactoryBean

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);
    }
}
Also used : JobDetail(org.quartz.JobDetail) CronTriggerFactoryBean(org.springframework.scheduling.quartz.CronTriggerFactoryBean) MethodInvokingJobDetailFactoryBean(org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean)

Aggregations

JobDetail (org.quartz.JobDetail)1 CronTriggerFactoryBean (org.springframework.scheduling.quartz.CronTriggerFactoryBean)1 MethodInvokingJobDetailFactoryBean (org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean)1