Created
April 20, 2015 10:09
-
-
Save facundofarias/d273cff5cb8290df025f to your computer and use it in GitHub Desktop.
Quartz JobFactory implementation using HK2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.Inject; | |
import javax.inject.Singleton; | |
import org.glassfish.hk2.api.ServiceLocator; | |
import org.jvnet.hk2.annotations.Service; | |
import org.quartz.Job; | |
import org.quartz.JobDetail; | |
import org.quartz.spi.JobFactory; | |
import org.quartz.Scheduler; | |
import org.quartz.SchedulerException; | |
import org.quartz.spi.TriggerFiredBundle; | |
@Service | |
@Singleton | |
public class DefaultJobFactory implements JobFactory | |
{ | |
@Inject | |
private ServiceLocator locator; | |
@Override | |
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException | |
{ | |
JobDetail jobDetail = bundle.getJobDetail(); | |
return locator.create(jobDetail.getJobClass()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment