/**   
 * @Title: QuartzConfig.java 
 * @Package com.unis.detectionnum.server.config 
 * @Description: TODO
 * @author LiuFeng  
 * @date 2019年11月7日 上午11:01:24 
 * @version V1.0   
 */
package com.unis.detectionnum.server.config;

import org.quartz.Scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import com.unis.detectionnum.server.schedule.job.JobFactory;

/** 
 * @ClassName: QuartzConfig 
 * @Description: TODO 
 * @author LiuFeng 
 * @date 2019年11月7日 上午11:01:24  
 */
@Configuration
public class QuartzConfig {

    private static final Logger logger = LoggerFactory.getLogger(QuartzConfig .class);
    @Autowired
    public JobFactory jobFactory;
    /**
     * 方法名：
     * 功能：定义quartz调度工厂
     */
    @Bean
    public SchedulerFactoryBean schedulerFactoryBean(){
        SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
        factoryBean.setJobFactory(jobFactory);
        //是否覆盖之前的定时任务
        factoryBean.setOverwriteExistingJobs(true);
        // 延时启动(秒)
        factoryBean.setStartupDelay(0);
        logger.info("scheduler 初始化成功！");
        return factoryBean;
    }
}
