[jboss-cvs] JBossAS SVN: r62779 - in projects/vfs/branches/urlconn-work/src: main/java/org/jboss/virtual/plugins/context and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 3 08:43:25 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-05-03 08:43:24 -0400 (Thu, 03 May 2007)
New Revision: 62779

Added:
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileURLConnection.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileUrlStreamHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarFile.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarURLConnection.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSMemoryJarFile.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSRandomAccessJarFile.java
   projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/VfsProtocolUnitTestCase.java
Removed:
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java
Modified:
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/VirtualFile.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractURLHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContext.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContextFactory.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContext.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContextFactory.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledUrlStreamHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/ByteArrayHandler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfs/Handler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsfile/Handler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/Handler.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VFSContextFactoryLocator.java
   projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java
   projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/support/ClassPathIterator.java
   projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
   projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/JARVirtualFileHandlerUnitTestCase.java
Log:
Checkpoint the URLConnection changes

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/VirtualFile.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/VirtualFile.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -117,7 +117,7 @@
     */
    public URL toURL() throws MalformedURLException, URISyntaxException
    {
-      return getHandler().toVfsUrl();
+      return getHandler().toURL();
    }
 
    /**

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractURLHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -45,7 +45,7 @@
    private static final long serialVersionUID = 1L;
 
    /** The url */
-   private final URL url;
+   private final URLConnection urlConn;
 
    /**
     * Create a newURLHandler.
@@ -56,27 +56,20 @@
     * @param name the name
     * @throws IllegalArgumentException for a null context, vfsPath or url
     */
-   public AbstractURLHandler(VFSContext context, VirtualFileHandler parent, URL url, String name)
+   public AbstractURLHandler(VFSContext context, VirtualFileHandler parent,
+         URLConnection urlConn, String name)
    {
       super(context, parent, name);
-      if (url == null)
-         throw new IllegalArgumentException("Null url");
-      this.url = url;
-      initCacheLastModified();
+      if (urlConn == null)
+         throw new IllegalArgumentException("Null urlConn");
+      this.urlConn = urlConn;
    }
 
-   protected void initCacheLastModified()
+   public URLConnection getConnection()
    {
-      try
-      {
-         this.cachedLastModified = url.openConnection().getLastModified();
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException(e);
-      }
+      return urlConn;
    }
-   
+
    /**
     * Get the url
     * 
@@ -84,7 +77,7 @@
     */
    public URL getURL() 
    {
-      return url;
+      return urlConn.getURL();
    }
 
    public URL toURL() throws MalformedURLException, URISyntaxException
@@ -95,19 +88,17 @@
    public long getLastModified() throws IOException
    {
       checkClosed();
-      URLConnection c = url.openConnection();
-      return c.getLastModified();
+      return urlConn.getLastModified();
    }
 
    public long getSize() throws IOException
    {
       checkClosed();
-      URLConnection c = url.openConnection();
-      return c.getContentLength();
+      return urlConn.getContentLength();
    }
 
    /**
-    * Basis existence on URLConnection.getLastModified() != 0. This may
+    * Base existence on URLConnection.getLastModified() != 0. This may
     * not be true for all url connections.
     * 
     * @see URLConnection#getLastModified()
@@ -115,8 +106,7 @@
     */
    public boolean exists() throws IOException
    {
-      URLConnection c = url.openConnection();
-      return c.getLastModified() != 0;
+      return urlConn.getLastModified() != 0;
    }
 
    public boolean isHidden() throws IOException
@@ -128,11 +118,11 @@
    public InputStream openStream() throws IOException
    {
       checkClosed();
-      return url.openStream();
+      return urlConn.getInputStream();
    }
 
    public URI toURI() throws URISyntaxException
    {
-      return VFSUtils.toURI(url);
+      return VFSUtils.toURI(urlConn.getURL());
    }
 }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -82,7 +82,7 @@
    /** The vfsPath */
    private transient String vfsPath;
 
-   protected URL vfsUrl;
+   //protected URL vfsUrl;
 
    /** The reference count */
    private transient AtomicInteger references = new AtomicInteger(0);
@@ -153,12 +153,18 @@
    {
       return toURI().toURL();
    }
+   public URI toURI() throws URISyntaxException
+   {
+      URI rootURI = getVFSContext().getRootURI();
+      return new URI(rootURI.toASCIIString()+"/"+getPathName());
+   }
 
-
+   /*
    public URL toVfsUrl() throws MalformedURLException, URISyntaxException
    {
       return vfsUrl;
    }
+   */
 
    /**
     * Initialise the path into the path name
@@ -382,7 +388,6 @@
       fields.put("rootURI", this.getVFSContext().getRootURI());
       fields.put("parent", parent);
       fields.put("name", name);
-      fields.put("vfsUrl", vfsUrl);
       out.writeFields();
    }
    private void readObject(ObjectInputStream in)
@@ -396,7 +401,6 @@
       VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURI);
       this.context = factory.getVFS(rootURI);
       this.references = new AtomicInteger(0);
-      this.vfsUrl = (URL)fields.get("vfsUrl", null);
       // Restore the log
       log = Logger.getLogger(getClass());
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/VfsArchiveBrowserFactory.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -28,7 +28,7 @@
 import org.jboss.util.file.ArchiveBrowser;
 import org.jboss.util.file.ArchiveBrowserFactory;
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 
 /**
  * This is a bridge to an older, crappier API written by myself.

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -29,6 +29,7 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -65,14 +66,14 @@
     * @throws IOException for an error accessing the file system
     * @throws IllegalArgumentException for a null context, url
     */
-   public FileHandler(FileSystemContext context, VirtualFileHandler parent, File file, URL url) throws IOException
+   public FileHandler(FileSystemContext context, VirtualFileHandler parent,
+         File file, URLConnection urlConn) throws IOException
    {
-      super(context, parent, url, file.getName());
+      super(context, parent, urlConn, file.getName());
 
       this.file = file;
       if (file.exists() == false)
          throw new FileNotFoundException("File does not exist: " + file.getCanonicalPath());
-      this.vfsUrl = new URL("vfs" + url.toString());
    }
    /**
     * Create a new FileHandler
@@ -84,21 +85,12 @@
     * @throws IOException for an error accessing the file system
     * @throws IllegalArgumentException for a null context, uri
     */
-   public FileHandler(FileSystemContext context, VirtualFileHandler parent, File file, URI uri) throws IOException
+   public FileHandler(FileSystemContext context, VirtualFileHandler parent,
+         File file, URI uri) throws IOException
    {
-      this(context, parent, file, uri.toURL());
+      this(context, parent, file, uri.toURL().openConnection());
    }
 
-
-   public URL toVfsUrl() throws MalformedURLException, URISyntaxException
-   {
-      if (vfsUrl == null)
-      {
-         vfsUrl = new URL("vfs" + getURL().toString());
-      }
-      return vfsUrl;
-   }
-
    @Override
    public FileSystemContext getVFSContext()
    {

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContext.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContext.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContext.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -59,16 +59,16 @@
     * @param uri the url
     * @return the file
     * @throws IOException for any error accessing the file system
+    * @throws URISyntaxException 
     * @throws IllegalArgumentException for a null url
     */
    private static File getFile(URI uri) throws IOException
    {
       if (uri == null)
          throw new IllegalArgumentException("Null uri");
-      
-      return new File(uri);
+      return new File(uri.getPath());
    }
-   
+
    /**
     * Get the url for a file
     * 
@@ -92,7 +92,7 @@
       }
       try
       {
-         return new URI("file", null, path, null);
+         return new URI("vfsfile", null, path, null);
       }
       catch(URISyntaxException e)
       {
@@ -123,7 +123,7 @@
    {
       this(rootURI, getFile(rootURI));
    }
-   
+
    /**
     * Create a new FileSystemContext.
     * 
@@ -176,7 +176,8 @@
          String name = file.getName();
          try
          {
-            return new JarHandler(this, parent, file, file.toURL(), name);
+            URL vfsjar = new URL("vfsjar://"+file.getPath());
+            return new JarHandler(this, parent, vfsjar.openConnection(), name);
          }
          catch (IOException e)
          {

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContextFactory.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContextFactory.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/FileSystemContextFactory.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -40,7 +40,7 @@
 public class FileSystemContextFactory implements VFSContextFactory
 {
    /** The protocols supported */
-   private static final String[] PROTOCOLS = { "file" };
+   private static final String[] PROTOCOLS = { "file", "vfsfile" };
 
    public String[] getProtocols()
    {
@@ -51,6 +51,8 @@
    {
       try
       {
+         if( root.getProtocol().equals("file") )
+            root = new URL("vfsfile", root.getHost(), root.getPort(), root.getFile());
          return new FileSystemContext(root);
       }
       catch(URISyntaxException e)
@@ -62,6 +64,19 @@
    }
    public VFSContext getVFS(URI root) throws IOException
    {
+      if( root.getScheme().equals("file") )
+      {
+         try
+         {
+            root = new URI("vfs"+root.toString());
+         }
+         catch(URISyntaxException e)
+         {
+            IOException ioe = new IOException("Failed to create vfsfile uri");
+            ioe.initCause(e);
+            throw ioe;
+         }
+      }
       return new FileSystemContext(root);
    }
 }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/file/LinkHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -27,6 +27,7 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.MalformedURLException;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -64,17 +65,10 @@
       private HashMap<String, VirtualFileHandler> children = 
          new HashMap<String, VirtualFileHandler>(1);
 
-      public ParentOfLink(VFSContext context, VirtualFileHandler parent, URL url, String name)
+      public ParentOfLink(VFSContext context, VirtualFileHandler parent,
+            URLConnection urlConn, String name)
       {
-         super(context, parent, url, name);
-         try
-         {
-            this.vfsUrl = new URL("vfs" + url.toString());
-         }
-         catch (MalformedURLException e)
-         {
-            throw new RuntimeException(e);
-         }
+         super(context, parent, urlConn, name);
       }
       void addChild(VirtualFileHandler child, String name)
       {
@@ -120,9 +114,9 @@
       throws IOException, URISyntaxException
    {
       // TODO: This URL is not consistent with the getName, but does point to the raw link file
-      super(context, parent, uri.toURL(), name);
+      super(context, parent, uri.toURL().openConnection(), name);
       this.links = links;
-      this.vfsUrl = new URL("vfs" + uri.toURL().toString());
+      // this.vfsUrl = new URL("vfs" + uri.toURL().toString());
       // Create handlers for the links and add
       for(LinkInfo link : links)
       {
@@ -152,8 +146,8 @@
             for(; n < paths.length-1; n ++)
             {
                atom = paths[n];
-               URL polURL = new URL(linkParent.toURI().toURL(), atom);
-               ParentOfLink pol = new ParentOfLink(this.getVFSContext(), linkParent, polURL, atom);
+               URLConnection conn = getConnection();
+               ParentOfLink pol = new ParentOfLink(this.getVFSContext(), linkParent, conn, atom);
                if( linkParent == this )
                {
                   linkTargets.put(atom, pol);

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -21,8 +21,10 @@
 */
 package org.jboss.virtual.plugins.context.jar;
 
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.File;
 import java.net.JarURLConnection;
@@ -34,14 +36,17 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
 
 import org.jboss.virtual.plugins.context.AbstractURLHandler;
 import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
 import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
+import org.jboss.virtual.protocol.vfsjar.VFSJarFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -60,12 +65,8 @@
     */
    private static final long serialVersionUID = 1;
 
+   private transient VFSJarFile jar;
    /**
-    * The jar file
-    */
-   private transient JarFile jar;
-
-   /**
     * The jar entries
     */
    private transient List<VirtualFileHandler> entries;
@@ -95,39 +96,29 @@
     * @throws IOException              for an error accessing the file system
     * @throws IllegalArgumentException for a null context, url or vfsPath
     */
-   protected AbstractJarHandler(VFSContext context, VirtualFileHandler parent, URL url, String name) throws IOException
+   protected AbstractJarHandler(VFSContext context, VirtualFileHandler parent,
+         URLConnection urlConn, String name) throws IOException
    {
-      super(context, parent, url, name);
+      super(context, parent, urlConn, name);
    }
 
    /**
-    * Get the jar.
-    *
-    * @return the jar.
-    */
-   public JarFile getJar()
-   {
-      return jar;
-   }
-
-   /**
     * Initialise the jar file
     *
     * @param jarFile the jar file
     * @throws IOException              for any error reading the jar file
     * @throws IllegalArgumentException for a null jarFile
     */
-   protected void initJarFile(JarFile jarFile) throws IOException
+   protected void initJarFile(VFSJarFile jar) throws IOException
    {
       /* This cannot be checked because of serialization
       if (this.jar != null)
          throw new IllegalStateException("jarFile has already been set");
       */
 
-      this.jar = jarFile;
 
-      Enumeration<JarEntry> enumeration = jar.entries();
-      if (enumeration.hasMoreElements() == false)
+      Iterator<JarEntry> iter = jar.getEntries();
+      if (iter.hasNext() == false)
       {
          entries = Collections.emptyList();
          entryMap = Collections.emptyMap();
@@ -140,10 +131,10 @@
       entries = new ArrayList<VirtualFileHandler>();
       entryMap = new HashMap<String, VirtualFileHandler>();
       boolean trace = log.isTraceEnabled();
-      while (enumeration.hasMoreElements())
+      while (iter.hasNext())
       {
-         JarEntry entry = enumeration.nextElement();
-         String[] paths = entry.getName().split("/");
+         JarEntry jarEntry = iter.next();
+         String[] paths = jarEntry.getName().split("/");
          int depth = paths.length;
          if (depth >= levelMapList.size())
          {
@@ -151,10 +142,11 @@
                levelMapList.add(new ArrayList<JarEntry>());
          }
          ArrayList<JarEntry> levelMap = levelMapList.get(depth);
-         levelMap.add(entry);
+         levelMap.add(jarEntry);
          if (trace)
-            log.trace("added " + entry.getName() + " at depth " + depth);
+            log.trace("added " + jarEntry.getName() + " at depth " + depth);
       }
+
       // Process each level to build the handlers in parent first order
       int level = 0;
       for (ArrayList<JarEntry> levels : levelMapList)
@@ -222,8 +214,8 @@
     * @throws IOException
     */
    protected VirtualFileHandler buildParents(String parentName,
-                                             Map<String, VirtualFileHandler> parentMap, JarEntry entry)
-           throws IOException
+         Map<String, VirtualFileHandler> parentMap, JarEntry entry)
+         throws IOException
    {
       VirtualFileHandler parent = this;
       String[] paths = PathTokenizer.getTokens(parentName);
@@ -240,9 +232,8 @@
          catch (IOException e)
          {
             // Create a synthetic parent
-            URL url = getURL(parent, path, true);
             next = new SynthenticDirEntryHandler(getVFSContext(), parent, path,
-                    entry.getTime(), url);
+                    entry.getTime(), getConnection());
             parentMap.put(pathName.toString(), next);
             if (parent == this)
             {
@@ -309,6 +300,10 @@
       return url;
    }
 
+   public VFSJarFile getJar()
+   {
+      return jar;
+   }
    protected void doClose()
    {
       /* TODO Figure out why this breaks things randomly
@@ -367,7 +362,8 @@
       if (entry == null)
          throw new IllegalArgumentException("Null entry");
 
-      URL url = getURL(parent, entryName, entry.isDirectory());
+      //URL url = getURL(parent, entryName, entry.isDirectory());
+      URLConnection conn = getConnection();
       VFSContext context = parent.getVFSContext();
 
       VirtualFileHandler vfh;
@@ -377,13 +373,13 @@
          boolean useNoCopyJarHandler = Boolean.valueOf(flag);
 
          if (useNoCopyJarHandler)
-            vfh = new NoCopyNestedJarHandler(context, parent, jar, entry, url);
+            vfh = new NoCopyNestedJarHandler(context, parent, jar, entry, conn);
          else
-            vfh = NestedJarHandler.create(context, parent, jar, entry, url, entryName);
+            vfh = NestedJarHandler.create(context, parent, jar, entry, conn, entryName);
       }
       else
       {
-         vfh = new JarEntryHandler(context, parent, jar, entry, entryName, url);
+         vfh = new JarEntryHandler(context, parent, jar, entry, entryName, conn);
       }
 
       return vfh;
@@ -401,19 +397,21 @@
       try
       {
          URLConnection connection = url.openConnection();
-         JarURLConnection jarConnection;
-         if (connection instanceof JarURLConnection)
+         connection.setUseCaches(false);
+         Object content = connection.getContent();
+         JarFile jarFile;
+         if (content instanceof JarFile)
          {
-            jarConnection = (JarURLConnection)connection;
+            jarFile = (JarFile) content;
          }
          else
          {
             // try wrapping it in jar:
             URL jarUrl = new URL("jar:" + url + "!/");
-            jarConnection = (JarURLConnection)jarUrl.openConnection();
+            JarURLConnection jarConn = (JarURLConnection)jarUrl.openConnection();
+            jarFile = jarConn.getJarFile();
          }
-         jarConnection.setUseCaches(false);
-         return jarConnection.getJarFile();
+         return jarFile;
       }
       catch (IOException original)
       {
@@ -421,7 +419,6 @@
          IOException e = new IOException("Error opening jar file: " + url + " reason=" + original.getMessage());
          e.setStackTrace(original.getStackTrace());
          throw e;
-
       }
 
    }
@@ -444,15 +441,15 @@
       if (jarAsString.startsWith("file:"))
       {
          File fp = new File(jarAsString.substring(5));
-         jar = new JarFile(fp);
+         JarInputStream jis = new JarInputStream(new FileInputStream(fp));
       }
       else
       {
          URLConnection conn = jarURL.openConnection();
-         if (conn instanceof JarURLConnection)
+         InputStream is = conn.getInputStream();
+         if (is instanceof JarInputStream)
          {
-            JarURLConnection jconn = (JarURLConnection) conn;
-            jar = jconn.getJarFile();
+            
          }
          else
          {

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContext.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContext.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContext.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLConnection;
 
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.plugins.context.AbstractVFSContext;
@@ -55,7 +56,7 @@
    public JarContext(URL rootURL) throws IOException, URISyntaxException
    {
       super(rootURL);
-      root = createVirtualFileHandler(null, rootURL);
+      root = createVirtualFileHandler(null, rootURL.openConnection());
       rootFile = root.getVirtualFile();
    }
 
@@ -73,17 +74,19 @@
     * @throws IOException for any error accessing the file system
     * @throws IllegalArgumentException for a null entry or url
     */
-   protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, URL url) throws IOException
+   protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent,
+         URLConnection urlConn) throws IOException
    {
-      if (url == null)
-         throw new IllegalArgumentException("Null url");
+      if (urlConn == null)
+         throw new IllegalArgumentException("Null urlConn");
 
-      String urlStr = url.toString();
+      String urlStr = urlConn.toString();
       String jarName = extractJarName(urlStr);
       String entryPath = urlStr;
       entryPath = entryPath(entryPath);
-      JarHandler jar =  new JarHandler(this, parent, url, jarName);
-      if (entryPath == null) return jar;
+      JarHandler jar =  new JarHandler(this, parent, urlConn, jarName);
+      if (entryPath.length() == 0)
+         return jar;
       // todo This is a hack until we can fix http://jira.jboss.com/jira/browse/JBMICROCONT-164
       AbstractVirtualFileHandler result = (AbstractVirtualFileHandler)jar.findChild(entryPath);
       result.setPathName("");
@@ -100,9 +103,10 @@
       }
       else
       {
-         entryName = null;
+         entryName = "";
       }
-      if (entryName.trim().equals("")) return null;
+      if (entryName.trim().equals(""))
+         return "";
       
       return entryName;
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContextFactory.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContextFactory.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarContextFactory.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -40,7 +40,7 @@
 public class JarContextFactory implements VFSContextFactory
 {
    /** The protocols supported */
-   private static final String[] PROTOCOLS = { "jar" };
+   private static final String[] PROTOCOLS = { "jar", "vfsjar" };
 
    public String[] getProtocols()
    {

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -24,18 +24,17 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
 import org.jboss.virtual.plugins.context.AbstractURLHandler;
 import org.jboss.virtual.plugins.context.StructuredVirtualFileHandler;
+import org.jboss.virtual.protocol.vfsjar.VFSJarFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -53,7 +52,7 @@
    private static final long serialVersionUID = 1L;
 
    /** The jar file */
-   private transient final JarFile jar;
+   private transient final VFSJarFile jar;
    
    /** The jar entry */
    private transient final JarEntry entry;
@@ -72,25 +71,11 @@
     * @throws IOException for an error accessing the file system
     * @throws IllegalArgumentException for a null context, url, jar or entry
     */
-   public JarEntryHandler(VFSContext context, VirtualFileHandler parent, JarFile jar,
-      JarEntry entry, String entryName, URL url)
+   public JarEntryHandler(VFSContext context, VirtualFileHandler parent, VFSJarFile jar,
+      JarEntry entry, String entryName, URLConnection urlConn)
       throws IOException
    {
-      super(context, parent, url, entryName);
-      try
-      {
-         URL parentVfsUrl = parent.toVfsUrl();
-         String vfsParentUrl = parentVfsUrl.toString();
-         String vfsUrlString = null;
-         if (vfsParentUrl.endsWith("/")) vfsUrlString = vfsParentUrl + entryName;
-         else vfsUrlString = vfsParentUrl + "/" + entryName;
-         if (entry.isDirectory()) vfsUrlString += "/";
-         vfsUrl = new URL(vfsUrlString);
-      }
-      catch (URISyntaxException e)
-      {
-         throw new RuntimeException(e);
-      }
+      super(context, parent, urlConn, entryName);
 
       if (jar == null)
          throw new IllegalArgumentException("Null jar");
@@ -101,12 +86,6 @@
 
 
    @Override
-   protected void initCacheLastModified()
-   {
-      // complete
-   }
-
-   @Override
    public boolean hasBeenModified() throws IOException
    {
       return false; // right now, jar entries should always 

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/JarHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -24,10 +24,10 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.net.JarURLConnection;
-import java.net.URL;
+import java.net.URLConnection;
 import java.util.jar.JarFile;
 
+import org.jboss.virtual.protocol.vfsjar.VFSJarFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -52,43 +52,26 @@
     * @throws IOException for an error accessing the file system
     * @throws IllegalArgumentException for a null context, url or vfsPath
     */
-   public JarHandler(VFSContext context, VirtualFileHandler parent, URL url, String name) throws IOException
+   public JarHandler(VFSContext context, VirtualFileHandler parent,
+         URLConnection urlConn, String name) throws IOException
    {
-      super(context, parent, url, name);
-      this.vfsUrl = new URL("vfs" + url.toString());
+      super(context, parent, urlConn, name);
 
       try
       {
-         JarURLConnection connection =  (JarURLConnection) url.openConnection();
-         initJarFile(connection.getJarFile());
+         //JarURLConnection connection =  (JarURLConnection) urlConn;
+         VFSJarFile jarFile = (VFSJarFile) urlConn.getContent();
+         initJarFile(jarFile);
       }
       catch (IOException original)
       {
          // Fix the context of the error message
-         IOException e = new IOException("Error opening jar file: " + url + " reason=" + original.getMessage());
+         IOException e = new IOException("Error opening jar file: " + urlConn + " reason=" + original.getMessage());
          e.setStackTrace(original.getStackTrace());
          throw e;
       }
    }
 
-   public JarHandler(VFSContext context, VirtualFileHandler parent, File file, URL url, String name) throws IOException
-   {
-      super(context, parent, url, name);
-      this.vfsUrl = new URL("vfs" + url.toString());
-
-      try
-      {
-         initJarFile(new JarFile(file));
-      }
-      catch (IOException original)
-      {
-         // Fix the context of the error message
-         IOException e = new IOException("Error opening jar file: " + url + " reason=" + original.getMessage());
-         e.setStackTrace(original.getStackTrace());
-         throw e;
-      }
-   }
-
    /**
     * Restore the jar file from the parent jar and entry name
     *
@@ -99,7 +82,7 @@
    private void readObject(ObjectInputStream in)
       throws IOException, ClassNotFoundException
    {
-      JarFile parentJar = super.getJar();
+      VFSJarFile parentJar = super.getJar();
       // Initial the parent jar entries
       initJarFile(parentJar);
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -16,6 +16,7 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -39,7 +40,7 @@
 
    private ZipInputStream zis;
    private HashMap<String, JarEntryContents> entries = new HashMap<String, JarEntryContents>();
-   private URL jarURL;
+   private URLConnection jarConn;
    private URL entryURL;
    private String vfsPath;
    private String name;
@@ -56,27 +57,15 @@
     * @param jarURL  - the URL to use as the jar URL
     * @param entry   - the parent jar ZipEntry for the nested jar
     */
-   public NestedJarFromStream(VFSContext context, VirtualFileHandler parent, ZipInputStream zis, URL jarURL, ZipEntry entry)
+   public NestedJarFromStream(VFSContext context, VirtualFileHandler parent,
+         ZipInputStream zis, URLConnection jarConn, ZipEntry entry)
    {
       super(context, parent, entry.getName());
-      this.jarURL = jarURL;
+      this.jarConn = jarConn;
       this.name = entry.getName();
       this.lastModified = entry.getTime();
       this.size = entry.getSize();
       this.zis = zis;
-      try
-      {
-         if (parent != null)
-         {
-            String vfsParentUrl = parent.toVfsUrl().toString();
-            if (vfsParentUrl.endsWith("/")) vfsUrl = new URL(vfsParentUrl + this.name);
-            else vfsUrl = new URL(vfsParentUrl + "/" + this.name);
-         }
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
    }
 
 
@@ -198,7 +187,7 @@
       try
       {
          if (entryURL == null)
-            entryURL = new URL(jarURL, getName());
+            entryURL = new URL(jarConn.getURL(), getName());
       }
       catch (MalformedURLException e)
       {
@@ -236,18 +225,9 @@
       ZipEntry entry = zis.getNextEntry();
       while (entry != null)
       {
-         try
-         {
-            String url = toURI().toASCIIString() + "!/" + entry.getName();
-            URL jecURL = new URL(url);
-            JarEntryContents jec = new JarEntryContents(getVFSContext(), this, entry, jecURL, zis, getPathName());
-            entries.put(entry.getName(), jec);
-            entry = zis.getNextEntry();
-         }
-         catch (URISyntaxException e)
-         {
-            e.printStackTrace();
-         }
+         JarEntryContents jec = new JarEntryContents(getVFSContext(), this, entry, jarConn, zis, getPathName());
+         entries.put(entry.getName(), jec);
+         entry = zis.getNextEntry();
       }
       zis.close();
       zis = null;
@@ -260,21 +240,20 @@
        * serialVersionUID
        */
       private static final long serialVersionUID = 1L;
+      private URLConnection jarConn;
       private ZipEntry entry;
-      private URL entryURL;
       private String vfsPath;
       private byte[] contents;
       private boolean isJar;
       private NestedJarFromStream njar;
       private InputStream openStream;
 
-      JarEntryContents(VFSContext context, VirtualFileHandler parent, ZipEntry entry, URL entryURL, InputStream zis,
-                       String parentVfsPath)
-              throws IOException
+      JarEntryContents(VFSContext context, VirtualFileHandler parent, ZipEntry entry,
+            URLConnection jarConn, InputStream zis, String parentVfsPath)
+            throws IOException
       {
          super(context, parent, entry.getName());
          this.entry = entry;
-         this.entryURL = entryURL;
          this.vfsPath = parentVfsPath + "/" + entry.getName();
          this.isJar = JarUtils.isArchive(entry.getName());
          int size = (int) entry.getSize();
@@ -400,7 +379,8 @@
 
       public URI toURI() throws URISyntaxException
       {
-         return entryURL.toURI();
+         // TODO: entry path is missing
+         return jarConn.getURL().toURI();
       }
 
       public String toString()
@@ -432,7 +412,7 @@
          {
             ByteArrayInputStream bais = new ByteArrayInputStream(contents);
             ZipInputStream zis = new ZipInputStream(bais);
-            njar = new NestedJarFromStream(getVFSContext(), this, zis, entryURL, entry);
+            njar = new NestedJarFromStream(getVFSContext(), this, zis, jarConn, entry);
          }
       }
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -29,9 +29,13 @@
 import java.io.ObjectInputStream;
 import java.net.URL;
 import java.net.URISyntaxException;
+import java.net.URLConnection;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
 
+import org.jboss.virtual.protocol.vfsjar.VFSJarFile;
+import org.jboss.virtual.protocol.vfsjar.VFSRandomAccessJarFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -53,9 +57,6 @@
    /** The temporary file */
    private transient File temp;
 
-   /** TODO WHAT DOES THIS DO? It is unused */
-   private transient URL original;
-
    /**
     * Create a temporary jar
     * 
@@ -65,43 +66,32 @@
     * @return the jar file
     * @throws IOException for any error
     */
-   private static JarFile createTempJar(File temp, JarFile parentJar, JarEntry entry) throws IOException
+   private static VFSJarFile createTempJar(File temp, VFSJarFile parentJar, JarEntry entry) throws IOException
    {
-      InputStream inputStream = parentJar.getInputStream(entry);
+      InputStream is = parentJar.getInputStream(entry);
+      VFSRandomAccessJarFile tmpJar = null;
       try
       {
-         FileOutputStream outputStream = new FileOutputStream(temp);
-         try
-         {
-            byte[] buffer = new byte[8096];
-            int read = inputStream.read(buffer);
-            while (read != -1)
-            {
-               outputStream.write(buffer, 0, read);
-               read = inputStream.read(buffer);
-            }
-         }
-         finally
-         {
-            outputStream.close();
-         }
+         JarInputStream jis = new JarInputStream(is);
+         tmpJar = new VFSRandomAccessJarFile(jis, temp.toURL());
       }
       finally
       {
          try
          {
-            inputStream.close();
+            is.close();
          }
          catch (IOException ignored)
          {
          }
       }
       
-      return new JarFile(temp);
+      return tmpJar;
    }
 
    public static NestedJarHandler create(VFSContext context, VirtualFileHandler parent,
-         JarFile parentJar, JarEntry entry, URL url, String entryName) throws IOException
+         VFSJarFile parentJar, JarEntry entry, URLConnection url, String entryName)
+      throws IOException
    {
       File temp = null;
 
@@ -134,24 +124,12 @@
     * @throws IllegalArgumentException for a null context, url or vfsPath
     */
    protected NestedJarHandler(VFSContext context, VirtualFileHandler parent,
-         JarFile parentJar, JarEntry entry, URL original, File temp, String entryName)
+         VFSJarFile parentJar, JarEntry entry, URLConnection original, File temp, String entryName)
       throws IOException
    {
-      super(context, parent, temp.toURL(), entryName);
+      super(context, parent, original, entryName);
 
-      try
-      {
-         String vfsParentUrl = parent.toVfsUrl().toString();
-         if (vfsParentUrl.endsWith("/")) vfsUrl = new URL(vfsParentUrl + entryName);
-         else vfsUrl = new URL(vfsParentUrl + "/" + entryName);
-      }
-      catch (URISyntaxException e)
-      {
-         throw new RuntimeException(e);
-      }
-
       this.temp = temp;
-      this.original = original;
       
       try
       {
@@ -211,7 +189,7 @@
    private void readObject(ObjectInputStream in)
       throws IOException, ClassNotFoundException
    {
-      JarFile parentJar = super.getJar();
+      VFSJarFile parentJar = super.getJar();
       // Initial the parent jar entries
       super.initJarFile(parentJar);
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -24,11 +24,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.zip.ZipInputStream;
 
+import org.jboss.virtual.protocol.vfsjar.VFSJarFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -58,10 +60,10 @@
     * @throws IOException for an error accessing the file system
     * @throws IllegalArgumentException for a null context, url or vfsPath
     */
-   public NoCopyNestedJarHandler(VFSContext context, VirtualFileHandler parent, JarFile parentJar, JarEntry entry, URL url) throws IOException
+   public NoCopyNestedJarHandler(VFSContext context, VirtualFileHandler parent,
+         VFSJarFile parentJar, JarEntry entry, URLConnection urlConn) throws IOException
    {
-      super(context, parent, url, getEntryName(entry));
-
+      super(context, parent, urlConn, getEntryName(entry));
       
       try
       {
@@ -75,12 +77,12 @@
          {
             jis = new ZipInputStream(is);
          }
-         njar = new NestedJarFromStream(context, parent, jis, url, entry); 
+         njar = new NestedJarFromStream(context, parent, jis, urlConn, entry); 
       }
       catch (IOException original)
       {
          // Fix the context of the error message
-         IOException e = new IOException("Error opening jar file: " + url + " reason=" + original.getMessage());
+         IOException e = new IOException("Error opening jar file: " + urlConn + " reason=" + original.getMessage());
          e.setStackTrace(original.getStackTrace());
          throw e;
       }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -26,6 +26,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URISyntaxException;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -66,27 +67,10 @@
     * @throws IllegalArgumentException for a null context, url, jar or entry
     */
    public SynthenticDirEntryHandler(VFSContext context, VirtualFileHandler parent,
-      String entryName, long lastModified, URL url)
+      String entryName, long lastModified, URLConnection urlConn)
       throws IOException
    {
-      super(context, parent, url, entryName);
-      try
-      {
-         URL parentVfsUrl = parent.toVfsUrl();
-         String vfsParentUrl = parentVfsUrl.toString();
-         if (vfsParentUrl.endsWith("/"))
-         {
-            vfsUrl = new URL(vfsParentUrl + entryName);
-         }
-         else
-         {
-            vfsUrl = new URL(vfsParentUrl + "/" + entryName + "/");
-         }
-      }
-      catch (URISyntaxException e)
-      {
-         throw new RuntimeException(e);
-      }
+      super(context, parent, urlConn, entryName);
       this.lastModified = lastModified;
    }
 

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectory.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -44,6 +44,7 @@
  */
 public class AssembledDirectory extends VirtualFile
 {
+   private static final long serialVersionUID = 1;
    private AssembledDirectoryHandler directory;
 
    public AssembledDirectory(VirtualFileHandler handler)

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledDirectoryHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -43,8 +43,11 @@
  * @version $Revision: 1.1 $
  */
 @Assembled
-public class AssembledDirectoryHandler extends AbstractVirtualFileHandler implements StructuredVirtualFileHandler
+public class AssembledDirectoryHandler extends AbstractVirtualFileHandler
+   implements StructuredVirtualFileHandler
 {
+   private static final long serialVersionUID = 1;
+
    private long lastModified = System.currentTimeMillis();
    private List<VirtualFileHandler> children = new ArrayList<VirtualFileHandler>();
    private Map<String, VirtualFileHandler> childrenMap = new HashMap<String, VirtualFileHandler>();
@@ -55,7 +58,6 @@
       super(context, parent, name);
       String path = getPathName();
       if (!path.endsWith("/")) path += "/";
-      vfsUrl = new URL("vfs", context.getName(), -1, path, new AssembledUrlStreamHandler(context));
    }
 
    public VirtualFileHandler addChld(VirtualFileHandler handler)
@@ -82,11 +84,6 @@
       return childrenMap.get(name);
    }
 
-   public URI toURI() throws URISyntaxException
-   {
-      return vfsUrl.toURI();
-   }
-
    public long getLastModified() throws IOException
    {
       return lastModified;
@@ -144,9 +141,4 @@
       return new AssembledDirectory(this);
    }
 
-   @Override
-   public URL toURL() throws MalformedURLException, URISyntaxException
-   {
-      return vfsUrl;
-   }
 }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledFileHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -40,14 +40,13 @@
 @Assembled
 public class AssembledFileHandler extends AbstractVirtualFileHandler
 {
+   private static final long serialVersionUID = 1;
    private VirtualFileHandler delegate;
 
    public AssembledFileHandler(AssembledContext context, AssembledDirectoryHandler parent, String name, VirtualFileHandler delegate) throws IOException
    {
       super(context, parent, name);
       this.delegate = delegate;
-      vfsUrl = new URL("vfs", context.getName(), -1, getPathName(), new AssembledUrlStreamHandler(context));
-
    }
 
 

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledUrlStreamHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledUrlStreamHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/AssembledUrlStreamHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -22,7 +22,7 @@
 package org.jboss.virtual.plugins.context.vfs;
 
 import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 
 import java.net.URLStreamHandler;
 import java.net.URLConnection;

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/ByteArrayHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/ByteArrayHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/context/vfs/ByteArrayHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -22,13 +22,8 @@
 package org.jboss.virtual.plugins.context.vfs;
 
 import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
-import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.MalformedURLException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ByteArrayInputStream;
@@ -43,6 +38,7 @@
 @Assembled
 public class ByteArrayHandler extends AbstractVirtualFileHandler
 {
+   private static final long serialVersionUID = 1;
    private byte[] bytes;
    private final long lastModified = System.currentTimeMillis();
 
@@ -51,21 +47,9 @@
    {
       super(context, parent, name);
       this.bytes = bytes;
-      vfsUrl = new URL("vfs", context.getName(), -1, getPathName(), new AssembledUrlStreamHandler(context));
    }
 
 
-   @Override
-   public URL toURL() throws MalformedURLException, URISyntaxException
-   {
-      return vfsUrl;
-   }
-
-   public URI toURI() throws URISyntaxException
-   {
-      return vfsUrl.toURI();
-   }
-
    public long getLastModified() throws IOException
    {
       return lastModified;

Deleted: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -1,117 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.virtual.plugins.vfs;
-
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VFS;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-import java.util.Collections;
-import java.util.HashMap;
-
-/**
- * Implements basic URLConnection for a VirtualFile
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public class VirtualFileURLConnection extends URLConnection
-{
-   public static Map<URL, VFS> urlCache = Collections.synchronizedMap(new HashMap<URL, VFS>());
-
-   protected VirtualFile file;
-   protected URL vfsurl;
-   protected String relativePath;
-
-
-   public VirtualFileURLConnection(URL url, URL vfsurl, String relativePath)
-   {
-      super(url);
-      this.vfsurl = vfsurl;
-      this.relativePath = relativePath;
-   }
-
-   public VirtualFileURLConnection(URL url, VirtualFile file)
-   {
-      super(url);
-      this.file = file;
-   }
-
-   public void connect() throws IOException
-   {
-   }
-
-   public static VirtualFile resolveCachedVirtualFile(URL vfsurl, String relativePath) throws IOException
-   {
-      VFS vfs = urlCache.get(vfsurl);
-      if (vfs == null)
-      {
-         vfs = VFS.getVFS(vfsurl);
-         urlCache.put(vfsurl, vfs);
-      }
-      else
-      {
-         // if the root of VFS has changed on disk, lets purge it
-         // this is important for Jar files as we don't want stale jars as the
-         // root of the VFS (i.e., on redeployment)
-         if (vfs.getRoot().getHandler().hasBeenModified())
-         {
-            vfs = VFS.getVFS(vfsurl);
-            urlCache.put(vfsurl, vfs);
-         }
-      }
-      return vfs.findChild(relativePath);
-
-   }
-
-   public static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
-   {
-      VFS vfs = VFS.getVFS(vfsurl);
-      return vfs.findChild(relativePath);
-   }
-
-   public synchronized VirtualFile getVirtualFile() throws IOException
-   {
-      if (file == null)
-      {
-         if (this.getUseCaches())
-         {
-            file = resolveCachedVirtualFile(vfsurl, relativePath);
-         }
-         else
-         {
-            file = resolveVirtualFile(vfsurl, relativePath);
-         }
-      }
-      return file;
-   }
-
-
-   public InputStream getInputStream() throws IOException
-   {
-      return getVirtualFile().openStream();
-   }
-}

Deleted: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -1,73 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.virtual.plugins.vfs;
-
-import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.VirtualFile;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.net.URISyntaxException;
-import java.io.IOException;
-
-/**
- * Used when creating VFS urls so we don't have to go through the handlers all the time
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public class VirtualFileUrlStreamHandler extends URLStreamHandler
-{
-   private final VFSContext context;
-
-
-   public VirtualFileUrlStreamHandler(VirtualFileHandler handler)
-   {
-      this.context = handler.getVFSContext();
-   }
-
-   protected URLConnection openConnection(URL u) throws IOException
-   {
-      String baseRootUrl = null;
-      try
-      {
-         baseRootUrl = context.getRoot().toVfsUrl().toString();
-      }
-      catch (URISyntaxException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException(e);
-      }
-      String urlString = u.toString();
-      int idx = urlString.indexOf(baseRootUrl);
-      if (idx == -1) throw new IOException(u.toString() + " does not belong to the same VFS context as " + baseRootUrl);
-      String path = urlString.substring(baseRootUrl.length());
-      VirtualFileHandler vf = context.getRoot().findChild(path);
-      if (vf == null) throw new IOException(path + " was not found in VFS context " + baseRootUrl);
-      return new VirtualFileURLConnection(u, vf.getVirtualFile());
-   }
-}

Copied: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileURLConnection.java (from rev 62756, projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java)
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileURLConnection.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileURLConnection.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,162 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.virtual.protocol;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFS;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * Implements basic URLConnection for a VirtualFile
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class VirtualFileURLConnection extends URLConnection
+{
+   private static Logger log = Logger.getLogger(VirtualFileURLConnection.class);
+   private static Map<URL, VFS> urlCache = Collections.synchronizedMap(new HashMap<URL, VFS>());
+
+   private VirtualFile file;
+   private URL vfsurl;
+   private String relativePath;
+
+
+   public VirtualFileURLConnection(URL vfsurl, String relativePath)
+   {
+      super(vfsurl);
+      this.vfsurl = vfsurl;
+      this.relativePath = relativePath;
+   }
+
+   public VirtualFileURLConnection(URL url, VirtualFile file)
+   {
+      super(url);
+      this.file = file;
+   }
+
+   public static VirtualFile resolveCachedVirtualFile(URL vfsurl, String relativePath) throws IOException
+   {
+      VFS vfs = urlCache.get(vfsurl);
+      if (vfs == null)
+      {
+         vfs = VFS.getVFS(vfsurl);
+         urlCache.put(vfsurl, vfs);
+      }
+      else
+      {
+         // if the root of VFS has changed on disk, lets purge it
+         // this is important for Jar files as we don't want stale jars as the
+         // root of the VFS (i.e., on redeployment)
+         if (vfs.getRoot().getHandler().hasBeenModified())
+         {
+            vfs = VFS.getVFS(vfsurl);
+            urlCache.put(vfsurl, vfs);
+         }
+      }
+      return vfs.findChild(relativePath);
+
+   }
+
+   public static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
+   {
+      VFS vfs = VFS.getVFS(vfsurl);
+      return vfs.findChild(relativePath);
+   }
+
+   public synchronized VirtualFile getVirtualFile() throws IOException
+   {
+      if (file == null)
+      {
+         if (this.getUseCaches())
+         {
+            file = resolveCachedVirtualFile(vfsurl, relativePath);
+         }
+         else
+         {
+            file = resolveVirtualFile(vfsurl, relativePath);
+         }
+      }
+      return file;
+   }
+
+
+   public void connect() throws IOException
+   {
+   }
+
+   @Override
+   public InputStream getInputStream() throws IOException
+   {
+      return getVirtualFile().openStream();
+   }
+
+   /**
+    * This restricts file sizes to < 4Gb.
+    */
+   @Override
+   public int getContentLength()
+   {
+      int size = -1;
+      try
+      {
+         long lsize = getVirtualFile().getSize();
+         if( lsize > Integer.MAX_VALUE )
+            log.debug("File("+file+") size > Integer.MAX_VALUE, "+lsize);
+         size = (int) lsize;
+      }
+      catch (IOException e)
+      {
+         log.debug("Failed to obtain size for: "+file);
+      }
+      return size;
+   }
+
+   @Override
+   public long getDate()
+   {
+      return getLastModified();
+   }
+
+   @Override
+   public long getLastModified()
+   {
+      long lastModified = 0;
+      try
+      {
+         lastModified = getVirtualFile().getLastModified();
+      }
+      catch (IOException e)
+      {
+         log.debug("Failed to obtain lastModified for: "+file);
+      }
+      return lastModified;
+   }
+}

Copied: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileUrlStreamHandler.java (from rev 62756, projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileUrlStreamHandler.java)
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileUrlStreamHandler.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/VirtualFileUrlStreamHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.virtual.protocol;
+
+import org.jboss.virtual.spi.VirtualFileHandler;
+import org.jboss.virtual.spi.VFSContext;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.io.IOException;
+
+/**
+ * Used when creating VFS urls so we don't have to go through the handlers
+ * all the time
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class VirtualFileUrlStreamHandler extends URLStreamHandler
+{
+   private final VFSContext context;
+
+
+   public VirtualFileUrlStreamHandler(VirtualFileHandler handler)
+   {
+      this.context = handler.getVFSContext();
+   }
+
+   protected URLConnection openConnection(URL u) throws IOException
+   {
+      String baseRootUrl = null;
+      try
+      {
+         baseRootUrl = context.getRoot().toURL().toString();
+      }
+      catch (URISyntaxException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      String urlString = u.toString();
+      int idx = urlString.indexOf(baseRootUrl);
+      if (idx == -1) throw new IOException(u.toString() + " does not belong to the same VFS context as " + baseRootUrl);
+      String path = urlString.substring(baseRootUrl.length());
+      VirtualFileHandler vf = context.getRoot().findChild(path);
+      if (vf == null) throw new IOException(path + " was not found in VFS context " + baseRootUrl);
+      return new VirtualFileURLConnection(u, vf.getVirtualFile());
+   }
+}

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfs/Handler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfs/Handler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfs/Handler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -21,7 +21,7 @@
 */
 package org.jboss.virtual.protocol.vfs;
 
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 import org.jboss.virtual.plugins.context.vfs.AssembledContextFactory;
 import org.jboss.virtual.plugins.context.vfs.AssembledDirectory;
 import org.jboss.virtual.VirtualFile;

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsfile/Handler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsfile/Handler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsfile/Handler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -21,7 +21,7 @@
 */
 package org.jboss.virtual.protocol.vfsfile;
 
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 
 import java.io.File;
 import java.io.IOException;
@@ -39,6 +39,7 @@
 {
    protected URLConnection openConnection(URL u) throws IOException
    {
+      /*
       String file = u.toString().substring(8); // strip out vfsfile:
       URL vfsurl = null;
       String relative;
@@ -65,10 +66,11 @@
             }
          }
       }
-
       if (vfsurl == null)
          throw new IOException("vfsfile does not exist: " + u.toString());
-      return new VirtualFileURLConnection(u, vfsurl, relative);
+      */
+
+      return new VirtualFileURLConnection(u, "");
    }
 
 }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/Handler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/Handler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/Handler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -22,12 +22,11 @@
 package org.jboss.virtual.protocol.vfsjar;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
 
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 
 /**
  * URLStreamHandler for VFS
@@ -39,25 +38,6 @@
 {
    protected URLConnection openConnection(URL u) throws IOException
    {
-      String urlString = u.toString();
-      int index = urlString.indexOf("!/");
-      String file = urlString.substring(3, index + 2); // strip out vfs
-      String path = urlString.substring(index + 2);
-      URL url = new URL(file);
-      return new VirtualFileURLConnection(u, url, path);
+      return new VFSJarURLConnection(u);
    }
-   public static void main(String[] args) throws Exception
-   {
-      System.setProperty("java.protocol.handler.pkgs", "org.jboss.virtual.protocol");
-      //URL url = new URL("vfsfile:/c:/tmp/urlstream.java");
-      //URL url = new URL("vfsfile:/C:\\jboss\\jboss-head\\build\\output\\jboss-5.0.0.Beta\\server\\default\\lib\\jboss.jar\\schema\\xml.xsd");
-      URL url = new URL("vfsjar:file:/c:/tmp/parent.jar!/foo.jar/urlstream.java");
-      InputStream is = url.openStream();
-      while (is.available() != 0)
-      {
-         System.out.print((char)is.read());
-      }
-      is.close();
-
-   }
 }

Added: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarFile.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarFile.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarFile.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.protocol.vfsjar;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public abstract class VFSJarFile
+{
+   
+   public void init(JarInputStream jis)
+      throws IOException
+   {
+      JarEntry entry = jis.getNextJarEntry();
+      while( entry != null )
+      {
+         addEntry(entry, jis);
+      }
+   }
+
+   public abstract Iterator<JarEntry> getEntries();
+   public abstract void addEntry(JarEntry entry, InputStream is)
+      throws IOException;
+   public abstract JarEntry getEntry(String name);
+   public abstract InputStream getInputStream(String name)
+      throws IOException;
+   public InputStream getInputStream(JarEntry entry)
+      throws IOException
+   {
+      return getInputStream(entry.getName());
+   }
+}


Property changes on: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarFile.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarURLConnection.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarURLConnection.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarURLConnection.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.protocol.vfsjar;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.jar.JarInputStream;
+
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class VFSJarURLConnection extends VirtualFileURLConnection
+{
+   public static final String VFS_JARURL_CLASS = "VFSJarURLClass";
+   public static final String DEFAULT_VFS_JARURL_CLASS =
+      "org.jboss.virtual.protocol.vfsjar.VFSRandomAccessJarFile";
+
+   private VFSJarFile jarFile;
+
+   public VFSJarURLConnection(URL vfsurl)
+   {
+      super(vfsurl, "");
+   }
+
+   @Override
+   public Object getContent() throws IOException
+   {
+      if( jarFile == null )
+      {
+         // Create the VFSJarFile
+         String jarClassName = super.getRequestProperty("VFS_JARURL_CLASS");
+         if( jarClassName == null )
+            jarClassName = DEFAULT_VFS_JARURL_CLASS;
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         try
+         {
+            Class jarClass = loader.loadClass(jarClassName);
+            // ctor(JarInputStream jis, URL url)
+            Class[] sig = {JarInputStream.class, URL.class};
+            Constructor<VFSJarFile> ctor = jarClass.getConstructor(sig);
+            Object[] args = {null, super.getURL()};
+            jarFile = ctor.newInstance(args);
+         }
+         catch(Exception e)
+         {
+            IOException ioe = new IOException();
+            ioe.initCause(e);
+            throw ioe;
+         }
+      }
+      return jarFile;
+   }
+
+}


Property changes on: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSJarURLConnection.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSMemoryJarFile.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSMemoryJarFile.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSMemoryJarFile.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.protocol.vfsjar;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class VFSMemoryJarFile extends VFSJarFile
+{
+   private HashMap<String, JarEntry> entries = new HashMap<String, JarEntry>();
+   private HashMap<String, EntryData> entryData = new HashMap<String, EntryData>();
+
+   public VFSMemoryJarFile(JarInputStream jis, URL url) throws IOException
+   {
+      init(jis);
+   }
+
+   @Override
+   public Iterator<JarEntry> getEntries()
+   {
+      return entries.values().iterator();
+   }
+
+   @Override
+   public void addEntry(JarEntry entry, InputStream is)
+      throws IOException
+   {
+      String key = entry.getName();
+      entries.put(key, entry);
+      EntryData data = new EntryData(is);
+      entryData.put(key, data);
+   }
+
+   @Override
+   public JarEntry getEntry(String name)
+   {
+      JarEntry entry = entries.get(name);
+      return entry;
+   }
+
+   @Override
+   public InputStream getInputStream(String name)
+   {
+      EntryData data = entryData.get(name);
+      InputStream is = null;
+      if( data != null )
+         is = data.getInputStream();
+      return is;
+   }
+
+   private static class EntryData
+   {
+      private byte[] data;
+
+      EntryData(InputStream is)
+         throws IOException
+      {
+         ByteArrayOutputStream baos = new ByteArrayOutputStream(is.available()+3);
+         byte[] tmp = new byte[2048];
+         int length = 0;
+         while( (length = is.read(tmp)) > 0 )
+         {
+            baos.write(tmp, 0, length);
+         }
+         is.close();
+         data = baos.toByteArray();
+      }
+      InputStream getInputStream()
+      {
+         return new ByteArrayInputStream(data);
+      }
+   }
+}


Property changes on: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSMemoryJarFile.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSRandomAccessJarFile.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSRandomAccessJarFile.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSRandomAccessJarFile.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.protocol.vfsjar;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class VFSRandomAccessJarFile extends VFSJarFile
+{
+   private HashMap<String, JarEntry> entries = new HashMap<String, JarEntry>();
+   private HashMap<String, EntryData> entryData = new HashMap<String, EntryData>();
+   private RandomAccessFile jarFile;
+
+   /**
+    * 
+    * @param jis
+    * @param url
+    * @throws IOException
+    */
+   public VFSRandomAccessJarFile(JarInputStream jis, URL url)
+      throws IOException
+   {
+      if( jis == null )
+      {
+         FileInputStream fis = new FileInputStream(url.getPath());
+         BufferedInputStream bis = new BufferedInputStream(fis);
+         jis = new JarInputStream(bis);
+      }
+      File name = new File(url.getFile());
+      File file = File.createTempFile(name.getName(), ".vfsjar");
+      jarFile = new RandomAccessFile(file, "w");
+
+      init(jis);
+      jarFile.close();
+      jarFile = new RandomAccessFile(file, "r");
+   }
+
+   
+   @Override
+   public Iterator<JarEntry> getEntries()
+   {
+      return entries.values().iterator();
+   }
+
+   @Override
+   public void addEntry(JarEntry entry, InputStream is)
+      throws IOException
+   {
+      String key = entry.getName();
+      entries.put(key, entry);
+      
+   }
+
+   @Override
+   public JarEntry getEntry(String name)
+   {
+      JarEntry entry = entries.get(name);
+      return entry;
+   }
+
+   @Override
+   public InputStream getInputStream(String name)
+      throws IOException
+   {
+      EntryData data = entryData.get(name);
+      InputStream is = null;
+      if( data != null )
+         is = data.getInputStream(jarFile);
+      return is;
+   }
+
+   private static class EntryData
+   {
+      private long begin;
+      private long end;
+
+      EntryData(InputStream is, RandomAccessFile raf)
+         throws IOException
+      {
+         byte[] tmp = new byte[2048];
+         int length = 0;
+         begin = raf.getFilePointer();
+         while( (length = is.read(tmp)) > 0 )
+         {
+            raf.write(tmp, 0, length);
+         }
+         is.close();
+         end = raf.getFilePointer();
+      }
+      InputStream getInputStream(final RandomAccessFile raf)
+         throws IOException
+      {
+         return new RafInputStream(raf, begin, end);
+      }
+   }
+   private static class RafInputStream extends InputStream
+   {
+      final RandomAccessFile raf;
+      private long begin;
+      private long end;
+
+      RafInputStream(final RandomAccessFile raf, long begin, long end)
+         throws IOException
+      {
+         this.raf = raf;
+         this.begin = begin;
+         this.end = end;
+         raf.seek(begin);
+      }
+
+      @Override
+      public int read() throws IOException
+      {
+         if( raf.getFilePointer() == end )
+            return -1;
+         return raf.read();
+      }
+
+      @Override
+      public int read(byte[] b, int off, int len) throws IOException
+      {
+         if( off >= end )
+            return -1;
+         // Adjust len to end
+         long pos = raf.getFilePointer();
+         if( pos+len >= end )
+            len = (int)(end - pos);
+         return raf.read(b, off, len);
+      }
+
+      @Override
+      public int read(byte[] b) throws IOException
+      {
+         return read(b, 0, b.length);
+      }
+   }
+}


Property changes on: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/protocol/vfsjar/VFSRandomAccessJarFile.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VFSContextFactoryLocator.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VFSContextFactoryLocator.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VFSContextFactoryLocator.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -240,10 +240,14 @@
       // No file protocol, use the default 
       if (factoryByProtocol.containsKey("file") == false)
          registerFactory(new FileSystemContextFactory());
+      if (factoryByProtocol.containsKey("vfsfile") == false)
+         registerFactory(new FileSystemContextFactory());
 
       // No jar protocol, use the default 
       if (factoryByProtocol.containsKey("jar") == false)
          registerFactory(new JarContextFactory());
+      if (factoryByProtocol.containsKey("vfsjar") == false)
+         registerFactory(new JarContextFactory());
 
       initialized = true;
    }

Modified: projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/main/java/org/jboss/virtual/spi/VirtualFileHandler.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -56,16 +56,6 @@
    String getPathName();
 
    /**
-    * Get a VFS-based URL
-    *
-    * @return the url
-    * @throws MalformedURLException
-    * @throws URISyntaxException
-    */
-   URL toVfsUrl() throws MalformedURLException, URISyntaxException;
-   
-
-   /**
     * Get the VF URI (file://root/org/jboss/X.java)
     * 
     * @return the full URI to the VF in the VFS.

Modified: projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/support/ClassPathIterator.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/support/ClassPathIterator.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/support/ClassPathIterator.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -33,10 +33,9 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
-import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.plugins.vfs.VirtualFileURLConnection;
+import org.jboss.virtual.protocol.VirtualFileURLConnection;
 
 /**
  * ClassPathIterator logic used by UCL package mapping

Modified: projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -30,6 +30,7 @@
 import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -125,8 +126,9 @@
 
       JarEntry jar1 = jf.getJarEntry("jar1.jar");
       URL jar1URL = new URL(outerJar.toURL(), "jar1.jar");
+      URLConnection jar1Conn = jar1URL.openConnection();
       ZipInputStream jis1 = new ZipInputStream(jf.getInputStream(jar1));
-      NestedJarFromStream njfs = new NestedJarFromStream(context, null, jis1, jar1URL, jar1);
+      NestedJarFromStream njfs = new NestedJarFromStream(context, null, jis1, jar1Conn, jar1);
       NestedJarFromStream.JarEntryContents e1 = njfs.getEntry("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
       assertNotNull(e1);
       log.info("org/jboss/test/vfs/support/CommonClass.class: "+e1);
@@ -142,8 +144,9 @@
 
       JarEntry jar2 = jf.getJarEntry("jar2.jar");
       URL jar2URL = new URL(outerJar.toURL(), "jar2.jar");
+      URLConnection jar2Conn = jar2URL.openConnection();
       ZipInputStream jis2 = new ZipInputStream(jf.getInputStream(jar2));
-      NestedJarFromStream njfs2 = new NestedJarFromStream(context, null, jis2, jar2URL, jar2);
+      NestedJarFromStream njfs2 = new NestedJarFromStream(context, null, jis2, jar2Conn, jar2);
       NestedJarFromStream.JarEntryContents e2 = njfs2.getEntry("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
       assertNotNull(e2);
       log.info("org/jboss/test/vfs/support/CommonClass.class: "+e2);
@@ -1203,7 +1206,7 @@
       assertNotNull("tstjar != null", tstjar);
       URI uri = tstjar.toURI();
       URI expectedURI = new URI("vfs" + rootURL.toString()+"/path%20with%20spaces/unpacked-tst.jar/");
-      assertEquals(uri, expectedURI);
+      assertEquals(expectedURI, uri);
    }
 
    /**

Modified: projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/JARVirtualFileHandlerUnitTestCase.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/JARVirtualFileHandlerUnitTestCase.java	2007-05-03 12:09:48 UTC (rev 62778)
+++ projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/JARVirtualFileHandlerUnitTestCase.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -22,8 +22,8 @@
 package org.jboss.test.virtual.test;
 
 import java.io.File;
-import java.net.JarURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
@@ -70,8 +70,8 @@
    {
       URL url = getRootResource(name);
       url = JarUtils.createJarURL(url);
-      JarURLConnection c = (JarURLConnection) url.openConnection();
-      JarFile jarFile = c.getJarFile();
+      URLConnection c = url.openConnection();
+      JarFile jarFile = (JarFile) c.getContent();
       return jarFile.getJarEntry(path);
    }
    

Added: projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/VfsProtocolUnitTestCase.java
===================================================================
--- projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/VfsProtocolUnitTestCase.java	                        (rev 0)
+++ projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/VfsProtocolUnitTestCase.java	2007-05-03 12:43:24 UTC (rev 62779)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.virtual.test;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContextFactoryLocator;
+
+/**
+ * Tests of the protocol handlers
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class VfsProtocolUnitTestCase extends BaseTestCase
+{
+   public VfsProtocolUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // Install the vfs protocol handlers
+      URL x = getClass().getProtectionDomain().getCodeSource().getLocation();
+      VFSContextFactoryLocator.getFactory(x);
+   }
+
+   public void testVfsfileHandler()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test/outer.jar");
+      File outerFile = new File(rootURL.getPath());
+      URL outerURL = new URL("vfs"+rootURL);
+      URLConnection outerConn = outerURL.openConnection();
+      long date = outerConn.getDate();
+      assertEquals(outerFile.lastModified(), date);
+      date = outerConn.getLastModified();
+      assertEquals(outerFile.lastModified(), date);
+      long size = outerConn.getContentLength();
+      assertEquals(outerFile.length(), size);
+      URL vfsURL = outerConn.getURL();
+      assertEquals(outerURL, vfsURL);
+   }
+
+   public void testVfsjarHandler()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test/outer.jar");
+      File outerFile = new File(rootURL.getPath());
+      URL outerURL = new URL("vfsjar"+rootURL.toString().substring(4));
+      URLConnection outerConn = outerURL.openConnection();
+      long date = outerConn.getDate();
+      assertEquals(outerFile.lastModified(), date);
+      date = outerConn.getLastModified();
+      assertEquals(outerFile.lastModified(), date);
+      long size = outerConn.getContentLength();
+      assertEquals(outerFile.length(), size);
+      URL vfsURL = outerConn.getURL();
+      assertEquals(outerURL, vfsURL);
+   }
+   
+}


Property changes on: projects/vfs/branches/urlconn-work/src/test/java/org/jboss/test/virtual/test/VfsProtocolUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list