|
|
|
@ -5,8 +5,10 @@ import cn.hutool.setting.dialect.Props;
|
|
|
|
|
import com.ctrip.framework.apollo.Config;
|
|
|
|
|
import com.java3y.austin.support.service.ConfigService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,12 +32,21 @@ public class ConfigServiceImpl implements ConfigService {
|
|
|
|
|
private Boolean enableApollo;
|
|
|
|
|
@Value("${apollo.bootstrap.namespaces}")
|
|
|
|
|
private String namespaces;
|
|
|
|
|
/**
|
|
|
|
|
* nacos配置
|
|
|
|
|
*/
|
|
|
|
|
@Value("${austin.nacos.enabled}")
|
|
|
|
|
private Boolean enableNacos;
|
|
|
|
|
@Resource
|
|
|
|
|
private ConfigurableApplicationContext configurableApplicationContext;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getProperty(String key, String defaultValue) {
|
|
|
|
|
if (enableApollo) {
|
|
|
|
|
Config config = com.ctrip.framework.apollo.ConfigService.getConfig(namespaces.split(StrUtil.COMMA)[0]);
|
|
|
|
|
return config.getProperty(key, defaultValue);
|
|
|
|
|
} else if (enableNacos) {
|
|
|
|
|
return configurableApplicationContext.getEnvironment().getProperty(key, defaultValue);
|
|
|
|
|
} else {
|
|
|
|
|
return props.getProperty(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|