瀏覽代碼

Merge pull request #1181 from j112929/master

许雪里 5 年之前
父節點
當前提交
0b9153f136
沒有帳戶連結到提交者的電子郵件

+ 27 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean 查看文件

1
+package com.xxl.job.admin.conf;
2
+
3
+import org.springframework.beans.factory.annotation.Qualifier;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+
7
+/**
8
+ * @Auther: zhuolin.ji
9
+ * @Date: 2019/10/12 18:08
10
+ * @Package: com.xxl.job.admin.conf
11
+ * @Description:
12
+ */
13
+@Configuration
14
+public class XxlJobAdminBean {
15
+
16
+    @Bean(name = "xxlJobAdminConfig")
17
+    public XxlJobAdminConfig getXxlJobAdminConfig() {
18
+        return new XxlJobAdminConfig();
19
+    }
20
+
21
+    @Bean(initMethod = "init", destroyMethod = "destroy")
22
+    public XxlJobScheduler getXxlJobScheduler(@Qualifier(value = "xxlJobAdminConfig") XxlJobAdminConfig xxlJobAdminConfig) {
23
+        XxlJobAdminConfig.setAdminConfig(xxlJobAdminConfig);
24
+        return new XxlJobScheduler();
25
+    }
26
+
27
+}

+ 4 - 5
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java 查看文件

18
  *
18
  *
19
  * @author xuxueli 2017-04-28
19
  * @author xuxueli 2017-04-28
20
  */
20
  */
21
-@Component
22
-public class XxlJobAdminConfig implements InitializingBean{
21
+
22
+public class XxlJobAdminConfig {
23
     private static XxlJobAdminConfig adminConfig = null;
23
     private static XxlJobAdminConfig adminConfig = null;
24
     public static XxlJobAdminConfig getAdminConfig() {
24
     public static XxlJobAdminConfig getAdminConfig() {
25
         return adminConfig;
25
         return adminConfig;
26
     }
26
     }
27
 
27
 
28
-    @Override
29
-    public void afterPropertiesSet() throws Exception {
30
-        adminConfig = this;
28
+    public static void setAdminConfig(XxlJobAdminConfig config) {
29
+        XxlJobAdminConfig.adminConfig = config;
31
     }
30
     }
32
 
31
 
33
     // conf
32
     // conf

+ 5 - 6
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobScheduler.java 查看文件

33
 /**
33
 /**
34
  * @author xuxueli 2018-10-28 00:18:17
34
  * @author xuxueli 2018-10-28 00:18:17
35
  */
35
  */
36
-@Component
37
-@DependsOn("xxlJobAdminConfig")
38
-public class XxlJobScheduler implements InitializingBean, DisposableBean {
36
+
37
+public class XxlJobScheduler  {
39
     private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class);
38
     private static final Logger logger = LoggerFactory.getLogger(XxlJobScheduler.class);
40
 
39
 
41
 
40
 
42
-    @Override
43
-    public void afterPropertiesSet() throws Exception {
41
+    
42
+    public void init() throws Exception {
44
         // init i18n
43
         // init i18n
45
         initI18n();
44
         initI18n();
46
 
45
 
59
         logger.info(">>>>>>>>> init xxl-job admin success.");
58
         logger.info(">>>>>>>>> init xxl-job admin success.");
60
     }
59
     }
61
 
60
 
62
-    @Override
61
+    
63
     public void destroy() throws Exception {
62
     public void destroy() throws Exception {
64
 
63
 
65
         // stop-schedule
64
         // stop-schedule