use of com.netflix.config.ConcurrentCompositeConfiguration 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.ConcurrentCompositeConfiguration 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.ConcurrentCompositeConfiguration 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.ConcurrentCompositeConfiguration in project java-chassis by ServiceComb.
the class TestPropertiesLoader method init.
@BeforeClass
public static void init() {
ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
YAMLConfigurationSource yamlConfigurationSource = new YAMLConfigurationSource();
DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigurationSource, new NeverStartPollingScheduler());
finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile");
ConfigurationManager.install(finalConfig);
}
use of com.netflix.config.ConcurrentCompositeConfiguration in project java-chassis by ServiceComb.
the class CseAutoConfiguration method addArchaiusConfiguration.
private void addArchaiusConfiguration(ConcurrentCompositeConfiguration config) {
if (ConfigurationManager.isConfigurationInstalled()) {
AbstractConfiguration installedConfiguration = ConfigurationManager.getConfigInstance();
if (installedConfiguration instanceof ConcurrentCompositeConfiguration) {
ConcurrentCompositeConfiguration configInstance = (ConcurrentCompositeConfiguration) installedConfiguration;
configInstance.addConfiguration(config);
} else {
installedConfiguration.append(config);
// if (!(installedConfiguration instanceof AggregatedConfiguration)) {
// //log.warn(
// // "Appending a configuration to an existing non-aggregated
// //installed configuration will have no effect");
// }
}
} else {
ConfigurationManager.install(config);
}
}
Aggregations