liulin
2024-07-30 ce04dfcdd664df7e791a63800cab2cd2d12e878c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.lunhan.xxx.host.job;
 
import com.lunhan.xxx.common.util.LoggerUtil;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
 
import java.util.Objects;
 
@Component
@ConfigurationProperties(prefix = "xxl-job")
public class XxlJobConfig {
    private String adminAddresses;
    private String accessToken;
    private String executorAppName;
    private String executorAddress;
    private String executorIp;
    private Integer executorPort;
    private String executorLogPath;
    private Integer executorLogRetentionDays;
 
    public String getAdminAddresses() {
        return adminAddresses;
    }
 
    public void setAdminAddresses(String adminAddresses) {
        this.adminAddresses = adminAddresses;
    }
 
    public String getAccessToken() {
        return accessToken;
    }
 
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
 
    public String getExecutorAppName() {
        return executorAppName;
    }
 
    public void setExecutorAppName(String executorAppName) {
        this.executorAppName = executorAppName;
    }
 
    public String getExecutorAddress() {
        return executorAddress;
    }
 
    public void setExecutorAddress(String executorAddress) {
        this.executorAddress = executorAddress;
    }
 
    public String getExecutorIp() {
        return executorIp;
    }
 
    public void setExecutorIp(String executorIp) {
        this.executorIp = executorIp;
    }
 
    public Integer getExecutorPort() {
        return executorPort;
    }
 
    public void setExecutorPort(Integer executorPort) {
        this.executorPort = executorPort;
    }
 
    public String getExecutorLogPath() {
        return executorLogPath;
    }
 
    public void setExecutorLogPath(String executorLogPath) {
        this.executorLogPath = executorLogPath;
    }
 
    public Integer getExecutorLogRetentionDays() {
        return executorLogRetentionDays;
    }
 
    public void setExecutorLogRetentionDays(Integer executorLogRetentionDays) {
        this.executorLogRetentionDays = executorLogRetentionDays;
    }
 
    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        LoggerUtil.get(XxlJobConfig.class).info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        if (Objects.nonNull(this.adminAddresses)) {
            xxlJobSpringExecutor.setAdminAddresses(this.adminAddresses);
        }
        if (Objects.nonNull(this.executorAppName)) {
            xxlJobSpringExecutor.setAppname(this.executorAppName);
        }
        if (Objects.nonNull(this.executorIp)) {
            xxlJobSpringExecutor.setIp(this.executorIp);
        }
        if (Objects.nonNull(this.executorPort)) {
            xxlJobSpringExecutor.setPort(this.executorPort);
        }
        if (Objects.nonNull(this.accessToken)) {
            xxlJobSpringExecutor.setAccessToken(this.accessToken);
        }
        if (Objects.nonNull(this.executorLogPath)) {
            xxlJobSpringExecutor.setLogPath(this.executorLogPath);
        }
        if (Objects.nonNull(this.executorLogRetentionDays)) {
            xxlJobSpringExecutor.setLogRetentionDays(this.executorLogRetentionDays);
        }
        return xxlJobSpringExecutor;
    }
}