| | |
| | | package com.yeshi.fanli.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 com.yeshi.fanli.log.LogHelper;
|
| | |
|
| | | public class JobFactory extends AdaptableJobFactory {
|
| | | @Autowired //这个对象Spring会帮我们自动注入进来,也属于Spring技术范畴.
|
| | | private AutowireCapableBeanFactory capableBeanFactory;
|
| | |
|
| | | @Override
|
| | | protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
|
| | | |
| | | LogHelper.test("-----初始化执行【JobFactory】-- createJobInstance--");
|
| | | // 调用父类的方法
|
| | | Object jobInstance = super.createJobInstance(bundle);
|
| | | // 进行注入,这属于Spring的技术,不清楚的可以查看Spring的API.
|
| | | capableBeanFactory.autowireBean(jobInstance);
|
| | | |
| | | LogHelper.test("----初始化结束【JobFactory】-- createJobInstance-----");
|
| | | |
| | | return jobInstance;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.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 com.yeshi.fanli.log.LogHelper; |
| | | |
| | | public class JobFactory extends AdaptableJobFactory { |
| | | @Autowired //这个对象Spring会帮我们自动注入进来,也属于Spring技术范畴. |
| | | private AutowireCapableBeanFactory capableBeanFactory; |
| | | |
| | | @Override |
| | | protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { |
| | | |
| | | LogHelper.test("-----初始化执行【JobFactory】-- createJobInstance--"); |
| | | // 调用父类的方法 |
| | | Object jobInstance = super.createJobInstance(bundle); |
| | | // 进行注入,这属于Spring的技术,不清楚的可以查看Spring的API. |
| | | capableBeanFactory.autowireBean(jobInstance); |
| | | |
| | | LogHelper.test("----初始化结束【JobFactory】-- createJobInstance-----"); |
| | | |
| | | return jobInstance; |
| | | } |
| | | } |