REM:
1.  监视设备配置项支持自动更新
This commit is contained in:
HuangXin 2021-10-28 16:10:48 +08:00
parent d5d622e717
commit ac7ec41aa5
1 changed files with 9 additions and 0 deletions

View File

@ -3,7 +3,9 @@ package com.dispose.config;
import com.dispose.common.DisposeConfigValue; import com.dispose.common.DisposeConfigValue;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -13,13 +15,16 @@ import java.util.Optional;
/** /**
* The type Device log configure. * The type Device log configure.
*
* @author xajhu * @author xajhu
*/ */
@Getter @Getter
@Setter @Setter
@Component @Component
@RefreshScope
@ConfigurationProperties(prefix = "device") @ConfigurationProperties(prefix = "device")
@Configuration @Configuration
@Slf4j
public class DeviceLogConfigure { public class DeviceLogConfigure {
/** /**
* The Log hosts. * The Log hosts.
@ -31,10 +36,14 @@ public class DeviceLogConfigure {
*/ */
@PostConstruct @PostConstruct
private void initGlobalValue() { private void initGlobalValue() {
DisposeConfigValue.LOG_HOSTS.clear();
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) { for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
if (s.toLowerCase(Locale.ROOT).startsWith("http")) { if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
DisposeConfigValue.LOG_HOSTS.add(s); DisposeConfigValue.LOG_HOSTS.add(s);
} }
} }
log.debug("Log device: {}", DisposeConfigValue.LOG_HOSTS);
} }
} }