remm 01/05/03 19:01:13
Modified: catalina/src/share/org/apache/catalina/loader
StandardClassLoader.java
Log:
- Correctly register repositories based on non file protocols.
- That fixes class reloading, which before could only handle file based URLs.
Revision Changes Path
1.16 +70 -25
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java
Index: StandardClassLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- StandardClassLoader.java 2001/04/25 04:14:47 1.15
+++ StandardClassLoader.java 2001/05/04 02:01:13 1.16
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java,v
1.15 2001/04/25 04:14:47 glenn Exp $
- * $Revision: 1.15 $
- * $Date: 2001/04/25 04:14:47 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java,v
1.16 2001/05/04 02:01:13 remm Exp $
+ * $Revision: 1.16 $
+ * $Date: 2001/05/04 02:01:13 $
*
* ====================================================================
*
@@ -110,7 +110,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.15 $ $Date: 2001/04/25 04:14:47 $
+ * @version $Revision: 1.16 $ $Date: 2001/05/04 02:01:13 $
*/
public class StandardClassLoader
@@ -561,8 +561,8 @@
return (true);
}
} else if (entries[i].origin instanceof URL) {
+ URL url = (URL) entries[i].origin;
try {
- URL url = (URL) entries[i].origin;
URLConnection urlConn = url.openConnection();
if (entries[i].lastModified != urlConn.getLastModified()) {
if (debug >= 2)
@@ -572,6 +572,7 @@
return (true);
}
} catch (IOException e) {
+ log(" Failed tracking modifications of '" + url + "'");
}
}
}
@@ -687,27 +688,71 @@
repositories[i].substring(0, repositories[i].length() - 1);
if (debug >= 4)
log(" Checking repository " + pathname);
- if (pathname.startsWith("file://"))
- pathname = pathname.substring(7);
- else if (pathname.startsWith("file:"))
- pathname = pathname.substring(5);
- pathname += File.separatorChar +
- name.replace('.', File.separatorChar) + ".class";
- try {
- File file = new File(pathname);
- if (file.exists() && file.canRead()) {
- if (debug >= 3)
- log(" Caching from '" + file.getAbsolutePath() +
+ if ((pathname.startsWith("file://"))
+ || (pathname.startsWith("file:"))) {
+
+ if (pathname.startsWith("file://")) {
+ pathname = pathname.substring(7);
+ } else if (pathname.startsWith("file:")) {
+ pathname = pathname.substring(5);
+ }
+ pathname += File.separatorChar
+ + name.replace('.', File.separatorChar) + ".class";
+
+ try {
+ File file = new File(pathname);
+ if (file.exists() && file.canRead()) {
+ if (debug >= 3)
+ log(" Caching from '" + file.getAbsolutePath() +
+ "' modified '" +
+ (new java.sql.Timestamp(file.lastModified())) +
+ "'");
+ classCache.put(name, new ClassCacheEntry
+ (clazz, file, file.lastModified()));
+ }
+
+ } catch(AccessControlException ace) {
+ // Don't worry about caching the class last modified
+ // if ClassLoader doesn't have permission to read file
+ }
+
+ } else {
+
+ pathname += "/" + name.replace('.', '/') + ".class";
+
+ try {
+ URLStreamHandler streamHandler = null;
+ String protocol = parseProtocol(pathname);
+ if (factory != null)
+ streamHandler =
+ factory.createURLStreamHandler(protocol);
+ URL classUrl = new URL(null, pathname, streamHandler);
+ try {
+ URLConnection classUrlConnection =
+ classUrl.openConnection();
+ log(" Caching from '" + classUrl.toString() +
"' modified '" +
- (new java.sql.Timestamp(file.lastModified())) +
- "'");
- classCache.put(name, new ClassCacheEntry(clazz, file,
- file.lastModified()));
- }
- } catch(AccessControlException ace) {
- // Don't worry about caching the class last modified
- // if ClassLoader doesn't have permission to read file
- }
+ (new java.sql.Timestamp
+ (classUrlConnection.getLastModified())) +
+ "'");
+ classCache.put(name, new ClassCacheEntry
+ (clazz, classUrl,
+ classUrlConnection.getLastModified()));
+ } catch (IOException e) {
+ log(" Failed tracking modifications of '"
+ + classUrl.toString() + "'");
+ }
+
+ } catch(MalformedURLException ex) {
+ // Should never happen
+ ex.printStackTrace();
+ } catch(AccessControlException ace) {
+ // Don't worry about caching the class last modified
+ // if ClassLoader doesn't have permission to read file
+ }
+
+ }
+
}
// Return the class we have located