Search in sources :

Example 51 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project zuul by Netflix.

the class RibbonConfig method setIfNotDefined.

private static void setIfNotDefined(String key, String value) {
    final AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    if (config.getString(key) == null) {
        LOG.info("Setting default NIWS Property " + key + "=" + value);
        config.setProperty(key, value);
    }
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration)

Example 52 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration 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);
    }
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration)

Example 53 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project java-chassis by ServiceComb.

the class CseDelegatingProxyUtils method addApplicationContext.

public static void addApplicationContext(ConfigurableApplicationContext context) {
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    config.clearProperty(APPLICATION_CONTEXT);
    config.setProperty(APPLICATION_CONTEXT, context);
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration)

Example 54 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project engine by craftercms.

the class MultiConfigurationBuilder method getConfiguration.

@Override
public Configuration getConfiguration() throws ConfigurationException {
    List<Configuration> configs = new ArrayList<>();
    // Last configurations should be loaded and added first so that they have greater priority.
    logger.info("Loading XML configurations in the order in which the properties will be resolved");
    for (int i = configPaths.length - 1; i >= 0; i--) {
        try {
            Resource resource = resourceLoader.getResource(configPaths[i]);
            if (resource.exists()) {
                XMLConfiguration config = new XMLConfiguration();
                config.load(resource.getInputStream());
                logger.info("XML configuration loaded from " + resource);
                configs.add(config);
            }
        } catch (Exception e) {
            throw new ConfigurationException("Unable to load configuration at " + configPaths[i], e);
        }
    }
    if (configs.size() > 1) {
        CombinedConfiguration combinedConfig = new CombinedConfiguration(new OverrideCombiner());
        for (Configuration config : configs) {
            combinedConfig.addConfiguration((AbstractConfiguration) config);
        }
        return combinedConfig;
    } else if (configs.size() == 1) {
        return configs.get(0);
    } else {
        return null;
    }
}
Also used : XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) Configuration(org.apache.commons.configuration.Configuration) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) CombinedConfiguration(org.apache.commons.configuration.CombinedConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Resource(org.springframework.core.io.Resource) CombinedConfiguration(org.apache.commons.configuration.CombinedConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) OverrideCombiner(org.apache.commons.configuration.tree.OverrideCombiner)

Example 55 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestConfigUtil method testConvertEnvVariable.

@Test
public void testConvertEnvVariable() {
    String someProperty = "cse_service_registry_address";
    AbstractConfiguration config = new DynamicConfiguration();
    config.addProperty(someProperty, "testing");
    AbstractConfiguration result = ConfigUtil.convertEnvVariable(config);
    assertThat(result.getString("cse.service.registry.address"), equalTo("testing"));
    assertThat(result.getString("cse_service_registry_address"), equalTo("testing"));
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) DynamicConfiguration(com.netflix.config.DynamicConfiguration) Test(org.junit.Test)

Aggregations

AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)80 Test (org.junit.Test)29 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)18 BeforeClass (org.junit.BeforeClass)10 Configuration (org.apache.commons.configuration.Configuration)9 URI (java.net.URI)6 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)6 HttpRequest (com.netflix.client.http.HttpRequest)5 ArrayList (java.util.ArrayList)5 DynamicConfiguration (com.netflix.config.DynamicConfiguration)4 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)4 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)4 HttpResponse (com.netflix.client.http.HttpResponse)3 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)3 ExpandedConfigurationListenerAdapter (com.netflix.config.ExpandedConfigurationListenerAdapter)3 LinkedHashMap (java.util.LinkedHashMap)3 Properties (java.util.Properties)3 AggregatedConfiguration (com.netflix.config.AggregatedConfiguration)2 ConfigurationManager (com.netflix.config.ConfigurationManager)2 DynamicURLConfiguration (com.netflix.config.DynamicURLConfiguration)2