Port RMI fix from 5.5
authorbillbarker <billbarker@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 24 May 2006 05:04:20 +0000 (05:04 +0000)
committerbillbarker <billbarker@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 24 May 2006 05:04:20 +0000 (05:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@409072 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/loader/WebappClassLoader.java

index e4b52da..7171639 100644 (file)
@@ -98,7 +98,7 @@ import org.apache.tomcat.util.IntrospectionUtils;
  *\r
  * @author Remy Maucherat\r
  * @author Craig R. McClanahan\r
- * @version $Revision: 378251 $ $Date: 2006-02-16 15:19:13 +0100 (jeu., 16 févr. 2006) $\r
+ * @version $Revision$ $Date: 2006-05-19 19:52:46 -0700 (Fri, 19 May 2006) $\r
  */\r
 public class WebappClassLoader\r
     extends URLClassLoader\r
@@ -141,6 +141,7 @@ public class WebappClassLoader
         "javax.servlet.Servlet"                     // Servlet API\r
     };\r
 \r
+\r
     /**\r
      * Set of package names which are not allowed to be loaded from a webapp\r
      * class loader without delegating first.\r
@@ -511,6 +512,13 @@ public class WebappClassLoader
         this.loaderDir = new File(workDir, "loader");\r
     }\r
 \r
+     /**\r
+      * Utility method for use in subclasses.\r
+      * Must be called before Lifecycle methods to have any effect.\r
+      */\r
+     protected void setParentClassLoader(ClassLoader pcl) {\r
+         parent = pcl;\r
+     }\r
 \r
     // ------------------------------------------------------- Reloader Methods\r
 \r
@@ -1064,7 +1072,7 @@ public class WebappClassLoader
                             && (!(name.endsWith(".class")))) {\r
                         // Copy binary content to the work directory if not present\r
                         File resourceFile = new File(loaderDir, name);\r
-                        url = resourceFile.toURL();\r
+                        url = getURI(resourceFile);\r
                     }\r
                 } catch (Exception e) {\r
                     // Ignore\r
@@ -1401,9 +1409,9 @@ public class WebappClassLoader
             URL[] urls = new URL[length];\r
             for (i = 0; i < length; i++) {\r
                 if (i < filesLength) {\r
-                    urls[i] = getURL(files[i]);\r
+                    urls[i] = getURL(files[i], true);\r
                 } else if (i < filesLength + jarFilesLength) {\r
-                    urls[i] = getURL(jarRealFiles[i - filesLength]);\r
+                    urls[i] = getURL(jarRealFiles[i - filesLength], true);\r
                 } else {\r
                     urls[i] = external[i - filesLength - jarFilesLength];\r
                 }\r
@@ -1831,7 +1839,7 @@ public class WebappClassLoader
         ResourceEntry entry = new ResourceEntry();\r
         try {\r
             entry.source = getURI(new File(file, path));\r
-            entry.codeBase = getURL(new File(file, path));\r
+            entry.codeBase = getURL(new File(file, path), false);\r
         } catch (MalformedURLException e) {\r
             return null;\r
         }   \r
@@ -1957,7 +1965,7 @@ public class WebappClassLoader
 \r
                     entry = new ResourceEntry();\r
                     try {\r
-                        entry.codeBase = getURL(jarRealFiles[i]);\r
+                        entry.codeBase = getURL(jarRealFiles[i], false);\r
                         String jarFakeUrl = getURI(jarRealFiles[i]).toString();\r
                         jarFakeUrl = "jar:" + jarFakeUrl + "!/" + path;\r
                         entry.source = new URL(jarFakeUrl);\r
@@ -2274,7 +2282,7 @@ public class WebappClassLoader
     /**\r
      * Get URL.\r
      */\r
-    protected URL getURL(File file)\r
+    protected URL getURL(File file, boolean encoded)\r
         throws MalformedURLException {\r
 \r
         File realFile = file;\r
@@ -2283,7 +2291,11 @@ public class WebappClassLoader
         } catch (IOException e) {\r
             // Ignore\r
         }\r
-        return realFile.toURL();\r
+        if(encoded) {\r
+            return getURI(realFile);\r
+        } else {\r
+            return realFile.toURL();\r
+        }\r
 \r
     }\r
 \r
@@ -2294,13 +2306,13 @@ public class WebappClassLoader
     protected URL getURI(File file)\r
         throws MalformedURLException {\r
 \r
+\r
         File realFile = file;\r
         try {\r
             realFile = realFile.getCanonicalFile();\r
         } catch (IOException e) {\r
             // Ignore\r
         }\r
-\r
         return realFile.toURI().toURL();\r
 \r
     }\r