All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.jobs.SpringJobFactory Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
package io.dropwizard.jobs;

import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.spi.JobFactory;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.context.ApplicationContext;

public class SpringJobFactory implements JobFactory {

    ApplicationContext context;

    public SpringJobFactory(ApplicationContext context) {
        this.context = context;
    }

    @Override
    public Job newJob(TriggerFiredBundle triggerFiredBundle, Scheduler scheduler) throws SchedulerException {
        JobDetail jobDetail = triggerFiredBundle.getJobDetail();
        Class jobClass = jobDetail.getJobClass();
        return context.getBean(jobClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy