[jboss-cvs] JBossAS SVN: r83349 - in projects/vfs/trunk/src: main/java/org/jboss/virtual/plugins/vfs and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 23 08:50:42 EST 2009
Author: alesj
Date: 2009-01-23 08:50:42 -0500 (Fri, 23 Jan 2009)
New Revision: 83349
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
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
Log:
[JBVFS-87]; introduce VFS::createNewRoot, deprecate getCachedFile.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java 2009-01-23 11:14:09 UTC (rev 83348)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java 2009-01-23 13:50:42 UTC (rev 83349)
@@ -158,6 +158,20 @@
}
/**
+ * Create new root
+ *
+ * @param rootURI the root url
+ * @return the virtual file
+ * @throws IOException if there is a problem accessing the VFS
+ * @throws IllegalArgumentException if the rootURL
+ */
+ public static VirtualFile createNewRoot(URI rootURI) throws IOException
+ {
+ VFS vfs = getVFS(rootURI);
+ return vfs.getRoot();
+ }
+
+ /**
* Get the root virtual file
*
* @param rootURI the root uri
@@ -167,8 +181,9 @@
*/
public static VirtualFile getRoot(URI rootURI) throws IOException
{
- VFS vfs = getVFS(rootURI);
- return vfs.getRoot();
+ VFSCache cache = VFSCacheFactory.getInstance();
+ VirtualFile file = cache.getFile(rootURI);
+ return (file != null) ? file : createNewRoot(rootURI);
}
/**
@@ -182,12 +197,12 @@
* @return the cached virtual file
* @throws IOException for any error
* @throws IllegalArgumentException if the rootURL is null
+ * @deprecated use getRoot
*/
+ @Deprecated
public static VirtualFile getCachedFile(URI rootURI) throws IOException
{
- VFSCache cache = VFSCacheFactory.getInstance();
- VirtualFile file = cache.getFile(rootURI);
- return (file != null) ? file : getRoot(rootURI);
+ return getRoot(rootURI);
}
/**
@@ -202,8 +217,8 @@
@SuppressWarnings("deprecation")
public static VirtualFile getVirtualFile(URI rootURI, String name) throws IOException
{
- VFS vfs = getVFS(rootURI);
- return vfs.findChild(name);
+ VirtualFile root = getRoot(rootURI);
+ return root.findChild(name);
}
/**
@@ -225,20 +240,35 @@
}
/**
- * Get the root virtual file
+ * Create new root
*
* @param rootURL the root url
* @return the virtual file
* @throws IOException if there is a problem accessing the VFS
* @throws IllegalArgumentException if the rootURL
*/
- public static VirtualFile getRoot(URL rootURL) throws IOException
+ public static VirtualFile createNewRoot(URL rootURL) throws IOException
{
VFS vfs = getVFS(rootURL);
return vfs.getRoot();
}
/**
+ * Get the root virtual file
+ *
+ * @param rootURL the root url
+ * @return the virtual file
+ * @throws IOException if there is a problem accessing the VFS
+ * @throws IllegalArgumentException if the rootURL
+ */
+ public static VirtualFile getRoot(URL rootURL) throws IOException
+ {
+ VFSCache cache = VFSCacheFactory.getInstance();
+ VirtualFile file = cache.getFile(rootURL);
+ return (file != null) ? file : createNewRoot(rootURL);
+ }
+
+ /**
* Get cached file.
*
* If VFSContext matching the rootURL parameter is cached
@@ -249,12 +279,12 @@
* @return the cached virtual file
* @throws IOException for any error
* @throws IllegalArgumentException if the rootURL is null
+ * @deprecated use getRoot
*/
+ @Deprecated
public static VirtualFile getCachedFile(URL rootURL) throws IOException
{
- VFSCache cache = VFSCacheFactory.getInstance();
- VirtualFile file = cache.getFile(rootURL);
- return (file != null) ? file : getRoot(rootURL);
+ return getRoot(rootURL);
}
/**
@@ -269,8 +299,8 @@
@SuppressWarnings("deprecation")
public static VirtualFile getVirtualFile(URL rootURL, String name) throws IOException
{
- VFS vfs = getVFS(rootURL);
- return vfs.findChild(name);
+ VirtualFile root = getRoot(rootURL);
+ return root.findChild(name);
}
/**
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 2009-01-23 11:14:09 UTC (rev 83348)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java 2009-01-23 13:50:42 UTC (rev 83349)
@@ -102,7 +102,7 @@
@SuppressWarnings("deprecation")
protected static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
{
- VirtualFile file = VFS.getCachedFile(vfsurl);
+ VirtualFile file = VFS.getRoot(vfsurl);
return file.findChild(relativePath);
}
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2009-01-23 11:14:09 UTC (rev 83348)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2009-01-23 13:50:42 UTC (rev 83349)
@@ -73,7 +73,7 @@
{
configureCache(cache);
- VirtualFile root = VFS.getCachedFile(url);
+ VirtualFile root = VFS.getRoot(url);
VirtualFile file = root.findChild("/nested.jar/META-INF/empty.txt");
URL fileURL = file.toURL();
@@ -119,7 +119,7 @@
{
configureCache(cache);
- VirtualFile root = VFS.getCachedFile(url);
+ VirtualFile root = VFS.getRoot(url);
assertNotNull(root);
Iterable<VFSContext> iter = statistics.getCachedContexts();
More information about the jboss-cvs-commits
mailing list