use of com.netflix.config.ConcurrentMapConfiguration in project chassis by Kixeye.
the class ConfigurationBuilder method initApplicationFileConfiguration.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initApplicationFileConfiguration() {
if (applicationPropertiesPath == null) {
LOGGER.debug("No client application properties to configure. Skipping...");
applicationFileConfiguration = new ConcurrentMapConfiguration();
return;
}
this.applicationFileConfiguration = new ConcurrentCompositeConfiguration();
String path = SystemPropertyUtils.resolvePlaceholders(applicationPropertiesPath);
LOGGER.debug("Configuring client application properties from path " + applicationPropertiesPath);
Map applicationProperties = new Properties();
if (SystemUtils.IS_OS_WINDOWS) {
if (path.startsWith("file://")) {
if (!path.startsWith("file:///")) {
path = path.replaceFirst(Pattern.quote("file://"), "file:///");
}
}
}
try (InputStream is = resourceLoader.getResource(path).getInputStream()) {
((Properties) applicationProperties).load(is);
} catch (Exception e) {
BootstrapException.resourceLoadingFailed(path, applicationPropertiesPath, e);
}
Map environmentApplicationProperties = getEnvironmentSpecificProperties(path);
if (environmentApplicationProperties != null) {
((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(environmentApplicationProperties));
}
((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(applicationProperties));
if (applicationFileConfiguration.containsKey(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName())) {
this.publishDefaults = applicationFileConfiguration.getBoolean(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName());
}
}
use of com.netflix.config.ConcurrentMapConfiguration in project chassis by Kixeye.
the class ConfigurationBuilder method build.
/**
* Build the Configuration
*
* @return the configuration
*/
public AbstractConfiguration build() {
initApplicationFileConfiguration();
initAppVersion();
initApplicationConfiguration();
initModuleConfiguration();
ConcurrentCompositeConfiguration finalConfiguration = new ConcurrentCompositeConfiguration();
if (addSystemConfigs) {
finalConfiguration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration()));
}
finalConfiguration.addProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion);
addServerInstanceProperties(finalConfiguration);
if (applicationConfiguration == null) {
LOGGER.warn("\n\n ****** Default configuration being used ******\n client application \"" + appName + "\" is being configured with modules defaults. Defaults should only be used in development environments.\n In non-developement environments, a configuration provider should be used to configure the client application and it should define ALL required configuration properties.\n");
finalConfiguration.addConfiguration(applicationFileConfiguration);
finalConfiguration.addConfiguration(moduleDefaultConfiguration);
} else {
finalConfiguration.addConfiguration(applicationConfiguration);
finalConfiguration.addConfiguration(applicationFileConfiguration);
}
finalConfiguration.setProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion);
configureArchaius(finalConfiguration);
logConfiguration(finalConfiguration);
return finalConfiguration;
}
use of com.netflix.config.ConcurrentMapConfiguration in project chassis by Kixeye.
the class CuratorFrameworkBuilder method buildConfiguration.
private ConcurrentCompositeConfiguration buildConfiguration() {
ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
configuration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration()));
configuration.addConfiguration(this.configuration);
configuration.addConfiguration(defaults);
return configuration;
}
use of com.netflix.config.ConcurrentMapConfiguration in project java-chassis by ServiceComb.
the class TestYAMLConfigurationSource method testFullOperation.
@Test
public void testFullOperation() {
// configuration from system properties
ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
// configuration from yaml file
YAMLConfigurationSource configSource = new YAMLConfigurationSource();
DynamicConfiguration configFromYamlFile = new DynamicConfiguration(configSource, new NeverStartPollingScheduler());
// create a hierarchy of configuration that makes
// 1) dynamic configuration source override system properties
ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
ConfigurationManager.install(finalConfig);
DynamicDoubleProperty myprop = DynamicPropertyFactory.getInstance().getDoubleProperty("trace.handler.sampler.percent", 0.1);
Assert.assertEquals(0.5, myprop.getValue().doubleValue(), 0.5);
// DynamicStringListProperty property = new DynamicStringListProperty("trace.handler.tlist", "|", DynamicStringListProperty.DEFAULT_DELIMITER);
// List<String> ll = property.get();
// for (String s : ll) {
// System.out.println(s);
// }
Object o = ConfigUtil.getProperty("zq");
@SuppressWarnings("unchecked") List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
Assert.assertEquals(3, listO.size());
}
Aggregations