Skip to content

Instantly share code, notes, and snippets.

@rtrcolin
Created July 16, 2012 07:53
Show Gist options
  • Save rtrcolin/3121429 to your computer and use it in GitHub Desktop.
Save rtrcolin/3121429 to your computer and use it in GitHub Desktop.
Quartz Configuration
import com.yammer.dropwizard.config.Configuration;
...
public class QuartzConfiguration extends Configuration {
@Valid
@JsonProperty
private Map<String,String> quartzSettings = new HashMap<String, String>();
public Properties getSchedulerFactoryProperties(){
Properties sfProps = new Properties();
// Fixed Quartz settings. They could easily be added to the YAML config file
sfProps.setProperty("org.quartz.plugin.jobInitializer.class", "org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin");
sfProps.setProperty("org.quartz.plugin.jobInitializer.failOnFileNotFound", "true");
// Job XML files can be changed without restarting the service by being check at regular intervals
sfProps.setProperty("org.quartz.plugin.jobInitializer.scanInterval", "0");
sfProps.setProperty("org.quartz.plugin.jobInitializer.wrapInUserTransaction", "false");
// Quartz checks for updates. This should be turned off for production systems.
sfProps.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
// Quartz settings configured in YML file
sfProps.setProperty("org.quartz.scheduler.instanceName", quartzSettings.get("instanceName"));
sfProps.setProperty("org.quartz.threadPool.class", quartzSettings.get("threadPoolClass"));
sfProps.setProperty("org.quartz.threadPool.threadCount", quartzSettings.get("threadCount"));
sfProps.setProperty("org.quartz.threadPool.threadPriority", quartzSettings.get("threadPriority"));
sfProps.setProperty("org.quartz.jobStore.class", quartzSettings.get("jobStoreClass"));
sfProps.setProperty("org.quartz.plugin.jobInitializer.fileNames", quartzSettings.get("jobFiles"));
return sfProps;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment