ソースを参照

Merge pull request #1181 from j112929/master

许雪里 5 年 前
コミット
0b9153f136
No account linked to committer's email

+ 27 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminBean ファイルの表示

@@ -0,0 +1,27 @@
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,16 +18,15 @@ import javax.sql.DataSource;
18 18
  *
19 19
  * @author xuxueli 2017-04-28
20 20
  */
21
-@Component
22
-public class XxlJobAdminConfig implements InitializingBean{
21
+
22
+public class XxlJobAdminConfig {
23 23
     private static XxlJobAdminConfig adminConfig = null;
24 24
     public static XxlJobAdminConfig getAdminConfig() {
25 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 32
     // conf

+ 5 - 6
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobScheduler.java ファイルの表示

@@ -33,14 +33,13 @@ import java.util.concurrent.ConcurrentMap;
33 33
 /**
34 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 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 43
         // init i18n
45 44
         initI18n();
46 45
 
@@ -59,7 +58,7 @@ public class XxlJobScheduler implements InitializingBean, DisposableBean {
59 58
         logger.info(">>>>>>>>> init xxl-job admin success.");
60 59
     }
61 60
 
62
-    @Override
61
+    
63 62
     public void destroy() throws Exception {
64 63
 
65 64
         // stop-schedule