remm 01/10/04 11:23:28
Modified: catalina/src/share/org/apache/catalina/loader
WebappClassLoader.java
Log:
- Add support for getResources (fix for bug 3936).
Revision Changes Path
1.20 +51 -5
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
Index: WebappClassLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebappClassLoader.java 2001/09/28 02:33:04 1.19
+++ WebappClassLoader.java 2001/10/04 18:23:28 1.20
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.19 2001/09/28 02:33:04 remm Exp $
- * $Revision: 1.19 $
- * $Date: 2001/09/28 02:33:04 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.20 2001/10/04 18:23:28 remm Exp $
+ * $Revision: 1.20 $
+ * $Date: 2001/10/04 18:23:28 $
*
* ====================================================================
*
@@ -88,6 +88,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Vector;
import java.util.jar.JarFile;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
@@ -123,7 +124,7 @@
*
* @author Remy Maucherat
* @author Craig R. McClanahan
- * @version $Revision: 1.19 $ $Date: 2001/09/28 02:33:04 $
+ * @version $Revision: 1.20 $ $Date: 2001/10/04 18:23:28 $
*/
public class WebappClassLoader
extends URLClassLoader
@@ -941,7 +942,52 @@
if (debug >= 3)
log(" findResources(" + name + ")");
- return (super.findResources(name));
+
+ Vector result = new Vector();
+
+ int jarFilesLength = jarFiles.length;
+ int repositoriesLength = repositories.length;
+
+ int i;
+
+ // Looking at the repositories
+ for (i = 0; i < repositoriesLength; i++) {
+ try {
+ String fullPath = repositories[i] + name;
+ resources.lookup(fullPath);
+ // Note : Not getting an exception here means the resource was
+ // found
+ try {
+ result.addElement(new File(files[i], name).toURL());
+ } catch (MalformedURLException e) {
+ // Ignore
+ }
+ } catch (NamingException e) {
+ }
+ }
+
+ // Looking at the JAR files
+ for (i = 0; i < jarFilesLength; i++) {
+ JarEntry jarEntry = jarFiles[i].getJarEntry(name);
+ if (jarEntry != null) {
+ try {
+ String jarFakeUrl = jarRealFiles[i].toURL().toString();
+ jarFakeUrl = "jar:" + jarFakeUrl + "!/" + name;
+ result.addElement(new URL(jarFakeUrl));
+ } catch (MalformedURLException e) {
+ // Ignore
+ }
+ }
+ }
+
+ // Adding the results of a call to the superclass
+ Enumeration otherResourcePaths = super.findResources(name);
+
+ while (otherResourcePaths.hasMoreElements()) {
+ result.addElement(otherResourcePaths.nextElement());
+ }
+
+ return result.elements();
}