Index: src/test/java/org/jboss/test/vfs/URLConnectionUnitTestCase.java
===================================================================
--- src/test/java/org/jboss/test/vfs/URLConnectionUnitTestCase.java	(revision 101975)
+++ src/test/java/org/jboss/test/vfs/URLConnectionUnitTestCase.java	(working copy)
@@ -21,20 +21,21 @@
 */
 package org.jboss.test.vfs;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.Executors;
 
 import junit.framework.Test;
 
+import org.jboss.vfs.TempFileProvider;
 import org.jboss.vfs.VFS;
 import org.jboss.vfs.VFSUtils;
 import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.protocol.FileURLConnection;
 
 /**
  * Basic tests of URL connection
@@ -158,6 +159,41 @@
       assertEquals(file.lastModified(), conn.getLastModified());
    }
 
+   public void testFileUrl() throws Exception
+   {
+      // Hack to ensure VFS.init has been called and has taken over the file: protocol
+      VFS.getChild("");
+      URL resourceUrl = getResource("/vfs/test/outer.jar");
+      // Hack to ensure the URL handler is not passed down by the parent URL context
+      URL url = new URL("file", resourceUrl.getHost(), resourceUrl.getFile());
+
+      // Make sure we are using our handler
+      URLConnection urlConn = url.openConnection();
+      assertTrue(urlConn instanceof FileURLConnection); 
+
+      File file = new File(url.toURI());
+      assertNotNull(file);
+
+      VirtualFile vf = VFS.getChild(url);
+      assertTrue(vf.isFile());
+       // Mount a temp dir over the jar location in VFS
+      TempFileProvider provider = null;
+      Closeable handle = null;
+      try {
+         provider = TempFileProvider.create("temp", Executors.newSingleThreadScheduledExecutor());
+         handle = VFS.mountTemp(vf, provider);
+         assertTrue(vf.isDirectory());
+
+         File vfsDerivedFile = vf.getPhysicalFile();
+         File urlDerivedFile = (File)url.getContent();
+         // Make sure the file returned by the file: URL is not the VFS File (In other words, make sure it does not use the mounts)
+         assertTrue(urlDerivedFile.isFile());
+         assertFalse(vfsDerivedFile.equals(urlDerivedFile));
+      } finally {
+         VFSUtils.safeClose(handle, provider);
+      }
+   }
+
    protected static byte[] readBytes(InputStream inputStream) throws Exception
    {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
Index: src/main/java/org/jboss/vfs/protocol/file/Handler.java
===================================================================
--- src/main/java/org/jboss/vfs/protocol/file/Handler.java	(revision 101965)
+++ src/main/java/org/jboss/vfs/protocol/file/Handler.java	(working copy)
@@ -22,11 +22,16 @@
 
 package org.jboss.vfs.protocol.file;
 
+import org.jboss.vfs.protocol.AbstractLocalURLStreamHandler;
+import org.jboss.vfs.protocol.FileURLStreamHandler;
 import org.jboss.vfs.protocol.VirtualFileURLStreamHandler;
 
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
 /**
  * Stub handler class.
  */
-public final class Handler extends VirtualFileURLStreamHandler {
-
+public final class Handler extends FileURLStreamHandler {
 }
Index: src/main/java/org/jboss/vfs/protocol/FileURLConnection.java
===================================================================
--- src/main/java/org/jboss/vfs/protocol/FileURLConnection.java	(revision 0)
+++ src/main/java/org/jboss/vfs/protocol/FileURLConnection.java	(revision 0)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.vfs.protocol;
+
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.spi.RootFileSystem;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.*;
+import java.security.Permission;
+
+/**
+ * Implementation URLConnection that will delegate to the VFS RootFileSystem.
+ *
+ * @author <a href=mailto:jbailey@redhat.com">John Bailey</a>
+ * @version $Revision$
+ */
+public class FileURLConnection extends org.jboss.net.protocol.file.FileURLConnection {
+
+   private final RootFileSystem rootFileSystem = RootFileSystem.ROOT_INSTANCE;
+
+   private final VirtualFile mountPoint = VFS.getRootVirtualFile();
+    
+   private final VirtualFile file;
+
+   public FileURLConnection(URL url) throws IOException
+   {
+      super(url);
+      file = VFS.getChild(toURI(url));
+   }
+
+   public File getContent() throws IOException
+   {
+      return rootFileSystem.getFile(mountPoint, file);
+   }
+
+   public int getContentLength()
+   {
+      final long size = rootFileSystem.getSize(mountPoint, file);
+      return size > (long) Integer.MAX_VALUE ? -1 : (int) size;
+   }
+
+   public long getLastModified()
+   {
+      return rootFileSystem.getLastModified(mountPoint, file);
+   }
+
+   public InputStream getInputStream() throws IOException
+   {
+      return rootFileSystem.openInputStream(mountPoint, file);
+   }
+
+   private static URI toURI(URL url) throws IOException
+   {
+      try
+      {
+         return VFSUtils.toURI(url);
+      }
+      catch (URISyntaxException e)
+      {
+         IOException ioe = new IOException();
+         ioe.initCause(e);
+         throw ioe;
+      }
+   }
+}
Index: src/main/java/org/jboss/vfs/protocol/VirtualFileURLStreamHandler.java
===================================================================
--- src/main/java/org/jboss/vfs/protocol/VirtualFileURLStreamHandler.java	(revision 101965)
+++ src/main/java/org/jboss/vfs/protocol/VirtualFileURLStreamHandler.java	(working copy)
@@ -33,37 +33,11 @@
 /**
  * The VFS URL stream handler.
  */
-public abstract class VirtualFileURLStreamHandler extends URLStreamHandler {
+public abstract class VirtualFileURLStreamHandler extends AbstractLocalURLStreamHandler {
 
-    private static final Set<String> locals;
-
-    static {
-        Set<String> set = new HashSet<String>();
-        set.add(null);
-        set.add("");
-        set.add("~");
-        set.add("localhost");
-        locals = set;
-    }
-
-    protected URLConnection openConnection(URL u) throws IOException {
-        if (locals.contains(toLower(u.getHost()))) {
-            // the URL is a valid local URL
-            return new VirtualFileURLConnection(u);
-        }
-        throw new IOException("Remote host access not supported for URLs of type \"" + u.getProtocol() + "\"");
-    }
-
-    protected URLConnection openConnection(URL u, Proxy p) throws IOException {
-        return openConnection(u);
-    }
-
     @Override
-    protected boolean hostsEqual(URL url1, URL url2) {
-        return locals.contains(toLower(url1.getHost())) && locals.contains(toLower(url2.getHost())) || super.hostsEqual(url1, url2);
+    protected URLConnection openConnection(URL url) throws IOException {
+        ensureLocal(url);
+        return new VirtualFileURLConnection(url);
     }
-
-    private static String toLower(String str) {
-        return str == null ? null : str.toLowerCase();
-    }
 }
Index: src/main/java/org/jboss/vfs/protocol/AbstractLocalURLStreamHandler.java
===================================================================
--- src/main/java/org/jboss/vfs/protocol/AbstractLocalURLStreamHandler.java	(revision 0)
+++ src/main/java/org/jboss/vfs/protocol/AbstractLocalURLStreamHandler.java	(revision 0)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.vfs.protocol;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Abstract URLStreamHandler that can be used as a base for other URLStreamHandlers that
+ * require the URL to be local.
+ *
+ * @author <a href=mailto:jbailey@redhat.com">John Bailey</a>
+ * @version $Revision$
+ */
+public abstract class AbstractLocalURLStreamHandler extends URLStreamHandler {
+
+    private static final Set<String> locals;
+
+    static {
+        Set<String> set = new HashSet<String>();
+        set.add(null);
+        set.add("");
+        set.add("~");
+        set.add("localhost");
+        locals = set;
+    }
+
+    @Override
+    protected URLConnection openConnection(URL u, Proxy p) throws IOException {
+        return openConnection(u);
+    }
+
+    @Override
+    protected boolean hostsEqual(URL url1, URL url2) {
+        return locals.contains(toLower(url1.getHost())) && locals.contains(toLower(url2.getHost())) || super.hostsEqual(url1, url2);
+    }
+
+    private static String toLower(String str) {
+        return str == null ? null : str.toLowerCase();
+    }
+
+    protected void ensureLocal(URL url) throws IOException {
+       if (!locals.contains(toLower(url.getHost())))   
+          throw new IOException("Remote host access not supported for URLs of type \"" + url.getProtocol() + "\"");
+    }
+
+}
Index: src/main/java/org/jboss/vfs/protocol/FileURLStreamHandler.java
===================================================================
--- src/main/java/org/jboss/vfs/protocol/FileURLStreamHandler.java	(revision 0)
+++ src/main/java/org/jboss/vfs/protocol/FileURLStreamHandler.java	(revision 0)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.vfs.protocol;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * A File based URLStreamHandler
+ *
+ * @author <a href=mailto:jbailey@redhat.com">John Bailey</a>
+ * @version $Revision$
+ */
+public class FileURLStreamHandler extends AbstractLocalURLStreamHandler {
+    @Override
+    protected URLConnection openConnection(final URL url) throws IOException {
+        ensureLocal(url);
+        return new FileURLConnection(url);
+    }
+}
