package link.at17.mid.tushare.config;

import org.springframework.context.annotation.Configuration;

import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import link.at17.mid.tushare.task.AutowireCapableJobFactory;

@Configuration
public class QuartzConfig {
    @Autowired
    private AutowireCapableJobFactory autowireCapableJobFactory;

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean() {
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setJobFactory(autowireCapableJobFactory);
        return schedulerFactoryBean;
    }

    @Bean
    @Qualifier("scheduler")
    public Scheduler scheduler() {
        return schedulerFactoryBean().getScheduler();
    }
}
