org.apache.commons.configuration.SystemConfiguration Java Examples
The following examples show how to use
org.apache.commons.configuration.SystemConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) { ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration(); duplicateCseConfigToServicecomb(config, new ConcurrentMapConfiguration(new SystemConfiguration()), "configFromSystem"); duplicateCseConfigToServicecomb(config, convertEnvVariable(new ConcurrentMapConfiguration(new EnvironmentConfiguration())), "configFromEnvironment"); // If there is extra configurations, add it into config. EXTRA_CONFIG_MAP.entrySet() .stream() .filter(mapEntry -> !mapEntry.getValue().isEmpty()) .forEachOrdered(configMapEntry -> duplicateCseConfigToServicecomb(config, new ConcurrentMapConfiguration(configMapEntry.getValue()), configMapEntry.getKey())); // we have already copy the cse config to the serviceComb config when we load the config from local yaml files // hence, we do not need duplicate copy it. config.addConfiguration(new DynamicConfiguration( new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()), "configFromYamlFile"); duplicateCseConfigToServicecombAtFront(config, new ConcurrentMapConfiguration(ConfigMapping.getConvertedMap(config)), "configFromMapping"); return config; }
Example #2
Source File: TestYAMLConfigurationSource.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void testFullOperation() { // configuration from system properties ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration()); // configuration from yaml file DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigSource(), new NeverStartPollingScheduler()); // create a hierarchy of configuration that makes // 1) dynamic configuration source override system properties ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration(); finalConfig.addConfiguration(configFromYamlFile, "yamlConfig"); finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig"); Assert.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5); Object o = finalConfig.getProperty("zq"); @SuppressWarnings("unchecked") List<Map<String, Object>> listO = (List<Map<String, Object>>) o; Assert.assertEquals(3, listO.size()); }
Example #3
Source File: SshdSettingsBuilder.java From artifactory_ssh_proxy with Apache License 2.0 | 6 votes |
protected Configuration createConfiguration(final String overriddenPath) { try { if (LOGGER.isDebugEnabled()) { LOGGER.debug("got overriddenPath {}", overriddenPath); } CompositeConfiguration compositeConfig = new CompositeConfiguration(); // TODO: see how Systems and properties interact. compositeConfig.addConfiguration(new SystemConfiguration()); compositeConfig.addConfiguration(findPropertiesConfiguration(overriddenPath)); return compositeConfig; } catch (ConfigurationException e) { throw new RuntimeException(e); } }
Example #4
Source File: URLUtil.java From spring-cloud-huawei with Apache License 2.0 | 5 votes |
private static List<String> getEnvURL(String systemServer) { SystemConfiguration sysConfig = new SystemConfiguration(); EnvironmentConfiguration envConfig = new EnvironmentConfiguration(); String sysURL = sysConfig.getString(systemServer); String envURL = envConfig.getString(systemServer); if (StringUtils.isEmpty(sysURL) && StringUtils.isEmpty(envURL)) { sysURL = sysConfig.getString(SYSTEM_KEY_BOTH); envURL = envConfig.getString(SYSTEM_KEY_BOTH); } return StringUtils.isEmpty(sysURL) ? dealMultiUrl(envURL) : dealMultiUrl(sysURL); }
Example #5
Source File: DatabaseJobHistoryStoreSchemaManager.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Override public void run(String[] args) throws Exception { if (args.length < 1 || args.length > 2) { printUsage(); } Closer closer = Closer.create(); try { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(new SystemConfiguration()); if (args.length == 2) { config.addConfiguration(new PropertiesConfiguration(args[1])); } Properties properties = getProperties(config); DatabaseJobHistoryStoreSchemaManager schemaManager = closer.register(DatabaseJobHistoryStoreSchemaManager.builder(properties).build()); if (String.CASE_INSENSITIVE_ORDER.compare("migrate", args[0]) == 0) { schemaManager.migrate(); } else if (String.CASE_INSENSITIVE_ORDER.compare("info", args[0]) == 0) { schemaManager.info(); } else { printUsage(); } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
Example #6
Source File: CuratorFrameworkBuilder.java From chassis with Apache License 2.0 | 5 votes |
private ConcurrentCompositeConfiguration buildConfiguration() { ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration(); configuration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration())); configuration.addConfiguration(this.configuration); configuration.addConfiguration(defaults); return configuration; }
Example #7
Source File: ConfigurationBuilder.java From chassis with Apache License 2.0 | 5 votes |
/** * Build the Configuration * * @return the configuration */ public AbstractConfiguration build() { initApplicationFileConfiguration(); initAppVersion(); initApplicationConfiguration(); initModuleConfiguration(); ConcurrentCompositeConfiguration finalConfiguration = new ConcurrentCompositeConfiguration(); if (addSystemConfigs) { finalConfiguration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration())); } finalConfiguration.addProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion); addServerInstanceProperties(finalConfiguration); if (applicationConfiguration == null) { LOGGER.warn("\n\n ****** Default configuration being used ******\n client application \"" + appName + "\" is being configured with modules defaults. Defaults should only be used in development environments.\n In non-developement environments, a configuration provider should be used to configure the client application and it should define ALL required configuration properties.\n"); finalConfiguration.addConfiguration(applicationFileConfiguration); finalConfiguration.addConfiguration(moduleDefaultConfiguration); } else { finalConfiguration.addConfiguration(applicationConfiguration); finalConfiguration.addConfiguration(applicationFileConfiguration); } finalConfiguration.setProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion); configureArchaius(finalConfiguration); logConfiguration(finalConfiguration); return finalConfiguration; }
Example #8
Source File: ConfigurationHelperTest.java From googleads-java-lib with Apache License 2.0 | 5 votes |
@Test public void testCreateCombinedConfiguration_justSystem() throws Exception { SystemConfiguration systemConfig = new SystemConfiguration(); systemConfig.setTrimmingDisabled(true); assertContains(systemConfig, configurationHelper.createCombinedConfiguration(null, null)); }
Example #9
Source File: SSLOptionTest.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Test public void testSSLOptionYaml() { // configuration from yaml files: default microservice.yaml DynamicConfiguration configFromYamlFile = new DynamicConfiguration(yamlConfigSource(), new FixedDelayPollingScheduler()); // configuration from system properties ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration()); // create a hierarchy of configuration that makes // 1) dynamic configuration source override system properties ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration(); finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig"); finalConfig.addConfiguration(configFromYamlFile, "configFromYamlFile"); ConfigurationManager.install(finalConfig); SSLOption option = SSLOption.buildFromYaml("server"); String protocols = option.getProtocols(); option.setProtocols(protocols); Assert.assertEquals("TLSv1.2,TLSv1.1,TLSv1,SSLv2Hello", protocols); String ciphers = option.getCiphers(); option.setCiphers(ciphers); Assert.assertEquals( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SH" + "A,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA", ciphers); boolean authPeer = option.isAuthPeer(); option.setAuthPeer(authPeer); Assert.assertEquals(true, authPeer); boolean checkCNHost = option.isCheckCNHost(); option.setCheckCNHost(checkCNHost); Assert.assertEquals(true, checkCNHost); boolean checkCNWhite = option.isCheckCNWhite(); option.setCheckCNWhite(checkCNWhite); Assert.assertEquals(true, checkCNWhite); String checkCNWhiteFile = option.getCheckCNWhiteFile(); option.setCheckCNWhiteFile(checkCNWhiteFile); Assert.assertEquals("white.list", checkCNWhiteFile); boolean allowRenegociate = option.isAllowRenegociate(); option.setAllowRenegociate(allowRenegociate); Assert.assertEquals(false, allowRenegociate); String storePath = option.getStorePath(); option.setStorePath(storePath); Assert.assertEquals("internal", storePath); String trustStore = option.getTrustStore(); option.setTrustStore(trustStore); Assert.assertEquals("trust.jks", trustStore); String trustStoreType = option.getTrustStoreType(); option.setTrustStoreType(trustStoreType); Assert.assertEquals("JKS", trustStoreType); String trustStoreValue = option.getTrustStoreValue(); option.setTrustStoreValue(trustStoreValue); Assert.assertEquals("Changeme_123", trustStoreValue); String keyStore = option.getKeyStore(); option.setKeyStore(keyStore); Assert.assertEquals("server.p12", keyStore); String keyStoreType = option.getKeyStoreType(); option.setKeyStoreType(keyStoreType); Assert.assertEquals("PKCS12", keyStoreType); String keyStoreValue = option.getKeyStoreValue(); option.setKeyStoreValue(keyStoreValue); Assert.assertEquals("Changeme_123", keyStoreValue); String crl = option.getCrl(); option.setCrl(crl); Assert.assertEquals("revoke.crl", crl); option.setSslCustomClass("123"); SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass()); Assert.assertArrayEquals(custom.decode("123".toCharArray()), "123".toCharArray()); }
Example #10
Source File: ServerConfiguration.java From distributedlog with Apache License 2.0 | 4 votes |
public ServerConfiguration() { super(); addConfiguration(new SystemConfiguration()); }
Example #11
Source File: DistributedLogConfiguration.java From distributedlog with Apache License 2.0 | 4 votes |
/** * Construct distributedlog configuration with default settings. * It also loads the settings from system properties. */ public DistributedLogConfiguration() { super(); // add configuration for system properties addConfiguration(new SystemConfiguration()); }
Example #12
Source File: DistributedLogConfiguration.java From distributedlog with Apache License 2.0 | 4 votes |
/** * Construct distributedlog configuration with default settings. * It also loads the settings from system properties. */ public DistributedLogConfiguration() { super(); // add configuration for system properties addConfiguration(new SystemConfiguration()); }
Example #13
Source File: ServerConfiguration.java From distributedlog with Apache License 2.0 | 4 votes |
public ServerConfiguration() { super(); addConfiguration(new SystemConfiguration()); }
Example #14
Source File: ConversionTool.java From product-private-paas with Apache License 2.0 | 4 votes |
/** * Method to get configuration details */ public static void readInitialConfiguration() throws ConfigurationException { final PropertiesConfiguration propsConfig = new PropertiesConfiguration( System.getProperty(Constants.CONFIGURATION_FILE_NAME)); SystemConfiguration.setSystemProperties(propsConfig); }