package org.molgenis.scheduler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.quartz.SchedulerFactoryBean; /** * Configure a scheduler factory based on a Quartz scheduler with jobs supporting autowiring. */ @Configuration public class SchedulerConfig { @Autowired private ApplicationContext applicationContext; @Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean(); AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory(); jobFactory.setApplicationContext(applicationContext); quartzScheduler.setJobFactory(jobFactory); return quartzScheduler; } }