Example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

Introduction

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

Prototype

public PropertiesConfiguration() 

Source Link

Document

Creates an empty PropertyConfiguration object which can be used to synthesize a new Properties file by adding values and then saving().

Usage

From source file:com.astamuse.asta4d.web.initialization.SimplePropertyFileInitializer.java

@Override
public void initliaze(InputStream input, WebApplicationConfiguration configuration) throws Exception {
    PropertiesConfiguration pc = new PropertiesConfiguration();
    pc.load(input);//w ww  .  ja  va  2 s.  c  o  m

    BeanUtilsBean bu = retrieveBeanUtilsBean();
    Iterator<String> keys = pc.getKeys();
    while (keys.hasNext()) {
        String key = keys.next();
        String value = pc.getString(key);
        fillConfiguration(configuration, bu, key, value);
    }

}

From source file:com.innovyt.transit.util.TopologyConfig.java

public TopologyConfig(String fileName) {

    config = new PropertiesConfiguration();
    try {/*w w  w. j  ava  2s .  c  o  m*/
        config.load(this.getClass().getResourceAsStream("/" + fileName));
    } catch (ConfigurationException e) {
        throw new RuntimeException(e.getMessage());
    }
}

From source file:br.com.ceosites.cachedproperties.cache.test.util.TestUtils.java

public static PropertiesConfiguration createFileConfiguration() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    try {//ww  w  . j  av a2  s .  c  o m
        configuration.load("src/main/resources/cached.properties");
    } catch (ConfigurationException ex) {
        Logger.getLogger(TestUtils.class.getName()).log(Level.SEVERE, null, ex);
    }
    return configuration;
}

From source file:com.medsphere.common.util.PropertyFileLocator.java

public PropertyFileLocator(String resourceDirectory, String fileName) throws IOException {
    propertiesConfiguration = new PropertiesConfiguration();
    properties = loadPropertiesFromFile(resourceDirectory, fileName);
}

From source file:com.mirth.connect.server.migration.Migrate3_1_0.java

private void migrateLog4jProperties() {
    PropertiesConfiguration log4jproperties = new PropertiesConfiguration();
    log4jproperties.setDelimiterParsingDisabled(true);
    log4jproperties.setFile(new File(ClassPathResource.getResourceURI("log4j.properties")));
    try {//from ww  w.jav  a  2  s  .  co m
        log4jproperties.load();

        String level = (String) log4jproperties.getProperty("log4j.logger.shutdown");
        if (level != null) {
            log4jproperties.setProperty("log4j.logger.undeploy", level);
            log4jproperties.clearProperty("log4j.logger.shutdown");
            Logger.getLogger("undeploy").setLevel(Level.toLevel(level));
        }

        level = (String) log4jproperties
                .getProperty("log4j.logger.com.mirth.connect.donkey.server.channel.RecoveryTask");
        if (StringUtils.isBlank(level)) {
            level = "INFO";
            log4jproperties.setProperty("log4j.logger.com.mirth.connect.donkey.server.channel.RecoveryTask",
                    level);
            Logger.getLogger("com.mirth.connect.donkey.server.channel.RecoveryTask")
                    .setLevel(Level.toLevel(level));
        }

        log4jproperties.save();
    } catch (ConfigurationException e) {
        logger.error("Failed to migrate log4j properties.");
    }
}

From source file:com.lehman.ic9.io.config.java

/**
 * Default constructor instantiate the config object.
 */
public config() {
    this.config = new PropertiesConfiguration();
}

From source file:com.aurel.track.util.PropertiesConfigurationHelper.java

/**
 * Obtain the Torque.properties from TRACKPLUS_HOME or if not available from the WAR.
 * @return//from w w w .j  ava  2 s  .com
 */
public static PropertiesConfiguration getPathnamePropFile(String absolutePath, String propFile) {
    PropertiesConfiguration propertiesConfiguration = null;
    File props = null;
    InputStream in = null;
    try {
        // First check if we have a configuration file pointed to by the environment
        if (absolutePath != null && !"".equals(absolutePath)) {
            props = new File(absolutePath + File.separator + propFile);
            LOGGER.debug("Trying file " + absolutePath + File.separator + propFile);
            if (props.exists() && props.canRead()) {
                LOGGER.info("Retrieving configuration from " + absolutePath + File.separator + propFile);
                in = new FileInputStream(props);
                propertiesConfiguration = new PropertiesConfiguration();
                propertiesConfiguration.load(in);
                in.close();
            }
        }

    } catch (Exception e) {
        LOGGER.warn("Could not read " + propFile + " from " + absolutePath + ". Exiting. " + e.getMessage());
    }
    return propertiesConfiguration;
}

From source file:com.dcsquare.fileauthplugin.utility.properties.CredentialProperties.java

/**
 * Initialize properties file/*w ww . j av  a  2s.c  o  m*/
 *
 * @param filename credential file name
 * @throws ConfigurationException is thrown if an error is encountered during loading of the file
 */
public CredentialProperties(String filename) throws ConfigurationException {
    propertiesConfiguration = new PropertiesConfiguration();

    PropertiesConfigurationLayout propertiesConfigurationLayout = new PropertiesConfigurationLayout(
            propertiesConfiguration);
    propertiesConfigurationLayout.setGlobalSeparator(":");
    propertiesConfiguration.setFile(new File(filename));
    propertiesConfiguration.load();

}

From source file:io.s4.example.model.Module.java

private void loadProperties(Binder binder) {

    try {//from  w  w  w . j  a v a  2 s .co  m
        InputStream is = this.getClass().getResourceAsStream("/model.properties");
        config = new PropertiesConfiguration();
        config.load(is);

        System.out.println(ConfigurationUtils.toString(config));
        // TODO - validate properties.

        /* Make all properties injectable. Do we need this? */
        Names.bindProperties(binder, ConfigurationConverter.getProperties(config));
    } catch (ConfigurationException e) {
        binder.addError(e);
        e.printStackTrace();
    }
}

From source file:es.bsc.autonomic.powermodeller.tools.VariableParser.java

public VariableParser(String filePath, List<String> dataSetHeader) {
    this.dataSetHeader = dataSetHeader;

    PropertiesConfiguration config = new PropertiesConfiguration();
    try {/*from  ww  w.j a  v  a 2  s.  co  m*/
        config.load(filePath);

        columns = new LinkedList(Arrays.asList(config.getStringArray("metrics")));
        for (String column : columns) {
            if (!dataSetHeader.contains(column)) {
                throw new VariableParserException(
                        "Selected metric '" + column + "' does not exist in the provided dataset");
            }
        }

        HashMap<String, String> varDictionary = processRawHM(populateHMFromKeyPrefix("var", config), null);
        newMetrics = processRawHM(populateHMFromKeyPrefix("newmetric", config), varDictionary);

    } catch (ConfigurationException e) {
        logger.error("Error while loading configuration file", e);
        throw new VariableParserException("Error while loading configuration file");
    }
}