Browse Source

Add debug information to the getResource methods.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269310 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
8339c7f3e8
1 changed files with 44 additions and 6 deletions
  1. +44
    -6
      src/main/org/apache/tools/ant/AntClassLoader.java

+ 44
- 6
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -357,17 +357,38 @@ public class AntClassLoader extends ClassLoader {
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 @@ public class AntClassLoader extends ClassLoader {
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 @@ public class AntClassLoader extends ClassLoader {
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;


Loading…
Cancel
Save