Search in sources :

Example 1 with SchedulerInstantiationException

use of org.motechproject.scheduler.exception.SchedulerInstantiationException in project motech by motech.

the class MotechSchedulerFactoryBean method init.

/**
 * Creates the Spring {@code SchedulerFactoryBean}.
 */
@PostConstruct
public void init() {
    schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setQuartzProperties(schedulerProperties);
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(getBooleanWithDefault(schedulerProperties.getProperty("scheduler.waitForJobsToCompleteOnShutdown"), true));
    schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
    schedulerFactoryBean.setApplicationContext(applicationContext);
    try {
        schedulerFactoryBean.afterPropertiesSet();
        schedulerFactoryBean.getScheduler().start();
    } catch (Exception e) {
        throw new SchedulerInstantiationException("Failed to instantiate scheduler with configuration from quartz.properties", e);
    }
}
Also used : SchedulerInstantiationException(org.motechproject.scheduler.exception.SchedulerInstantiationException) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) SchedulerInstantiationException(org.motechproject.scheduler.exception.SchedulerInstantiationException) SchedulerException(org.quartz.SchedulerException) SchedulerShutdownException(org.motechproject.scheduler.exception.SchedulerShutdownException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 SchedulerInstantiationException (org.motechproject.scheduler.exception.SchedulerInstantiationException)1 SchedulerShutdownException (org.motechproject.scheduler.exception.SchedulerShutdownException)1 SchedulerException (org.quartz.SchedulerException)1 SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)1