diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java index d7ab500..1ccef9c 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +//which로 커맨드가 설치되어있는지 확인함 @Component @RequiredArgsConstructor public class CommandInstalledValidator implements Validator { diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java index 085a2ed..b67745d 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java @@ -11,10 +11,13 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; //시스템의 전체적인 검증을 진행하는 클래스 //SystemValidatorConfig에 의해 빈으로 등록됩니다 @Slf4j +@Profile("prod") +@Component public final class SystemValidator { private final NetworkConfig config; private final SystemNetworkInterfaces systemNIs; diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java deleted file mode 100644 index 8660b74..0000000 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.whoz_in.log_writer.system_validator; - -import com.whoz_in.log_writer.common.SystemNetworkInterfaces; -import com.whoz_in.log_writer.config.NetworkConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - - -//TODO: Conditional로 뺄지 아니면 -@Slf4j -@Configuration -public class SystemValidatorConfig { - private final String profile; - private final NetworkConfig config; - private final SystemNetworkInterfaces systemNIs; - private final CommandInstalledValidator commandInstalledValidator; - private final NetworkInterfaceValidator networkInterfaceValidator; - - public SystemValidatorConfig(@Value("${spring.profiles.active}") String profile, - NetworkConfig config, - SystemNetworkInterfaces systemNIs, - CommandInstalledValidator commandInstalledValidator, - NetworkInterfaceValidator networkInterfaceValidator) { - this.profile = profile; - this.config = config; - this.systemNIs = systemNIs; - this.commandInstalledValidator = commandInstalledValidator; - this.networkInterfaceValidator = networkInterfaceValidator; - } - - @Bean - public SystemValidator systemValidator(){ - String osName = System.getProperty("os.name").toLowerCase(); - log.info("운영체제 - {}", osName); - log.info("스프링 프로필 - {}", profile); - - if (!profile.equals("prod") || !osName.contains("nux")){ - log.info("리눅스가 아니거나 스프링 프로필이 prod가 아니므로 시스템 검증을 수행하지 않습니다."); - return null; - } - return new SystemValidator(config, systemNIs, commandInstalledValidator, networkInterfaceValidator); - } -}