Search in sources :

Example 66 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project chassis by Kixeye.

the class PropertiesServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // get list of properties
    TreeSet<String> properties = new TreeSet<String>();
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    Iterator<String> keys = config.getKeys();
    while (keys.hasNext()) {
        String key = keys.next();
        Object value = config.getProperty(key);
        if ("aws.accessId".equals(key) || "aws.secretKey".equals(key) || "experiments-service.secret".equals(key) || "java.class.path".equals(key) || key.contains("framework.securityDefinition") || key.contains("password") || key.contains("secret")) {
            value = "*****";
        }
        properties.add(key + "=" + value.toString());
    }
    // write them out in sorted order
    for (String line : properties) {
        resp.getWriter().append(line).println();
    }
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) TreeSet(java.util.TreeSet)

Example 67 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project riposte by Nike-Inc.

the class ArchaiusServer method infrastructureInit.

/**
 * Initializes the Archaius system and configures the Netty leak detection level (if necessary).
 * DO NOT CALL THIS DIRECTLY. Use {@link #launchServer(String[])} when you're ready to start the server.
 */
protected void infrastructureInit() {
    MainClassUtils.setupJbossLoggingToUseSlf4j();
    try {
        Pair<String, String> appIdAndEnvironmentPair = MainClassUtils.getAppIdAndEnvironmentFromSystemProperties();
        ConfigurationManager.loadCascadedPropertiesFromResources(appIdAndEnvironmentPair.getLeft());
    } catch (IOException e) {
        throw new RuntimeException("Error loading Archaius properties", e);
    }
    AbstractConfiguration appConfig = ConfigurationManager.getConfigInstance();
    Function<String, Boolean> hasPropertyFunction = (propKey) -> appConfig.getProperty(propKey) != null;
    Function<String, String> propertyExtractionFunction = (propKey) -> {
        // Properties in Archaius might be a Collection or an Object.
        Object propValObj = appConfig.getProperty(propKey);
        return (propValObj instanceof Collection) ? ((Collection<?>) propValObj).stream().map(String::valueOf).collect(Collectors.joining(",")) : String.valueOf(propValObj);
    };
    Set<String> propKeys = new LinkedHashSet<>();
    appConfig.getKeys().forEachRemaining(propKeys::add);
    MainClassUtils.logApplicationPropertiesIfDebugActionsEnabled(hasPropertyFunction, propertyExtractionFunction, propKeys, false);
    MainClassUtils.setupNettyLeakDetectionLevel(hasPropertyFunction, propertyExtractionFunction);
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) MainClassUtils(com.nike.riposte.util.MainClassUtils) Collection(java.util.Collection) ConfigurationManager(com.netflix.config.ConfigurationManager) Set(java.util.Set) Server(com.nike.riposte.server.Server) IOException(java.io.IOException) Pair(com.nike.internal.util.Pair) ServerConfig(com.nike.riposte.server.config.ServerConfig) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) LinkedHashSet(java.util.LinkedHashSet) LinkedHashSet(java.util.LinkedHashSet) IOException(java.io.IOException) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) Collection(java.util.Collection)

Example 68 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project wildfly-swarm by wildfly-swarm.

the class ArchaiusCustomizer method customize.

@Override
public void customize() {
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    Set<ConfigKey> seen = new HashSet<>();
    this.configurableManager.configurables().stream().filter(this::shouldLink).forEach(e -> {
        try {
            Object value = e.currentValue();
            if (value != null) {
                config.setProperty(e.key().subkey(1).name(), e.currentValue());
            }
            seen.add(e.key());
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    });
    this.configurableManager.configView().allKeysRecursively().filter(this::shouldLink).filter(k -> !seen.contains(k)).forEach(k -> {
        Object value = this.configurableManager.configView().valueOf(k);
        if (value != null) {
            config.setProperty(k.subkey(1).name(), value);
        }
    });
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationManager(com.netflix.config.ConfigurationManager) Set(java.util.Set) Customizer(org.wildfly.swarm.spi.api.Customizer) Post(org.wildfly.swarm.spi.runtime.annotations.Post) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ConfigurableHandle(org.wildfly.swarm.container.runtime.ConfigurableHandle) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurableManager(org.wildfly.swarm.container.runtime.ConfigurableManager) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) PostConstruct(javax.annotation.PostConstruct) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Any(javax.enterprise.inject.Any) Instance(javax.enterprise.inject.Instance) ConfigKey(org.wildfly.swarm.spi.api.config.ConfigKey) HashSet(java.util.HashSet)

Example 69 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.

the class ArchaiusAutoConfiguration method addArchaiusConfiguration.

private static 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) AggregatedConfiguration(com.netflix.config.AggregatedConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration)

Example 70 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.

the class ArchaiusDelegatingProxyUtils 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)

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