Example usage for org.apache.commons.configuration BaseConfiguration setProperty

List of usage examples for org.apache.commons.configuration BaseConfiguration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration BaseConfiguration setProperty.

Prototype

public void setProperty(String key, Object value) 

Source Link

Usage

From source file:org.trustedanalytics.atk.giraph.io.titan.GiraphToTitanGraphFactory.java

/**
 * generateTitanConfiguration from Giraph configuration
 *
 * @param hadoopConfig : Giraph configuration
 * @param prefix : prefix to remove for Titan
 * @return BaseConfiguration//from  w  w  w .  j a v  a2 s  .c o  m
 */
public static BaseConfiguration createTitanBaseConfiguration(Configuration hadoopConfig, String prefix) {

    BaseConfiguration titanConfig = new BaseConfiguration();
    Iterator<Map.Entry<String, String>> itty = hadoopConfig.iterator();

    while (itty.hasNext()) {
        Map.Entry<String, String> entry = itty.next();
        String key = entry.getKey();
        String value = entry.getValue();

        if (key.startsWith(prefix)) {
            titanConfig.setProperty(key.substring(prefix.length() + 1), value);
        }
    }
    return titanConfig;
}

From source file:org.xwiki.configuration.internal.CloudConfigurationSource.java

/**
 * Load remapping definitions from the remapping file and provide them as a configuration source.
 *
 * @return A configuration source containing the remappings. null if the file is not present.
 * @throws Exception if there is an error loading the file.
 *///  w  ww. ja v  a2 s  .  c o  m
private ConfigurationSource loadRemappings() throws Exception {
    InputStream is = this.environment.getResourceAsStream(REMAPPING_FILE);
    if (is == null) {
        return null;
    }

    Properties properties = new Properties();
    try {
        properties.load(is);
    } catch (Exception e) {
        throw new InitializationException(String.format("Unable to read %s", REMAPPING_FILE), e);
    }

    BaseConfiguration configuration = new BaseConfiguration();
    for (String key : properties.stringPropertyNames()) {
        configuration.setProperty(key, properties.get(key));
    }

    CommonsConfigurationSource commonsConfigurationSource = new CommonsConfigurationSource();
    commonsConfigurationSource.setConfiguration(configuration);

    return commonsConfigurationSource;
}

From source file:org.xwiki.configuration.internal.SystemEnvironmentConfigurationSource.java

@Override
public void initialize() throws InitializationException {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setDelimiterParsingDisabled(true);

    Map<String, String> environment = System.getenv();
    for (String key : environment.keySet()) {
        configuration.setProperty(key, environment.get(key));
    }//from   w w  w . ja  v  a 2  s  .  co m

    setConfiguration(configuration);
}

From source file:org.xwiki.configuration.internal.SystemPropertiesConfigurationSource.java

@Override
public void initialize() throws InitializationException {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setDelimiterParsingDisabled(true);

    Properties properties = System.getProperties();
    for (String key : properties.stringPropertyNames()) {
        configuration.setProperty(key, properties.get(key));
    }//  ww  w.j  a va  2s . c  o  m

    setConfiguration(configuration);
}