/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rjconsultores.ventaboletos.web.gui.controladores.job;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;

import com.rjconsultores.ventaboletos.service.CorridaService;
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;

/**
 *
 * @author Rafius
 */
public class GeneracionCorridaJob implements Job {

    private static Logger log = Logger.getLogger(GeneracionCorridaJob.class);
    private CorridaService corridaService;

    public CorridaService getCorridaService() {
        return corridaService;
    }

    public void setCorridaService(CorridaService corridaService) {
        this.corridaService = corridaService;
    }

    @Override
    public void execute(JobExecutionContext jec) throws JobExecutionException {
        log.info("Inicio do job de geração de corridas.");

        ApplicationContext appContext = AppContext.getApplicationContext();
        CorridaService cs = (CorridaService) appContext.getBean("corridaService");
        cs.generarCorridaAutomatica();

        log.info("Fim do job de geração de corridas.");
    }
}
