[jboss-cvs] JBossAS SVN: r80404 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: plugins/vfs and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 3 15:26:16 EST 2008


Author: alesj
Date: 2008-11-03 15:26:15 -0500 (Mon, 03 Nov 2008)
New Revision: 80404

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
Log:
Expose caching in VFS.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java	2008-11-03 20:23:14 UTC (rev 80403)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java	2008-11-03 20:26:15 UTC (rev 80404)
@@ -33,6 +33,7 @@
 import org.jboss.virtual.spi.VFSContextFactoryLocator;
 import org.jboss.virtual.spi.VirtualFileHandler;
 import org.jboss.virtual.spi.cache.VFSCacheFactory;
+import org.jboss.virtual.spi.cache.VFSCache;
 import org.jboss.util.file.ArchiveBrowser;
 
 /**
@@ -99,7 +100,7 @@
     * @param rootURI the root uri
     * @return the virtual file
     * @throws IOException if there is a problem accessing the VFS
-    * @throws IllegalArgumentException if the rootURL
+    * @throws IllegalArgumentException if the rootURL is null
     */
    public static VirtualFile getRoot(URI rootURI) throws IOException
    {
@@ -108,6 +109,24 @@
    }
 
    /**
+    * Get cached file.
+    *
+    * If VFSContext matching the rootURI parameter is cached
+    * this method will return cached virtual file
+    * else it will use VFS::getRoot(rootURI).
+    *
+    * @param rootURI the root uri
+    * @return the cached virtual file
+    * @throws IOException for any error
+    * @throws IllegalArgumentException if the rootURL is null
+    */
+   public static VirtualFile getCachedFile(URI rootURI) throws IOException
+   {
+      VFSCache cache = VFSCacheFactory.getInstance();
+      return cache.getFile(rootURI);
+   }
+
+   /**
     * Get a virtual file
     * 
     * @param rootURI the root uri
@@ -155,6 +174,24 @@
    }
 
    /**
+    * Get cached file.
+    *
+    * If VFSContext matching the rootURL parameter is cached
+    * this method will return cached virtual file
+    * else it will use VFS::getRoot(rootURL).
+    *
+    * @param rootURL the root url
+    * @return the cached virtual file
+    * @throws IOException for any error
+    * @throws IllegalArgumentException if the rootURL is null
+    */
+   public static VirtualFile getCachedFile(URL rootURL) throws IOException
+   {
+      VFSCache cache = VFSCacheFactory.getInstance();
+      return cache.getFile(rootURL);
+   }
+
+   /**
     * Get a virtual file
     * 
     * @param rootURL the root url

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-11-03 20:23:14 UTC (rev 80403)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-11-03 20:26:15 UTC (rev 80404)
@@ -26,9 +26,8 @@
 import java.net.URL;
 import java.net.URLConnection;
 
+import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.cache.VFSCache;
-import org.jboss.virtual.spi.cache.VFSCacheFactory;
 
 /**
  * Implements basic URLConnection for a VirtualFile
@@ -103,8 +102,7 @@
    @SuppressWarnings("deprecation")
    protected static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
    {
-      VFSCache cache = VFSCacheFactory.getInstance();
-      VirtualFile file = cache.getFile(vfsurl);
+      VirtualFile file = VFS.getCachedFile(vfsurl);
       return file.findChild(relativePath);
    }
 




More information about the jboss-cvs-commits mailing list