summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--contributors.xml4
-rw-r--r--src/main/org/apache/tools/ant/AntClassLoader.java45
3 files changed, 41 insertions, 9 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 064e6ad34..bc935a7c2 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -43,6 +43,7 @@ Avik Sengupta
Balazs Fejes 2
barney2k7
Bart Vanhaute
+Basil Crow
Ben Galbraith
Ben Gertzfield
Benjamin Burgess
diff --git a/contributors.xml b/contributors.xml
index cff2bf718..c84ec148b 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -200,6 +200,10 @@
<last>Vanhaute</last>
</name>
<name>
+ <first>Basil</first>
+ <last>Crow</last>
+ </name>
+ <name>
<first>Benjamin</first>
<last>Burgess</last>
</name>
diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java
index 189351f24..9791fb327 100644
--- a/src/main/org/apache/tools/ant/AntClassLoader.java
+++ b/src/main/org/apache/tools/ant/AntClassLoader.java
@@ -889,15 +889,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
if (url != null) {
log("Resource " + name + " loaded from parent loader", Project.MSG_DEBUG);
} else {
- // try and load from this loader if the parent either didn't find
- // it or wasn't consulted.
- for (final File pathComponent : pathComponents) {
- url = getResourceURL(pathComponent, name);
- if (url != null) {
- log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG);
- break;
- }
- }
+ url = getUrl(name);
}
if (url == null && !isParentFirst(name)) {
// this loader was first but it didn't find it - try the parent
@@ -917,6 +909,29 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
}
/**
+ * Finds a matching file by iterating through path components.
+ *
+ * @param name File to find
+ * @return A <code>URL</code> object for reading the resource, or <code>null</code> if the
+ * resource could not be found
+ */
+ private URL getUrl(String name) {
+ URL url = null;
+
+ // try and load from this loader if the parent either didn't find
+ // it or wasn't consulted.
+ for (final File pathComponent : pathComponents) {
+ url = getResourceURL(pathComponent, name);
+ if (url != null) {
+ log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG);
+ break;
+ }
+ }
+
+ return url;
+ }
+
+ /**
* Finds all the resources with the given name. A resource is some
* data (images, audio, text, etc) that can be accessed by class
* code in a way that is independent of the location of the code.
@@ -936,6 +951,18 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo
}
/**
+ * Finds the resource with the given name.
+ *
+ * @param name The resource name
+ * @return A <code>URL</code> object for reading the resource, or <code>null</code> if the
+ * resource could not be found
+ */
+ @Override
+ protected URL findResource(final String name) {
+ return getUrl(name);
+ }
+
+ /**
* Returns an enumeration of URLs representing all the resources with the
* given name by searching the class loader's classpath.
*