Java 类org.apache.commons.configuration.EnvironmentConfiguration 实例源码

项目:incubator-servicecomb-java-chassis    文件:ConfigUtil.java   
public static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
  ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();

  duplicateServiceCombConfigToCse(config,
      new ConcurrentMapConfiguration(new SystemConfiguration()),
      "configFromSystem");
  duplicateServiceCombConfigToCse(config,
      convertEnvVariable(new ConcurrentMapConfiguration(new EnvironmentConfiguration())),
      "configFromEnvironment");
  duplicateServiceCombConfigToCse(config,
      new DynamicConfiguration(
          new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()),
      "configFromYamlFile");

  return config;
}
项目:glados-wiki    文件:GroovyConfigurer.java   
private Optional<String> getUserConfigFilename() throws NamingException {
    CompositeConfiguration cc = new CompositeConfiguration();
    JNDIConfiguration jndi = new JNDIConfiguration();
    EnvironmentConfiguration env = new EnvironmentConfiguration();
    SystemConfiguration jvm = new SystemConfiguration();
    cc.addConfiguration(jvm);
    cc.addConfiguration(env);
    cc.addConfiguration(jndi);
    //
    final String CONFIG_FILENAME = (String) cc.getProperty("gladosWiki_configFile");
    if (false == Strings.isNullOrEmpty(CONFIG_FILENAME)) {
        LOG.debug(String.format("LOCAL-CONFIG CONFIG_FILENAME = %s", CONFIG_FILENAME));
        return Optional.of(CONFIG_FILENAME);
    } else {
        return Optional.absent();
    }
}
项目:spring-cloud-netflix    文件:ArchaiusEndpoint.java   
private void append(Map<String, Object> map, Configuration config) {
    if (config instanceof ConfigurableEnvironmentConfiguration) {
        return;
    }
    if (config instanceof SystemConfiguration) {
        return;
    }
    if (config instanceof EnvironmentConfiguration) {
        return;
    }
    for (Iterator<String> iter = config.getKeys(); iter.hasNext();) {
        String key = iter.next();
        map.put(key, config.getProperty(key));
    }
}
项目:data-driven-framework    文件:DDConfig.java   
/**
 * Returns the configuration data. If configuration data is null, method first attempts to
 * create a configuration data from JVM's system properties.<br>
 * 
 * @return test configuration data
 */
public synchronized Configuration getData() {
    if (data != null) {
        return data;
    }
    final HierarchicalConfiguration cfg = new HierarchicalConfiguration();
    cfg.copy(new EnvironmentConfiguration());// copy the environment variables.
    cfg.copy(new SystemConfiguration());// JVM args
    log.debug("Configuration data from Env:\n" + ConfigurationUtils.toString(cfg));
    return data = prepareData(cfg);
}
项目:spring-cloud-netflix    文件:ArchaiusAutoConfiguration.java   
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();

        // support to add other Configurations (Jdbc, DynamoDb, Zookeeper, jclouds,
        // 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");
    }
}