/**   
 * @Title: JobFactory.java 
 * @Package com.unis.detectionnum.server.schedule.job 
 * @Description: TODO
 * @author LiuFeng  
 * @date 2019年11月7日 上午11:00:09 
 * @version V1.0   
 */
package com.unis.detectionnum.server.schedule.job;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

/** 
 * @ClassName: JobFactory 
 * @Description: 解决调用service  空指针
 * @author LiuFeng 
 * @date 2019年11月7日 上午11:00:09  
 */
@Component
public class JobFactory extends AdaptableJobFactory {
    @Autowired
    private AutowireCapableBeanFactory capableBeanFactory;

    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        //调用父类的方法
        Object jobInstance = super.createJobInstance(bundle);
        //进行注入
        capableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }
}

