提交 | 用户 | 时间
|
e7c126
|
1 |
package com.xxl.job.admin.core.conf; |
H |
2 |
|
|
3 |
import com.xxl.job.admin.core.alarm.JobAlarmer; |
|
4 |
import com.xxl.job.admin.core.scheduler.XxlJobScheduler; |
|
5 |
import com.xxl.job.admin.dao.*; |
|
6 |
import org.springframework.beans.factory.DisposableBean; |
|
7 |
import org.springframework.beans.factory.InitializingBean; |
|
8 |
import org.springframework.beans.factory.annotation.Value; |
|
9 |
import org.springframework.mail.javamail.JavaMailSender; |
|
10 |
import org.springframework.stereotype.Component; |
|
11 |
|
|
12 |
import javax.annotation.Resource; |
|
13 |
import javax.sql.DataSource; |
|
14 |
import java.util.Arrays; |
|
15 |
|
|
16 |
/** |
|
17 |
* xxl-job config |
|
18 |
* |
|
19 |
* @author xuxueli 2017-04-28 |
|
20 |
*/ |
|
21 |
|
|
22 |
@Component |
|
23 |
public class XxlJobAdminConfig implements InitializingBean, DisposableBean { |
|
24 |
|
|
25 |
private static XxlJobAdminConfig adminConfig = null; |
|
26 |
public static XxlJobAdminConfig getAdminConfig() { |
|
27 |
return adminConfig; |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
// ---------------------- XxlJobScheduler ---------------------- |
|
32 |
|
|
33 |
private XxlJobScheduler xxlJobScheduler; |
|
34 |
|
|
35 |
@Override |
|
36 |
public void afterPropertiesSet() throws Exception { |
|
37 |
adminConfig = this; |
|
38 |
|
|
39 |
xxlJobScheduler = new XxlJobScheduler(); |
|
40 |
xxlJobScheduler.init(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public void destroy() throws Exception { |
|
45 |
xxlJobScheduler.destroy(); |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
// ---------------------- XxlJobScheduler ---------------------- |
|
50 |
|
|
51 |
// conf |
|
52 |
@Value("${xxl.job.i18n}") |
|
53 |
private String i18n; |
|
54 |
|
|
55 |
@Value("${xxl.job.accessToken}") |
|
56 |
private String accessToken; |
|
57 |
|
|
58 |
@Value("${spring.mail.from}") |
|
59 |
private String emailFrom; |
|
60 |
|
|
61 |
@Value("${xxl.job.triggerpool.fast.max}") |
|
62 |
private int triggerPoolFastMax; |
|
63 |
|
|
64 |
@Value("${xxl.job.triggerpool.slow.max}") |
|
65 |
private int triggerPoolSlowMax; |
|
66 |
|
|
67 |
@Value("${xxl.job.logretentiondays}") |
|
68 |
private int logretentiondays; |
|
69 |
|
|
70 |
// dao, service |
|
71 |
|
|
72 |
@Resource |
|
73 |
private XxlJobLogDao xxlJobLogDao; |
|
74 |
@Resource |
|
75 |
private XxlJobInfoDao xxlJobInfoDao; |
|
76 |
@Resource |
|
77 |
private XxlJobRegistryDao xxlJobRegistryDao; |
|
78 |
@Resource |
|
79 |
private XxlJobGroupDao xxlJobGroupDao; |
|
80 |
@Resource |
|
81 |
private XxlJobLogReportDao xxlJobLogReportDao; |
|
82 |
@Resource |
|
83 |
private JavaMailSender mailSender; |
|
84 |
@Resource |
|
85 |
private DataSource dataSource; |
|
86 |
@Resource |
|
87 |
private JobAlarmer jobAlarmer; |
|
88 |
|
|
89 |
|
|
90 |
public String getI18n() { |
|
91 |
if (!Arrays.asList("zh_CN", "zh_TC", "en").contains(i18n)) { |
|
92 |
return "zh_CN"; |
|
93 |
} |
|
94 |
return i18n; |
|
95 |
} |
|
96 |
|
|
97 |
public String getAccessToken() { |
|
98 |
return accessToken; |
|
99 |
} |
|
100 |
|
|
101 |
public String getEmailFrom() { |
|
102 |
return emailFrom; |
|
103 |
} |
|
104 |
|
|
105 |
public int getTriggerPoolFastMax() { |
|
106 |
if (triggerPoolFastMax < 200) { |
|
107 |
return 200; |
|
108 |
} |
|
109 |
return triggerPoolFastMax; |
|
110 |
} |
|
111 |
|
|
112 |
public int getTriggerPoolSlowMax() { |
|
113 |
if (triggerPoolSlowMax < 100) { |
|
114 |
return 100; |
|
115 |
} |
|
116 |
return triggerPoolSlowMax; |
|
117 |
} |
|
118 |
|
|
119 |
public int getLogretentiondays() { |
|
120 |
if (logretentiondays < 7) { |
|
121 |
return -1; // Limit greater than or equal to 7, otherwise close |
|
122 |
} |
|
123 |
return logretentiondays; |
|
124 |
} |
|
125 |
|
|
126 |
public XxlJobLogDao getXxlJobLogDao() { |
|
127 |
return xxlJobLogDao; |
|
128 |
} |
|
129 |
|
|
130 |
public XxlJobInfoDao getXxlJobInfoDao() { |
|
131 |
return xxlJobInfoDao; |
|
132 |
} |
|
133 |
|
|
134 |
public XxlJobRegistryDao getXxlJobRegistryDao() { |
|
135 |
return xxlJobRegistryDao; |
|
136 |
} |
|
137 |
|
|
138 |
public XxlJobGroupDao getXxlJobGroupDao() { |
|
139 |
return xxlJobGroupDao; |
|
140 |
} |
|
141 |
|
|
142 |
public XxlJobLogReportDao getXxlJobLogReportDao() { |
|
143 |
return xxlJobLogReportDao; |
|
144 |
} |
|
145 |
|
|
146 |
public JavaMailSender getMailSender() { |
|
147 |
return mailSender; |
|
148 |
} |
|
149 |
|
|
150 |
public DataSource getDataSource() { |
|
151 |
return dataSource; |
|
152 |
} |
|
153 |
|
|
154 |
public JobAlarmer getJobAlarmer() { |
|
155 |
return jobAlarmer; |
|
156 |
} |
|
157 |
|
|
158 |
} |