Search in sources :

Example 6 with DynamicURLConfiguration

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

Aggregations

DynamicURLConfiguration (com.netflix.config.DynamicURLConfiguration)6 Test (org.junit.Test)4 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)2 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)2 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)2 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)2 File (java.io.File)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1