use of org.apache.commons.configuration.AbstractConfiguration in project java-chassis by ServiceComb.
the class ConfigurePropertyUtils method getPropertiesWithPrefix.
public static Map<String, String> getPropertiesWithPrefix(String prefix) {
Map<String, String> propertiesMap = new HashMap<>();
Object config = DynamicPropertyFactory.getBackingConfigurationSource();
if (null != config && AbstractConfiguration.class.isInstance(config)) {
AbstractConfiguration composite = (AbstractConfiguration) config;
Iterator<String> keysIterator = composite.getKeys(prefix);
while (keysIterator.hasNext()) {
String key = keysIterator.next();
propertiesMap.put(key.substring(prefix.length() + 1), String.valueOf(composite.getProperty(key)));
}
}
return propertiesMap;
}
use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.
the class ConfigUtil method installDynamicConfig.
public static void installDynamicConfig() {
if (ConfigurationManager.isConfigurationInstalled()) {
LOGGER.warn("Configuration installed by others, will ignore this configuration.");
return;
}
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
ConfigurationManager.install(dynamicConfig);
}
use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.
the class ConfigurationSpringInitializer method mergeProperties.
@Override
protected Properties mergeProperties() throws IOException {
Properties properties = super.mergeProperties();
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
Iterator<String> iter = config.getKeys();
while (iter.hasNext()) {
String key = iter.next();
Object value = config.getProperty(key);
properties.put(key, value);
}
return properties;
}
use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.
the class TestConfigUtil method duplicateServiceCombConfigToCseListValue.
@Test
public void duplicateServiceCombConfigToCseListValue() throws Exception {
List<String> list = Arrays.asList("a", "b");
AbstractConfiguration config = new DynamicConfiguration();
config.addProperty("servicecomb.list", list);
Deencapsulation.invoke(ConfigUtil.class, "duplicateServiceCombConfigToCse", config);
Object result = config.getProperty("cse.list");
assertThat(result, instanceOf(List.class));
assertThat(result, equalTo(list));
}
use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.
the class TestConfigUtil method testCreateDynamicConfigNoConfigCenterSPI.
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
new Expectations(SPIServiceUtils.class) {
{
SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
result = null;
}
};
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
List<ConfigModel> list = loader.getConfigModels();
Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
Assert.assertEquals(1, list.size());
Assert.assertNotEquals(DynamicWatchedConfiguration.class, ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
Aggregations