use of org.apache.commons.configuration.AbstractConfiguration in project archaius by Netflix.
the class DynamicPropertyUpdaterTest method testUpdateProperties.
/**
* Test method for {@link com.charter.aesd.archaius.DynamicPropertyUpdater#updateProperties(com.netflix.config.WatchedUpdateResult, org.apache.commons.configuration.Configuration, boolean)}.
* @throws InterruptedException
*/
@Test
public void testUpdateProperties() throws InterruptedException {
AbstractConfiguration.setDefaultListDelimiter(',');
AbstractConfiguration config = new ConcurrentCompositeConfiguration();
config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
MyListener.resetCount();
config.setProperty("test", "host,host1,host2");
config.setProperty("test12", "host12");
Map<String, Object> added = Maps.newHashMap();
added.put("test.host", "test,test1");
Map<String, Object> changed = Maps.newHashMap();
changed.put("test", "host,host1");
changed.put("test.host", "");
dynamicPropertyUpdater.updateProperties(WatchedUpdateResult.createIncremental(added, changed, null), config, false);
assertEquals("", config.getProperty("test.host"));
assertEquals(2, ((CopyOnWriteArrayList) (config.getProperty("test"))).size());
assertTrue(((CopyOnWriteArrayList) (config.getProperty("test"))).contains("host"));
assertTrue(((CopyOnWriteArrayList) (config.getProperty("test"))).contains("host1"));
assertEquals(5, MyListener.count);
}
use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.
the class ArchaiusAutoConfiguration method configureArchaius.
protected static void configureArchaius(ConfigurableEnvironmentConfiguration envConfig, ConfigurableEnvironment env, List<AbstractConfiguration> externalConfigurations) {
if (initialized.compareAndSet(false, true)) {
String appName = env.getProperty("spring.application.name");
if (appName == null) {
appName = "application";
log.warn("No spring.application.name found, defaulting to 'application'");
}
System.setProperty(DeploymentContext.ContextKey.appId.getKey(), appName);
ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
// etc...)
if (externalConfigurations != null) {
for (AbstractConfiguration externalConfig : externalConfigurations) {
config.addConfiguration(externalConfig);
}
}
config.addConfiguration(envConfig, ConfigurableEnvironmentConfiguration.class.getSimpleName());
defaultURLConfig = new DynamicURLConfiguration();
try {
config.addConfiguration(defaultURLConfig, URL_CONFIG_NAME);
} catch (Throwable ex) {
log.error("Cannot create config from " + defaultURLConfig, ex);
}
// TODO: sys/env above urls?
if (!Boolean.getBoolean(DISABLE_DEFAULT_SYS_CONFIG)) {
SystemConfiguration sysConfig = new SystemConfiguration();
config.addConfiguration(sysConfig, SYS_CONFIG_NAME);
}
if (!Boolean.getBoolean(DISABLE_DEFAULT_ENV_CONFIG)) {
EnvironmentConfiguration environmentConfiguration = new EnvironmentConfiguration();
config.addConfiguration(environmentConfiguration, ENV_CONFIG_NAME);
}
ConcurrentCompositeConfiguration appOverrideConfig = new ConcurrentCompositeConfiguration();
config.addConfiguration(appOverrideConfig, APPLICATION_PROPERTIES);
config.setContainerConfigurationIndex(config.getIndexOfConfiguration(appOverrideConfig));
addArchaiusConfiguration(config);
} else {
// TODO: reinstall ConfigurationManager
log.warn("Netflix ConfigurationManager has already been installed, unable to re-install");
}
}
use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.
the class ArchaiusEndpoint method invoke.
@ReadOperation
public Map<String, Object> invoke() {
Map<String, Object> map = new LinkedHashMap<>();
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
if (config instanceof ConcurrentCompositeConfiguration) {
ConcurrentCompositeConfiguration composite = (ConcurrentCompositeConfiguration) config;
for (Configuration item : composite.getConfigurations()) {
append(map, item);
}
} else {
append(map, config);
}
return map;
}
use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.
the class ArchaiusAutoConfigurationTests method configurationCreated.
@Test
public void configurationCreated() {
this.context = new AnnotationConfigApplicationContext(ArchaiusAutoConfiguration.class);
AbstractConfiguration config = this.context.getBean(ConfigurableEnvironmentConfiguration.class);
assertNotNull(config.getString("java.io.tmpdir"));
}
use of org.apache.commons.configuration.AbstractConfiguration in project hazelcast-eureka by hazelcast.
the class HazelcastClientTestCase method configure.
private void configure(String namespace, String appName) {
URI serviceUri = server.getServiceURI();
AbstractConfiguration configInstance = ConfigurationManager.getConfigInstance();
configInstance.setProperty(namespace + ".serviceUrl.default", serviceUri.toString());
configInstance.setProperty(namespace + ".port", serviceUri.getPort());
configInstance.setProperty(namespace + ".name", appName);
}
Aggregations