org.apache.commons.configuration.CombinedConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration.CombinedConfiguration. 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: ConfigurationManager.java    From opensoc-streaming with Apache License 2.0 6 votes vote down vote up
/**
 * Common method to load content of all configuration resources defined in
 * 'config-definition.xml'.
 * 
 * @param configDefFilePath
 *          the config def file path
 * @return Configuration
 */
public static Configuration getConfiguration(String configDefFilePath) {
  if (configurationsCache.containsKey(configDefFilePath)) {
    return configurationsCache.get(configDefFilePath);
  }
  CombinedConfiguration configuration = null;
  synchronized (configurationsCache) {
    if (configurationsCache.containsKey(configDefFilePath)) {
      return configurationsCache.get(configDefFilePath);
    }
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    String fielPath = getConfigDefFilePath(configDefFilePath);
    LOGGER.info("loading from 'configDefFilePath' :" + fielPath);
    builder.setFile(new File(fielPath));
    try {
      configuration = builder.getConfiguration(true);
      configurationsCache.put(fielPath, configuration);
    } catch (ConfigurationException e) {
      LOGGER.info("Exception in loading property files.", e);
    }
  }
  return configuration;
}
 
Example #2
Source File: DatasetTemplate.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected static Configuration loadConfiguration() {
    try {
        CombinedConfiguration configuration = new CombinedConfigurationNoInterpolation();
        String datasetPropertiesFile = System.getProperty("dataset.properties.file");
        Validate.notEmpty(datasetPropertiesFile);
        configuration.addConfiguration(loadFromFile(new File(datasetPropertiesFile)));
        return configuration;
    } catch (ConfigurationException ex) {
        throw new RuntimeException(ex);
    }
}