List of usage examples for org.apache.commons.configuration CompositeConfiguration setThrowExceptionOnMissing
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
throwExceptionOnMissing
flag. From source file:org.apache.accumulo.core.conf.SiteConfiguration.java
@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "location of props is specified by an admin") private static ImmutableMap<String, String> createMap(URL accumuloPropsLocation, Map<String, String> overrides) { CompositeConfiguration config = new CompositeConfiguration(); config.setThrowExceptionOnMissing(false); config.setDelimiterParsingDisabled(true); PropertiesConfiguration propsConfig = new PropertiesConfiguration(); propsConfig.setDelimiterParsingDisabled(true); if (accumuloPropsLocation != null) { try {/* ww w .j a v a 2 s .c o m*/ propsConfig.load(accumuloPropsLocation.openStream()); } catch (IOException | ConfigurationException e) { throw new IllegalArgumentException(e); } } config.addConfiguration(propsConfig); // Add all properties in config file Map<String, String> result = new HashMap<>(); config.getKeys().forEachRemaining(key -> result.put(key, config.getString(key))); // Add all overrides overrides.forEach(result::put); // Add sensitive properties from credential provider (if set) String credProvider = result.get(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey()); if (credProvider != null) { org.apache.hadoop.conf.Configuration hadoopConf = new org.apache.hadoop.conf.Configuration(); hadoopConf.set(CredentialProviderFactoryShim.CREDENTIAL_PROVIDER_PATH, credProvider); for (Property property : Property.values()) { if (property.isSensitive()) { char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf, property.getKey()); if (value != null) { result.put(property.getKey(), new String(value)); } } } } return ImmutableMap.copyOf(result); }
From source file:org.apache.fluo.api.config.SimpleConfiguration.java
public SimpleConfiguration() { CompositeConfiguration compositeConfig = new CompositeConfiguration(); compositeConfig.setThrowExceptionOnMissing(true); compositeConfig.setDelimiterParsingDisabled(true); internalConfig = compositeConfig;/*from w w w . ja va2 s . c o m*/ }
From source file:uk.co.gidley.jmxmonitor.RegistryManager.java
private static CompositeConfiguration readConfiguration(String configurationFile) throws InitialisationException { // Read configuration file CompositeConfiguration config = new CompositeConfiguration(); config.setThrowExceptionOnMissing(true); try {//from ww w . j a v a 2 s. com config.addConfiguration(new PropertiesConfiguration(configurationFile)); } catch (ConfigurationException e) { logger.error("{}", e); throw new InitialisationException(e); } return config; }