/* Copyright (c) 2011 Danish Maritime Authority
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
package dk.dma.ais.abnormal.analyzer.reports;
import com.google.inject.Inject;
import com.google.inject.Injector;
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;
/**
* This class performs integration between Google Guice and Quartz Scheduler.
*
* @author Thomas Borg Salling <tbsalling@tbsalling.dk>
*/
public class ReportJobFactory implements JobFactory {
private final Injector injector;
@Inject
public ReportJobFactory(final Injector injector) {
this.injector = injector;
}
@Override
public Job newJob(TriggerFiredBundle triggerFiredBundle, Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = triggerFiredBundle.getJobDetail();
Class jobClass = jobDetail.getJobClass();
return (Job) injector.getInstance(jobClass);
}
}