Skip to content

Instantly share code, notes, and snippets.

@rtrcolin
Created July 16, 2012 06:56
Show Gist options
  • Save rtrcolin/3121212 to your computer and use it in GitHub Desktop.
Save rtrcolin/3121212 to your computer and use it in GitHub Desktop.
Dropwizard Quartz Service
import com.yammer.dropwizard.Service;
...
public class QuartzService extends Service<QuartzConfiguration> {
public static void main(String[] args) throws Exception {
new Quartz Service().run(args);
}
public QuartzService() {
super("Quartz Service");
}
@Override
protected void initialize(QuartzConfiguration config, Environment env) throws Exception {
// In subsequent posts will we add more stuff here
...
// Create a Quartz scheduler factory from properties in the Service YML config
SchedulerFactory sf = new StdSchedulerFactory(config.getSchedulerFactoryProperties());
QuartzManager qm = new QuartzManager(sf); // A Dropwizard Managed Object
env.manage(qm); // Assign the management of the object to the Service
env.addHealthCheck(new QuartzHealthCheck(qm)); // Add the health check to the service
...
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment