[jboss-cvs] JBossAS SVN: r58873 - projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 6 13:05:14 EST 2006
Author: scott.stark at jboss.org
Date: 2006-12-06 13:05:12 -0500 (Wed, 06 Dec 2006)
New Revision: 58873
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
Log:
Merge the entry url creation into a common getURL method and correctly assign SyntheticDirEntryHandlers a jar url.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java 2006-12-06 18:03:19 UTC (rev 58872)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java 2006-12-06 18:05:12 UTC (rev 58873)
@@ -240,7 +240,7 @@
catch (IOException e)
{
// Create a synthetic parent
- URL url = getURL(parent, path);
+ URL url = getURL(parent, path, true);
next = new SynthenticDirEntryHandler(getVFSContext(), parent, path,
entry.getTime(), url);
parentMap.put(pathName.toString(), next);
@@ -268,13 +268,30 @@
return parent;
}
- protected URL getURL(VirtualFileHandler parent, String path)
+ /**
+ * Create the URL for the entry represented by path.
+ *
+ * @param parent - the parent handler
+ * @param path - the simple path to the entry without any trailing '/'
+ * @return the jar entry URL
+ * @throws MalformedURLException
+ */
+ protected URL getURL(VirtualFileHandler parent, String path, boolean isDirEntry)
throws MalformedURLException
{
StringBuilder buffer = new StringBuilder();
try
{
- buffer.append(parent.toURL());
+ String parentUrl = parent.toURL().toString();
+ if (parent instanceof JarEntryHandler || parent instanceof SynthenticDirEntryHandler)
+ {
+ buffer.append(parentUrl);
+ }
+ else
+ {
+ buffer.append("jar:").append(parentUrl).append("!/");
+ }
+
if (buffer.charAt(buffer.length() - 1) != '/')
buffer.append('/');
buffer.append(path);
@@ -284,6 +301,9 @@
// Should not happen
throw new MalformedURLException(e.getMessage());
}
+ // Jar directory URLs must end in /
+ if( isDirEntry && buffer.charAt(buffer.length() - 1) != '/')
+ buffer.append('/');
URL url = new URL(buffer.toString());
return url;
}
@@ -332,13 +352,13 @@
*
* @param parent the parent
* @param entry the entry
- * @param entryName the entry name
+ * @param entryName - the entry name without any trailing '/'
* @return the handler
* @throws IOException for any error accessing the file system
* @throws IllegalArgumentException for a null parent or entry
*/
- protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, JarEntry entry,
- String entryName)
+ protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent,
+ JarEntry entry, String entryName)
throws IOException
{
if (parent == null)
@@ -346,31 +366,7 @@
if (entry == null)
throw new IllegalArgumentException("Null entry");
-
- StringBuilder buffer = new StringBuilder();
- try
- {
- String parentUrl = parent.toURL().toString();
- if (parent instanceof JarEntryHandler || parent instanceof SynthenticDirEntryHandler)
- {
- buffer.append(parentUrl);
- }
- else
- {
- buffer.append("jar:").append(parentUrl).append("!/");
- }
-
- if (buffer.charAt(buffer.length() - 1) != '/')
- buffer.append('/');
- buffer.append(entryName);
- }
- catch (URISyntaxException e)
- {
- // Should not happen
- throw new MalformedURLException(e.getMessage());
- }
- URL url = new URL(buffer.toString());
-
+ URL url = getURL(parent, entryName, entry.isDirectory());
VFSContext context = parent.getVFSContext();
VirtualFileHandler vfh;
@@ -386,9 +382,6 @@
}
else
{
- // Jar directory URLs must end in /
- if (entry.isDirectory())
- url = new URL(url.toString() + "/");
vfh = new JarEntryHandler(context, parent, jar, entry, entryName, url);
}
More information about the jboss-cvs-commits
mailing list