bodewig 01/07/10 23:50:46
Modified: src/main/org/apache/tools/ant AntClassLoader.java
Log:
Add debug information to the getResource methods.
Revision Changes Path
1.24 +44 -6 jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java
Index: AntClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- AntClassLoader.java 2001/07/10 14:55:22 1.23
+++ AntClassLoader.java 2001/07/11 06:50:45 1.24
@@ -357,17 +357,38 @@
InputStream resourceStream = null;
if (isSystemFirst(name)) {
resourceStream = loadBaseResource(name);
- if (resourceStream == null) {
+ if (resourceStream != null) {
+ project.log("ResourceStream for " + name
+ + " loaded from system loader", Project.MSG_DEBUG);
+
+ } else {
resourceStream = loadResource(name);
+ if (resourceStream != null) {
+ project.log("ResourceStream for " + name
+ + " loaded from ant loader", Project.MSG_DEBUG);
+ }
}
}
else {
resourceStream = loadResource(name);
- if (resourceStream == null) {
+ if (resourceStream != null) {
+ project.log("ResourceStream for " + name
+ + " loaded from ant loader", Project.MSG_DEBUG);
+
+ } else {
resourceStream = loadBaseResource(name);
+ if (resourceStream != null) {
+ project.log("ResourceStream for " + name
+ + " loaded from system loader", Project.MSG_DEBUG);
+ }
}
}
+ if (resourceStream == null) {
+ project.log("Couldn't load ResourceStream for " + name,
+ Project.MSG_WARN);
+ }
+
return resourceStream;
}
@@ -518,17 +539,26 @@
url = super.getResource(name);
}
- // try and load from this loader if the parent eitehr didn't find it or
- // wasn;t consulted.
- if (url == null) {
+ if (url != null) {
+ project.log("Resource " + name + " loaded from system loader",
+ Project.MSG_DEBUG);
+
+ } else {
+ // try and load from this loader if the parent either didn't find
+ // it or wasn't consulted.
String[] pathElements = classpath.list();
for (int i = 0; i < pathElements.length && url == null; ++i) {
try {
File pathComponent = project.resolveFile((String)pathElements[i]);
url = getResourceURL(pathComponent, name);
+ if (url != null) {
+ project.log("Resource " + name
+ + " loaded from ant loader",
+ Project.MSG_DEBUG);
+ }
}
catch (BuildException e) {
- // ignore path elements which ar einvalid relative to the project
+ // ignore path elements which are invalid relative to the project
}
}
}
@@ -536,6 +566,14 @@
if (url == null && !isSystemFirst(name)) {
// this loader was first but it didn't find it - try the parent
url = super.getResource(name);
+ if (url != null) {
+ project.log("Resource " + name + " loaded from system loader",
+ Project.MSG_DEBUG);
+ }
+ }
+
+ if (url == null) {
+ project.log("Couldn't load Resource " + name, Project.MSG_WARN);
}
return url;
|