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

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

Introduction

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

Prototype

public void setURL(URL url) 

Source Link

Document

Set the location of this configuration as a URL.

Usage

From source file:org.unitime.timetable.util.MessageResources.java

private Configuration getConfiguration(String name) {
    Configuration configuration = null;
    URL url = Thread.currentThread().getContextClassLoader().getResource(name);
    if (url != null) {
        PropertiesConfiguration pc = new PropertiesConfiguration();
        pc.setURL(url);

        // Set reloading strategy 
        String dynamicReload = ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload", null);
        if (dynamicReload != null && dynamicReload.equalsIgnoreCase("true")) {
            long refreshDelay = Constants.getPositiveInteger(
                    ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload_interval"), 15000);

            FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
            strategy.setRefreshDelay(refreshDelay);
            pc.setReloadingStrategy(strategy);

            pc.addConfigurationListener(new MessageResourcesCfgListener(pc.getBasePath()));
        }/*from  ww  w.  j  a v  a2 s .  co  m*/

        try {
            pc.load();
            configuration = pc;
        } catch (ConfigurationException e) {
            Debug.error("Message Resources configuration exception: " + e.getMessage());
        }
    }

    return configuration;
}