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;
|
}
|
}
|