use of org.apache.commons.configuration.EnvironmentConfiguration in project incubator-servicecomb-java-chassis by apache.
the class ConfigUtil method createLocalConfig.
private static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
duplicateCseConfigToServicecomb(config, new ConcurrentMapConfigurationExt(new SystemConfiguration()), "configFromSystem");
duplicateCseConfigToServicecomb(config, convertEnvVariable(new ConcurrentMapConfigurationExt(new EnvironmentConfiguration())), "configFromEnvironment");
// If there is extra configurations, add it into config.
EXTRA_CONFIG_MAP.entrySet().stream().filter(mapEntry -> !mapEntry.getValue().isEmpty()).forEachOrdered(configMapEntry -> duplicateCseConfigToServicecomb(config, new ConcurrentMapConfigurationExt(configMapEntry.getValue()), configMapEntry.getKey()));
// we have already copy the cse config to the serviceComb config when we load the config from local yaml files
// hence, we do not need duplicate copy it.
config.addConfiguration(new DynamicConfigurationExt(new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()), "configFromYamlFile");
duplicateCseConfigToServicecombAtFront(config, new ConcurrentMapConfigurationExt(ConfigMapping.getConvertedMap(config)), "configFromMapping");
return config;
}
use of org.apache.commons.configuration.EnvironmentConfiguration in project incubator-servicecomb-java-chassis by apache.
the class MicroserviceFactory method createMicroserviceFromConfiguration.
private Microservice createMicroserviceFromConfiguration(Configuration configuration) {
Microservice microservice = new Microservice();
EnvironmentConfiguration envConfig = new EnvironmentConfiguration();
if (!StringUtils.isEmpty(envConfig.getString(APP_MAPPING)) && !StringUtils.isEmpty(envConfig.getString(envConfig.getString(APP_MAPPING)))) {
microservice.setAppId(envConfig.getString(envConfig.getString(APP_MAPPING)));
} else {
microservice.setAppId(BootStrapProperties.readApplication(configuration));
}
if (!StringUtils.isEmpty(envConfig.getString(SERVICE_MAPPING)) && !StringUtils.isEmpty(envConfig.getString(envConfig.getString(SERVICE_MAPPING)))) {
microservice.setServiceName(envConfig.getString(envConfig.getString(SERVICE_MAPPING)));
} else {
microservice.setServiceName(BootStrapProperties.readServiceName(configuration));
}
String version;
if (!StringUtils.isEmpty(envConfig.getString(VERSION_MAPPING)) && !StringUtils.isEmpty(envConfig.getString(envConfig.getString(VERSION_MAPPING)))) {
version = envConfig.getString(envConfig.getString(VERSION_MAPPING));
} else {
version = BootStrapProperties.readServiceVersion(configuration);
}
// just check version format
new Version(version);
microservice.setVersion(version);
microservice.setDescription(BootStrapProperties.readServiceDescription(configuration));
microservice.setLevel(BootStrapProperties.readServiceRole(configuration));
microservice.setPaths(ConfigurePropertyUtils.getMicroservicePaths(configuration));
Map<String, String> propertiesMap = MicroservicePropertiesLoader.INSTANCE.loadProperties(configuration);
microservice.setProperties(propertiesMap);
microservice.setEnvironment(BootStrapProperties.readServiceEnvironment(configuration));
// set alias name when allow cross app
if (microservice.allowCrossApp()) {
microservice.setAlias(Microservice.generateAbsoluteMicroserviceName(microservice.getAppId(), microservice.getServiceName()));
}
microservice.setFramework(createFramework());
microservice.setRegisterBy(CONFIG_DEFAULT_REGISTER_BY);
return microservice;
}
Aggregations