Issue
We disable the quartz scheduler locally by commenting out the scheduler factory bean in the jobs.xml
file.
Is there a setting for doing something similar in the quartz.properties
file?
Solution
If you use Spring Framework you can make subclass from org.springframework.scheduling.quartz.SchedulerFactoryBean and override afterPropertiesSet() method.
public class MySchedulerFactoryBean extends org.springframework.scheduling.quartz.SchedulerFactoryBean {
@Autowired
private @Value("${enable.quartz.tasks}") boolean enableQuartzTasks;
@Override
public void afterPropertiesSet() throws Exception {
if (enableQuartzTasks) {
super.afterPropertiesSet();
}
}
}
Then change declaration of factory in xml file and set "enable.quartz.tasks" property in properties file. That's all.
Of course, instead using @Autowired you can write and use setter method and add
<property name="enableQuartzTasks" value="${enable.quartz.tasks}"/>
to MySchedulerFactoryBean declaration in xml.
Answered By - Ćukasz Kmiecik