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

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

Introduction

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

Prototype

public String getBasePath() 

Source Link

Usage

From source file:org.apache.juddi.v3.client.config.ClientConfig.java

/**
 * Does the actual work of reading the configuration from System
 * Properties and/or uddi.xml file. When the uddi.xml
 * file is updated the file will be reloaded. By default the reloadDelay is
 * set to 1 second to prevent excessive date stamp checking.
 *///from w  w w.j  a  v  a2s.c  om
private void loadConfiguration(String configurationFile, Properties properties) throws ConfigurationException {
    //Properties from system properties
    CompositeConfiguration compositeConfig = new CompositeConfiguration();
    compositeConfig.addConfiguration(new SystemConfiguration());
    //Properties from XML file
    if (System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY) != null) {
        log.info("Using system property config override");
        configurationFile = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
    }
    XMLConfiguration xmlConfig = null;
    if (configurationFile != null) {
        xmlConfig = new XMLConfiguration(configurationFile);
    } else {
        final String filename = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
        if (filename != null) {
            xmlConfig = new XMLConfiguration(filename);
        } else {
            xmlConfig = new XMLConfiguration(DEFAULT_UDDI_CONFIG);
        }
    }
    log.info("Reading UDDI Client properties file " + xmlConfig.getBasePath() + " use -D"
            + UDDI_CONFIG_FILENAME_PROPERTY + " to override");
    this.configurationFile = xmlConfig.getBasePath();
    long refreshDelay = xmlConfig.getLong(Property.UDDI_RELOAD_DELAY, 1000l);
    log.debug("Setting refreshDelay to " + refreshDelay);
    FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
    fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
    xmlConfig.setReloadingStrategy(fileChangedReloadingStrategy);
    compositeConfig.addConfiguration(xmlConfig);
    //Making the new configuration globally accessible.
    config = compositeConfig;
    readConfig(properties);
}