mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(headless)Improve javadocs and log messages.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.tencent.supersonic.common.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.service.SystemConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -10,7 +9,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public abstract class ParameterConfig {
|
||||
|
||||
@Autowired
|
||||
@@ -19,29 +17,28 @@ public abstract class ParameterConfig {
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
/**
|
||||
* @return system parameters to be set with user interface
|
||||
*/
|
||||
protected abstract List<Parameter> getSysParameters();
|
||||
|
||||
/**
|
||||
* Parameter value will be derived by following orders:
|
||||
* Parameter value will be derived in the following order:
|
||||
* 1. `system config` set with user interface
|
||||
* 2. `system property` set with application.yaml
|
||||
* 2. `system property` set with application.yaml file
|
||||
* 3. `default value` set with parameter declaration
|
||||
* @param parameter
|
||||
* @param parameter instance
|
||||
* @return parameter value
|
||||
*/
|
||||
public String getParameterValue(Parameter parameter) {
|
||||
String paramName = parameter.getName();
|
||||
String value = sysConfigService.getSystemConfig().getParameterByName(paramName);
|
||||
try {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
if (environment.containsProperty(paramName)) {
|
||||
value = environment.getProperty(paramName);
|
||||
} else {
|
||||
value = parameter.getDefaultValue();
|
||||
}
|
||||
if (StringUtils.isBlank(value)) {
|
||||
if (environment.containsProperty(paramName)) {
|
||||
value = environment.getProperty(paramName);
|
||||
} else {
|
||||
value = parameter.getDefaultValue();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to get parameter value for {} with exception: {}", paramName, e);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user