*\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
"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
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
&& (!(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
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
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
\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
/**\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
} 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
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