[Jboss-cvs] JBossAS SVN: r56994 - in projects/microcontainer/trunk/container/src/main/org/jboss/virtual: . plugins/context plugins/context/jar spi

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 20 05:49:09 EDT 2006


Author: adrian at jboss.org
Date: 2006-09-20 05:49:02 -0400 (Wed, 20 Sep 2006)
New Revision: 56994

Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java
Log:
Allow the handler to tell you what the real URL is.
The URI remains the same.

Use the old method toURI().toURL() by default.
Use the temp file url for nested jars.

Also when asked for a child of a jar entry, resolve it
against the parent (if it has one).

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/VirtualFile.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -118,7 +118,7 @@
     */
    public URL toURL() throws MalformedURLException, URISyntaxException
    {
-      return getHandler().toURI().toURL();
+      return getHandler().toURL();
    }
    /**
     * Get the VF URI (file://root/org/jboss/X.java)

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -23,6 +23,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -67,11 +68,16 @@
     * 
     * @return the url
     */
-   public URL getURL()
+   public URL getURL() 
    {
       return url;
    }
 
+   public URL toURL() throws MalformedURLException, URISyntaxException
+   {
+      return getURL();
+   }
+
    public long getLastModified() throws IOException
    {
       checkClosed();

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -27,8 +27,10 @@
 import java.io.ObjectStreamField;
 import java.io.ObjectInputStream.GetField;
 import java.io.ObjectOutputStream.PutField;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -117,6 +119,11 @@
       return vfsPath;
    }
 
+   public URL toURL() throws MalformedURLException, URISyntaxException
+   {
+      return toURI().toURL();
+   }
+
    /**
     * Initialise the path into the path name
     * 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -131,6 +131,10 @@
    public VirtualFileHandler findChild(String path) throws IOException
    {
       checkClosed();
-      throw new IOException("A JarEntry has no children: " + path + " for " + this);
+      VirtualFileHandler handler = getParent();
+      if (handler == null)
+         throw new IOException("A JarEntry has no children: " + path + " for " + this);
+      else
+         return handler.findChild(getName() +"/" + path);
    }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -25,6 +25,8 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
@@ -46,19 +48,20 @@
    /** The jar entry */
    private transient JarEntry entry;
    
+   /** The temporary file */
+   private transient File temp;
+   
    /**
     * Create a temporary jar
     * 
+    * @param temp the temporary file
     * @param parentJar the jar
     * @param entry the jar entry
     * @return the jar file
     * @throws IOException for any error
     */
-   private static JarFile createTempJar(JarFile parentJar, JarEntry entry) throws IOException
+   private static JarFile createTempJar(File temp, JarFile parentJar, JarEntry entry) throws IOException
    {
-      File temp = File.createTempFile("nestedjar", null);
-      temp.deleteOnExit();
-
       InputStream inputStream = parentJar.getInputStream(entry);
       try
       {
@@ -110,7 +113,10 @@
       
       try
       {
-         initJarFile(createTempJar(parentJar, entry));
+         temp = File.createTempFile("nestedjar", null);
+         temp.deleteOnExit();
+
+         initJarFile(createTempJar(temp, parentJar, entry));
       }
       catch (IOException original)
       {
@@ -151,4 +157,10 @@
    {
       return getJar().getInputStream(getEntry());
    }
+
+   @Override
+   public URL toURL() throws MalformedURLException, URISyntaxException
+   {
+      return temp.toURL();
+   }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java	2006-09-20 09:46:49 UTC (rev 56993)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/spi/VirtualFileHandler.java	2006-09-20 09:49:02 UTC (rev 56994)
@@ -24,8 +24,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.List;
 
 import org.jboss.virtual.VirtualFile;
@@ -54,12 +56,21 @@
    String getPathName();
 
    /**
+    * Get the VF URI (file://root/org/jboss/X.java)
+    * 
+    * @return the full URI to the VF in the VFS.
+    * @throws URISyntaxException for an error parsing the URI 
+    */
+   URI toURI() throws URISyntaxException;
+
+   /**
     * Get the VF URL (file://root/org/jboss/X.java)
     * 
     * @return the full URL to the VF in the VFS.
     * @throws URISyntaxException for an error parsing the URI 
+    * @throws MalformedURLException for any error
     */
-   URI toURI() throws URISyntaxException;
+   URL toURL() throws MalformedURLException, URISyntaxException;
 
    /**
     * When the file was last modified




More information about the jboss-cvs-commits mailing list