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

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

Introduction

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

Prototype

public XMLConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Creates a new instance of XMLConfiguration.

Usage

From source file:com.servioticy.queueclient.QueueClient.java

private static QueueClient createInstance(String configPath) throws QueueClientException {
    QueueClient instance;/*from ww w.ja va 2 s  .c o  m*/
    File f = new File(configPath);
    if (!f.exists()) {
        if (Thread.currentThread().getContextClassLoader().getResource(configPath) == null) {
            return createInstance(configPath, "kestrel", "localhost:22133", "services");
        }
    }

    String type;
    HierarchicalConfiguration config;

    try {
        config = new XMLConfiguration(configPath);

        config.setExpressionEngine(new XPathExpressionEngine());

        if (!config.containsKey("defaultQueue/queueType")) {
            String errMsg = "No default queue. Fix your configuration file.";
            logger.error(errMsg);
            throw new QueueClientException(errMsg);
        }
        type = config.getString("defaultQueue/queueType");
        instance = createInstance(configPath, type,
                config.getString("defaultQueue/baseAddress", "localhost:22133"),
                config.getString("defaultQueue/relativeAddress", "services"));
    } catch (ConfigurationException e) {
        String errMsg = "'" + configPath + "' configuration file is malformed (" + e.getMessage() + ").";
        logger.error(errMsg);
        throw new QueueClientException(errMsg);
    }

    return instance;
}

From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopologyTest.java

@Test
public void testConfigure() throws Exception {
    URL resource = this.getClass().getResource("/TwitterTopology.xml");
    XMLConfiguration conf = new XMLConfiguration(resource);
    topology.configure(conf);//from  w  w w . j a v  a  2 s .c o m
}

From source file:com.rinxor.example.in.memory.datagrid.cache.AppConf.java

private void load(String cfgFilePath) {
    try {/*w  ww.ja v a2  s .  c o m*/
        XMLConfiguration reader = new XMLConfiguration(cfgFilePath);

        zoneId = reader.getString("server.zoneId");
        nodeId = reader.getString("server.uniqueNodeId");

    } catch (ConfigurationException ex) {
        LOG.error(ex.getMessage());
    }
}

From source file:de.rkl.tools.tzconv.configuration.ApplicationConfiguration.java

@SuppressWarnings("unused")
public ApplicationConfiguration() throws ConfigurationException {
    configuration = new XMLConfiguration("configuration.xml");
}

From source file:com.sm.store.BuildRemoteConfig.java

private void init() {
    try {/*from   ww w . j av  a  2 s . co m*/
        config = new XMLConfiguration(fileName);
    } catch (ConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:edu.indiana.d2i.sloan.Configuration.java

private void loadConfigurations(String xmlPath) {
    try {//from   ww w  .  j a va 2s . c o  m
        XMLConfiguration config = new XMLConfiguration(xmlPath);
        int size = config.getList("property.name").size();
        for (int i = 0; i < size; i++) {
            HierarchicalConfiguration sub = config.configurationAt(String.format("property(%d)", i));
            String name = sub.getString("name");
            String val = sub.getString("value");
            properties.put(name, val);
        }
    } catch (ConfigurationException cex) {
        throw new RuntimeException(cex);
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.util.ConfigurationMapEntryUtilsTest.java

@Test
public void test() throws ConfigurationException {
    URL resource = getResource(this.getClass(), "ConfigurationMapEntryUtilsTest.xml");
    XMLConfiguration conf = new XMLConfiguration(resource);
    Map<String, Map<String, String>> map = extractMapList(conf, "fieldTypeMapping.entry", "fieldName",
            "fieldType", "dateFormat");
    Assert.assertEquals(3, map.size());//from w w w.  j  a  v  a2 s.  c  o m
    System.out.println(map);
}

From source file:com.github.steveash.typedconfig.NestedConfig2IntegrationTest.java

@Before
public void setUp() throws Exception {
    proxy = ConfigProxyFactory.getDefault().make(Proxy.class, new XMLConfiguration("nestedConfig2.xml"));
}

From source file:com.vaushell.samplelibrary.AppTest.java

/**
 * Initialize the test.//w  ww . j  a va2  s.  c om
 *
 * @throws ConfigurationException
 */
@BeforeClass
public void setUp() throws ConfigurationException {
    // My config
    final XMLConfiguration config = new XMLConfiguration("conf-local/configuration.xml");
}

From source file:com.linuxbox.enkive.imap.EnkiveIMAPServer.java

public EnkiveIMAPServer(String configurationPath) throws ConfigurationException {

    Logger logger = new org.slf4j.impl.Log4jLoggerFactory().getLogger("com.linuxbox.enkive.imap");
    setLog(logger);//w ww .jav  a 2 s  .  c o  m
    config = new XMLConfiguration(ClassLoader.getSystemResource(configurationPath));
}