org.apache.commons.configuration2.CompositeConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration2.CompositeConfiguration. 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: Schema2MarkupConfigBuilder.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
protected static CompositeConfiguration getCompositeConfiguration(Configuration configuration) {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    compositeConfiguration.addConfiguration(new SystemConfiguration());
    compositeConfiguration.addConfiguration(configuration);
    compositeConfiguration.addConfiguration(getDefaultConfiguration());
    return compositeConfiguration;
}
 
Example #2
Source File: SimpleConfiguration.java    From fluo with Apache License 2.0 5 votes vote down vote up
/**
 * Loads configuration from InputStream. Later loads have lower priority.
 * 
 * @param in InputStream to load from
 * @since 1.2.0
 */
public void load(InputStream in) {
  try {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.getLayout().load(config, checkProps(in));
    ((CompositeConfiguration) internalConfig).addConfiguration(config);
  } catch (ConfigurationException e) {
    throw new IllegalArgumentException(e);
  }
}
 
Example #3
Source File: SimpleConfiguration.java    From fluo with Apache License 2.0 5 votes vote down vote up
/**
 * Loads configuration from File. Later loads have lower priority.
 * 
 * @param file File to load from
 * @since 1.2.0
 */
public void load(File file) {
  try (InputStream in = Files.newInputStream(file.toPath())) {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.getLayout().load(config, checkProps(in));
    ((CompositeConfiguration) internalConfig).addConfiguration(config);
  } catch (ConfigurationException | IOException e) {
    throw new IllegalArgumentException(e);
  }
}
 
Example #4
Source File: TemplateMessage.java    From carina with Apache License 2.0 5 votes vote down vote up
public void setEnvironmentConfiguration(CompositeConfiguration compositeConfiguration) {
    this.compositeConfiguration = compositeConfiguration;
    Iterator<?> keys = compositeConfiguration.getKeys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        propertiesStorage.put(key, compositeConfiguration.getProperty(key));
    }
}
 
Example #5
Source File: ConfigService.java    From maven-examples with GNU General Public License v3.0 4 votes vote down vote up
public ConfigService() {
    configs = new CompositeConfiguration();
    configs.addProperty("datastore", "app");
}
 
Example #6
Source File: ConfigurationProviderImpl.java    From cryptotrader with GNU Affero General Public License v3.0 4 votes vote down vote up
@VisibleForTesting
Configuration create(String versionPath, String sitePath, String defaultPath) {

    CompositeConfiguration composite = new CompositeConfiguration();

    try {

        createClasspath(versionPath).ifPresent(composite::addConfiguration);

        createSystem().ifPresent(composite::addConfiguration);

        createFilePath(sitePath).ifPresent(composite::addConfiguration);

        createClasspath(defaultPath).ifPresent(composite::addConfiguration);

    } catch (Exception e) {

        throw new RuntimeException("Failed to load configurations.", e);

    }

    return composite;

}
 
Example #7
Source File: SimpleConfiguration.java    From fluo with Apache License 2.0 4 votes vote down vote up
private void init() {
  CompositeConfiguration compositeConfig = new CompositeConfiguration();
  compositeConfig.setThrowExceptionOnMissing(true);
  internalConfig = compositeConfig;
}
 
Example #8
Source File: ConfigurationPropertiesFactoryBean.java    From commons-configuration with Apache License 2.0 4 votes vote down vote up
public ConfigurationPropertiesFactoryBean(final Configuration configuration)
{
    Assert.notNull(configuration, "configuration");
    this.compositeConfiguration = new CompositeConfiguration(configuration);
}
 
Example #9
Source File: ConfigurationPropertiesFactoryBean.java    From commons-configuration with Apache License 2.0 4 votes vote down vote up
public CompositeConfiguration getConfiguration()
{
    return compositeConfiguration;
}
 
Example #10
Source File: TemplateMessage.java    From carina with Apache License 2.0 4 votes vote down vote up
public CompositeConfiguration getCompositeConfiguration() {
    return compositeConfiguration;
}