Example usage for org.apache.commons.configuration ConfigurationException printStackTrace

List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Usage

From source file:com.shadwelldacunha.byteswipe.core.ConfigHandler.java

private void checkDefaults(String file) {
    try {/*ww  w. java  2s  . com*/
        PropertiesConfiguration defConfig = new PropertiesConfiguration(
                Utilities.getResource("byteswipe.properties"));
        Iterator<String> defKeys = defConfig.getKeys();

        //Add missing keys
        while (defKeys.hasNext()) {
            String key = defKeys.next();
            if (!config.containsKey(key)) {
                config.addProperty(key, defConfig.getProperty(key));
            }
        }

        config.save();
        //TODO: Handle exceptions
    } catch (ConfigurationException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
}

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

private void loadProperties(Binder binder) {

    try {//from  ww  w .j a v a  2  s .  c  om
        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:io.s4.meter.controller.ControllerModule.java

private void loadProperties(Binder binder) {

    try {/*from  w w  w. j  ava 2s . c o  m*/
        InputStream is = this.getClass().getResourceAsStream("/s4-meter.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:eu.eco2clouds.accounting.conf.ConfigurationTest.java

@Test
public void loadMonitoringPropertiesFile() {

    String propertiesFile = "MonitoringCollector.properties";

    File f = new File(etcConfiguration);
    if (f.exists()) {
        propertiesFile = etcConfiguration;
    }//from w w  w.j  av a2 s  .  co  m

    org.apache.commons.configuration.Configuration config;
    try {
        config = new PropertiesConfiguration(propertiesFile);

        assertEquals("root", config.getString("mysql.username"));
        assertEquals("1234", config.getString("mysql.password"));
        assertEquals("localhost/metricsdb", config.getString("mysql.host"));

    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:edu.emory.library.tast.submission.SubmissionAttributes.java

private SubmissionAttribute[] loadConfig() {
    try {/*www.ja  va 2 s. com*/
        ArrayList list = new ArrayList();
        Document document = new XMLConfiguration("submission-attributes.xml").getDocument();
        Node mainNode = document.getFirstChild();
        if (mainNode != null) {
            if (mainNode.getNodeType() == Node.ELEMENT_NODE) {
                NodeList attrs = mainNode.getChildNodes();
                for (int j = 0; j < attrs.getLength(); j++) {
                    if (attrs.item(j).getNodeType() == Node.ELEMENT_NODE) {
                        SubmissionAttribute attr = SubmissionAttribute.fromXML(attrs.item(j));
                        if (attr.getKey() == null) {
                            list.add(attr);
                        } else {
                            map.put(attr.getKey(), attr);
                        }
                    }
                }
            }
        }
        return (SubmissionAttribute[]) list.toArray(new SubmissionAttribute[] {});
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:edu.harvard.i2b2.util.I2b2PcoriTest.java

@Before
public void init() {
    try {/*from w w w.  ja v a  2  s  .c  o  m*/
        i2b2User = CoreConfig.getStringProperty("pcori.i2b2User");
        i2b2Password = CoreConfig.getStringProperty("pcori.i2b2Password");
        i2b2Url = CoreConfig.getStringProperty("pcori.i2b2Url");

        i2b2Domain = CoreConfig.getStringProperty("pcori.i2b2Domain");

        projectId = CoreConfig.getStringProperty("pcori.projectId");
        patientId = CoreConfig.getStringProperty("pcori.patientId");
        medPath = CoreConfig.getStringProperty("pcori.medPath");
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:io.s4.meter.generator.GeneratorModule.java

/**
 * Loads properties./*from w w w .ja  v a  2 s. c  o m*/
 * 
 * @param binder
 *            the Guice binder.
 */
private void loadProperties(Binder binder) {

    try {
        InputStream is = this.getClass().getResourceAsStream("/generator.properties");
        config = new PropertiesConfiguration();
        config.load(is);

        // System.out.println(ConfigurationUtils.toString(config));
        logger.info(ConfigurationUtils.toString(config));

        /* 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:io.s4.comm.Module.java

private void loadProperties(Binder binder) {

    try {//from  w w  w . j a va  2 s .c o  m
        InputStream is = this.getClass().getResourceAsStream("/s4-comm.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:it.grid.storm.authz.sa.conf.FileAuthzDBReader.java

public void onChangeAuthzDB(String authzDBName) throws AuthzDBReaderException {

    // Parsing of Authz DB.
    try {// w  w w.  ja va 2 s . com
        PropertiesConfiguration authzdb = new PropertiesConfiguration(authzDBName);
        FileAuthzDB fileAuthzDB = new FileAuthzDB(authzdb);
        authzDBs.put(authzDBName, fileAuthzDB);
        long pTime = System.currentTimeMillis();
        parsedTime.put(authzDBName, new Long(pTime));
        log.debug("Bound FileAuthzDBReader with {}", authzDBName);
    } catch (ConfigurationException ex) {
        ex.printStackTrace();
        throw new AuthzDBReaderException("Unable to parse the AuthzDB '" + authzDBName + "'.");
    }
    // Notify the watcher the accomplished parsing
    authzDBWatcher.authzDBParsed(authzDBName);
}

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

private void loadProperties(Binder binder) {

    try {// w w  w  .  ja v a  2s.  c o m
        InputStream is = this.getClass().getResourceAsStream("/s4-piper-example.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();
    }
}