Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#setURL()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#setURL() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageResources.java From unitime with Apache License 2.0 | 5 votes |
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())); } try { pc.load(); configuration = pc; } catch (ConfigurationException e) { Debug.error("Message Resources configuration exception: " + e.getMessage()); } } return configuration; }
Example 2
Source File: ConfigurationHelper.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** * Loads configuration from a specified path. * * @param path the path to try first as a resource, then as a file * @throws ConfigurationLoadException if the configuration could not be * loaded. * @returns properties loaded from the specified path or null. */ public Configuration fromFile(URL path) throws ConfigurationLoadException { PropertiesConfiguration configuration = setupConfiguration(new PropertiesConfiguration()); configuration.setURL(path); try { configuration.load(); return configuration; } catch (ConfigurationException e) { throw new ConfigurationLoadException( "Encountered a problem reading the provided configuration file \"" + path + "\"!", e); } }