Author: oheger
Date: Sat Sep 28 19:40:40 2013
New Revision: 1527236
URL: http://svn.apache.org/r1527236
Log:
Changed loading of include files in PropertiesConfiguration.
Files to be included are now resolved using the new locate(FileLocator) method
of FileLocatorUtils (and thus the customizable FileLocationStrategy is
applied).
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java?rev=1527236&r1=1527235&r2=1527236&view=diff
==============================================================================
---
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java
(original)
+++
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PropertiesConfiguration.java
Sat Sep 28 19:40:40 2013
@@ -1388,17 +1388,13 @@ public class PropertiesConfiguration ext
private void loadIncludeFile(String fileName) throws ConfigurationException
{
assert locator != null : "Locator has not been set!";
- URL url =
-
FileLocatorUtils.locate(FileLocatorUtils.obtainFileSystem(locator),
- locator.getBasePath(), fileName);
+ URL url = locateIncludeFile(locator.getBasePath(), fileName);
if (url == null)
{
URL baseURL = locator.getSourceURL();
if (baseURL != null)
{
- url =
- FileLocatorUtils.locate(locator.getFileSystem(),
- baseURL.toString(), fileName);
+ url = locateIncludeFile(baseURL.toString(), fileName);
}
}
@@ -1411,4 +1407,21 @@ public class PropertiesConfiguration ext
FileHandler fh = new FileHandler(this);
fh.load(url);
}
+
+ /**
+ * Tries to obtain the URL of an include file using the specified
(optional)
+ * base path and file name.
+ *
+ * @param basePath the base path
+ * @param fileName the file name
+ * @return the URL of the include file or <b>null</b> if it cannot be
+ * resolved
+ */
+ private URL locateIncludeFile(String basePath, String fileName)
+ {
+ FileLocator includeLocator =
+ FileLocatorUtils.fileLocator(locator).sourceURL(null)
+ .basePath(basePath).fileName(fileName).create();
+ return FileLocatorUtils.locate(includeLocator);
+ }
}