|
@@ -8,8 +8,6 @@ import java.util.List;
|
8
|
8
|
import java.util.Map;
|
9
|
9
|
import java.util.Set;
|
10
|
10
|
|
11
|
|
-import javax.annotation.Resource;
|
12
|
|
-
|
13
|
11
|
import org.quartz.CronScheduleBuilder;
|
14
|
12
|
import org.quartz.CronTrigger;
|
15
|
13
|
import org.quartz.Job;
|
|
@@ -27,7 +25,10 @@ import org.quartz.impl.matchers.GroupMatcher;
|
27
|
25
|
import org.quartz.impl.triggers.CronTriggerImpl;
|
28
|
26
|
import org.slf4j.Logger;
|
29
|
27
|
import org.slf4j.LoggerFactory;
|
|
28
|
+import org.springframework.beans.BeansException;
|
30
|
29
|
import org.springframework.beans.factory.InitializingBean;
|
|
30
|
+import org.springframework.context.ApplicationContext;
|
|
31
|
+import org.springframework.context.ApplicationContextAware;
|
31
|
32
|
import org.springframework.util.Assert;
|
32
|
33
|
|
33
|
34
|
import com.xxl.job.client.util.JacksonUtil;
|
|
@@ -39,32 +40,30 @@ import com.xxl.job.dao.IXxlJobLogDao;
|
39
|
40
|
* base quartz scheduler util
|
40
|
41
|
* @author xuxueli 2015-12-19 16:13:53
|
41
|
42
|
*/
|
42
|
|
-public final class DynamicSchedulerUtil implements InitializingBean {
|
|
43
|
+public final class DynamicSchedulerUtil implements ApplicationContextAware, InitializingBean {
|
43
|
44
|
private static final Logger logger = LoggerFactory.getLogger(DynamicSchedulerUtil.class);
|
44
|
45
|
|
45
|
|
- // xxlJobLogDao
|
46
|
|
- public static IXxlJobLogDao xxlJobLogDao;
|
47
|
|
- @Resource
|
48
|
|
- public void setXxlJobLogDao(IXxlJobLogDao xxlJobLogDao) {
|
49
|
|
- DynamicSchedulerUtil.xxlJobLogDao = xxlJobLogDao;
|
50
|
|
- }
|
51
|
|
- // xxlJobInfoDao
|
52
|
|
- public static IXxlJobInfoDao xxlJobInfoDao;
|
53
|
|
- @Resource
|
54
|
|
- public void setXxlJobInfoDao(IXxlJobInfoDao xxlJobInfoDao) {
|
55
|
|
- DynamicSchedulerUtil.xxlJobInfoDao = xxlJobInfoDao;
|
56
|
|
- }
|
57
|
|
-
|
58
|
46
|
// Scheduler
|
59
|
47
|
private static Scheduler scheduler;
|
60
|
48
|
public static void setScheduler(Scheduler scheduler) {
|
61
|
49
|
DynamicSchedulerUtil.scheduler = scheduler;
|
62
|
50
|
}
|
|
51
|
+
|
|
52
|
+ // xxlJobLogDao、xxlJobInfoDao
|
|
53
|
+ public static IXxlJobLogDao xxlJobLogDao;
|
|
54
|
+ public static IXxlJobInfoDao xxlJobInfoDao;
|
63
|
55
|
|
|
56
|
+ @Override
|
|
57
|
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
58
|
+ DynamicSchedulerUtil.xxlJobLogDao = applicationContext.getBean(IXxlJobLogDao.class);
|
|
59
|
+ DynamicSchedulerUtil.xxlJobInfoDao = applicationContext.getBean(IXxlJobInfoDao.class);
|
|
60
|
+ }
|
|
61
|
+
|
64
|
62
|
@Override
|
65
|
63
|
public void afterPropertiesSet() throws Exception {
|
66
|
64
|
Assert.notNull(scheduler, "quartz scheduler is null");
|
67
|
65
|
logger.info(">>>>>>>>> init quartz scheduler success.[{}]", scheduler);
|
|
66
|
+
|
68
|
67
|
}
|
69
|
68
|
|
70
|
69
|
// getJobKeys
|
|
@@ -266,4 +265,5 @@ public final class DynamicSchedulerUtil implements InitializingBean {
|
266
|
265
|
return result;
|
267
|
266
|
}
|
268
|
267
|
|
|
268
|
+
|
269
|
269
|
}
|