[jboss-cvs] JBossAS SVN: r80461 - in projects/vfs/branches/Branch_2_0: src/main/java/org/jboss/virtual and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 4 05:22:38 EST 2008


Author: alesj
Date: 2008-11-04 05:22:38 -0500 (Tue, 04 Nov 2008)
New Revision: 80461

Added:
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/CachePolicyVFSCacheTest.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java
Removed:
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
Modified:
   projects/vfs/branches/Branch_2_0/pom.xml
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFS.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFSUtils.java
   projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
   projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
Log:
Port trunk changes to branch.

Modified: projects/vfs/branches/Branch_2_0/pom.xml
===================================================================
--- projects/vfs/branches/Branch_2_0/pom.xml	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/pom.xml	2008-11-04 10:22:38 UTC (rev 80461)
@@ -29,7 +29,7 @@
   </organization>
 
   <properties>
-    <version.jboss.common.core>2.2.8.GA</version.jboss.common.core>
+    <version.jboss.common.core>2.2.9.GA</version.jboss.common.core>
     <version.jboss.logging>2.0.5.GA</version.jboss.logging>
     <version.jboss.test>1.1.0.GA</version.jboss.test>
     <version.junit>4.4</version.junit>

Modified: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFS.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFS.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -32,6 +32,8 @@
 import org.jboss.virtual.spi.VFSContextFactory;
 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;
 
 /**
@@ -39,6 +41,7 @@
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @author Scott.Stark at jboss.org
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a> 
  * @version $Revision: 1.1 $
  */
 public class VFS
@@ -87,6 +90,7 @@
       if (factory == null)
          throw new IOException("No context factory for " + rootURI);
       VFSContext context = factory.getVFS(rootURI);
+      VFSCacheFactory.getInstance().putContext(context);
       return context.getVFS();
    }
 
@@ -96,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
    {
@@ -105,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
@@ -133,6 +155,7 @@
       if (factory == null)
          throw new IOException("No context factory for " + rootURL);
       VFSContext context = factory.getVFS(rootURL);
+      VFSCacheFactory.getInstance().putContext(context);
       return context.getVFS();
    }
 
@@ -151,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/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFSUtils.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFSUtils.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/VFSUtils.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -50,6 +50,7 @@
 import org.jboss.virtual.spi.LinkInfo;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
+import org.jboss.virtual.spi.cache.VFSCacheFactory;
 
 /**
  * VFS Utilities
@@ -106,6 +107,19 @@
    public static final String OPTIMIZE_FOR_MEMORY_KEY = "jboss.vfs.optimizeForMemory";
 
    /**
+    * Key used to determine VFS Cache impl
+    */
+   public static final String VFS_CACHE_KEY = "jboss.vfs.cache";
+
+   /**
+    * Stop cache.
+    */
+   public static void stopCache()
+   {
+      VFSCacheFactory.getInstance().stop();
+   }
+
+   /**
     * Get the paths string for a collection of virtual files
     *
     * @param paths the paths

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache)

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,256 +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.cache;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.jboss.logging.Logger;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.spi.cache.CacheStatistics;
-import org.jboss.virtual.spi.cache.VFSCache;
-
-/**
- * Abstract vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class AbstractVFSCache implements VFSCache, CacheStatistics
-{
-   protected Logger log = Logger.getLogger(getClass());
-   
-   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-   private long timestamp;
-
-   public long lastInsert()
-   {
-      return timestamp;
-   }
-
-   /**
-    * Is cache valid.
-    */
-   protected abstract void check();
-
-   public VirtualFile getFile(URI uri) throws IOException
-   {
-      check();
-
-      VFSContext context = findContext(uri);
-      if (context != null)
-      {
-         VirtualFileHandler root = context.getRoot();
-         String relativePath = getRelativePath(context, uri);
-         VirtualFileHandler child = root.getChild(relativePath);
-         return child.getVirtualFile();
-      }
-      return VFS.getRoot(uri);
-   }
-
-   /**
-    * Get relative path.
-    *
-    * @param context the vfs context
-    * @param uri the uri
-    * @return uri's relative path to context's root
-    */
-   protected String getRelativePath(VFSContext context, URI uri)
-   {
-      String uriPath = stripProtocol(uri);
-      String contextKey = getKey(context);
-      return uriPath.substring(contextKey.length());
-   }
-
-   public VirtualFile getFile(URL url) throws IOException
-   {
-      check();
-
-      try
-      {
-         return getFile(VFSUtils.toURI(url));
-      }
-      catch (URISyntaxException e)
-      {
-         IOException ioe = new IOException();
-         ioe.initCause(e);
-         throw ioe;
-      }
-   }
-
-   /**
-    * Strip protocol from url string.
-    *
-    * @param uri the uri
-    * @return uri's path string
-    */
-   protected static String stripProtocol(URI uri)
-   {
-      String path = uri.getPath();
-      if (path != null && path.length() > 0)
-      {
-         StringBuilder sb = new StringBuilder(path);
-
-         if (sb.charAt(0) != '/')
-            sb.insert(0, '/');
-         if (sb.charAt(sb.length() - 1) != '/')
-            sb.append('/');
-
-         path = sb.toString();
-      }
-      else
-      {
-         path = "/";
-      }
-
-      return path;
-   }
-
-   /**
-    * Get the cached context.
-    *
-    * @param path the path to match
-    * @return cached context or null if not found
-    */
-   protected abstract VFSContext getContext(String path);
-
-   /**
-    * Find cached context.
-    * This method must take read lock.
-    *
-    * @param uri the uri to match
-    * @return found context or null
-    */
-   protected abstract VFSContext findContext(URI uri);
-
-   /**
-    * Get path key.
-    *
-    * @param context the vfs context
-    * @return contex's root path w/o protocol
-    */
-   protected static String getKey(VFSContext context)
-   {
-      URI uri = context.getRootURI();
-      return stripProtocol(uri);
-   }
-
-   public void putContext(VFSContext context)
-   {
-      if (context == null)
-         throw new IllegalArgumentException("Null context");
-
-      check();
-
-      if (log.isTraceEnabled())
-      {
-         StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
-         log.trace("VFSContext: " + context + ", Stack-trace:\n" + Arrays.toString(stackTraceElements));
-      }
-
-      String path = getKey(context);
-      writeLock();
-      try
-      {
-         putContext(path, context);
-         timestamp = System.currentTimeMillis();
-      }
-      finally
-      {
-         writeUnlock();
-      }
-   }
-
-   /**
-    * Put vfs context and its path key into cache.
-    *
-    * @param path the context's path
-    * @param context the vfs context
-    */
-   protected abstract void putContext(String path, VFSContext context);
-
-   public void removeContext(VFSContext context)
-   {
-      if (context == null)
-         throw new IllegalArgumentException("Null context");
-
-      check();
-
-      String path = getKey(context);
-      writeLock();
-      try
-      {
-         removeContext(path, context);
-      }
-      finally
-      {
-         writeUnlock();
-      }
-   }
-
-   /**
-    * Remove vfs context and its path key from cache.
-    *
-    * @param path the context's path
-    * @param context the vfs context
-    */
-   protected abstract void removeContext(String path, VFSContext context);
-
-   /**
-    * Read lock.
-    */
-   protected void readLock()
-   {
-      lock.readLock().lock();
-   }
-
-   /**
-    * Read unlock.
-    */
-   protected void readUnlock()
-   {
-      lock.readLock().unlock();
-   }
-
-   /**
-    * Write lock.
-    */
-   protected void writeLock()
-   {
-      lock.writeLock().lock();
-   }
-
-   /**
-    * Write unlock.
-    */
-   protected void writeUnlock()
-   {
-      lock.writeLock().unlock();
-   }
-}

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,256 @@
+/*
+* 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.cache;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
+import org.jboss.virtual.spi.cache.CacheStatistics;
+import org.jboss.virtual.spi.cache.VFSCache;
+
+/**
+ * Abstract vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractVFSCache implements VFSCache, CacheStatistics
+{
+   protected Logger log = Logger.getLogger(getClass());
+   
+   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+   private long timestamp;
+
+   public long lastInsert()
+   {
+      return timestamp;
+   }
+
+   /**
+    * Is cache valid.
+    */
+   protected abstract void check();
+
+   public VirtualFile getFile(URI uri) throws IOException
+   {
+      check();
+
+      VFSContext context = findContext(uri);
+      if (context != null)
+      {
+         VirtualFileHandler root = context.getRoot();
+         String relativePath = getRelativePath(context, uri);
+         VirtualFileHandler child = root.getChild(relativePath);
+         return child.getVirtualFile();
+      }
+      return VFS.getRoot(uri);
+   }
+
+   /**
+    * Get relative path.
+    *
+    * @param context the vfs context
+    * @param uri the uri
+    * @return uri's relative path to context's root
+    */
+   protected String getRelativePath(VFSContext context, URI uri)
+   {
+      String uriPath = stripProtocol(uri);
+      String contextKey = getKey(context);
+      return uriPath.substring(contextKey.length());
+   }
+
+   public VirtualFile getFile(URL url) throws IOException
+   {
+      check();
+
+      try
+      {
+         return getFile(VFSUtils.toURI(url));
+      }
+      catch (URISyntaxException e)
+      {
+         IOException ioe = new IOException();
+         ioe.initCause(e);
+         throw ioe;
+      }
+   }
+
+   /**
+    * Strip protocol from url string.
+    *
+    * @param uri the uri
+    * @return uri's path string
+    */
+   protected static String stripProtocol(URI uri)
+   {
+      String path = uri.getPath();
+      if (path != null && path.length() > 0)
+      {
+         StringBuilder sb = new StringBuilder(path);
+
+         if (sb.charAt(0) != '/')
+            sb.insert(0, '/');
+         if (sb.charAt(sb.length() - 1) != '/')
+            sb.append('/');
+
+         path = sb.toString();
+      }
+      else
+      {
+         path = "/";
+      }
+
+      return path;
+   }
+
+   /**
+    * Get the cached context.
+    *
+    * @param path the path to match
+    * @return cached context or null if not found
+    */
+   protected abstract VFSContext getContext(String path);
+
+   /**
+    * Find cached context.
+    * This method must take read lock.
+    *
+    * @param uri the uri to match
+    * @return found context or null
+    */
+   protected abstract VFSContext findContext(URI uri);
+
+   /**
+    * Get path key.
+    *
+    * @param context the vfs context
+    * @return contex's root path w/o protocol
+    */
+   protected static String getKey(VFSContext context)
+   {
+      URI uri = context.getRootURI();
+      return stripProtocol(uri);
+   }
+
+   public void putContext(VFSContext context)
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null context");
+
+      check();
+
+      if (log.isTraceEnabled())
+      {
+         StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+         log.trace("VFSContext: " + context + ", Stack-trace:\n" + Arrays.toString(stackTraceElements));
+      }
+
+      String path = getKey(context);
+      writeLock();
+      try
+      {
+         putContext(path, context);
+         timestamp = System.currentTimeMillis();
+      }
+      finally
+      {
+         writeUnlock();
+      }
+   }
+
+   /**
+    * Put vfs context and its path key into cache.
+    *
+    * @param path the context's path
+    * @param context the vfs context
+    */
+   protected abstract void putContext(String path, VFSContext context);
+
+   public void removeContext(VFSContext context)
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null context");
+
+      check();
+
+      String path = getKey(context);
+      writeLock();
+      try
+      {
+         removeContext(path, context);
+      }
+      finally
+      {
+         writeUnlock();
+      }
+   }
+
+   /**
+    * Remove vfs context and its path key from cache.
+    *
+    * @param path the context's path
+    * @param context the vfs context
+    */
+   protected abstract void removeContext(String path, VFSContext context);
+
+   /**
+    * Read lock.
+    */
+   protected void readLock()
+   {
+      lock.readLock().lock();
+   }
+
+   /**
+    * Read unlock.
+    */
+   protected void readUnlock()
+   {
+      lock.readLock().unlock();
+   }
+
+   /**
+    * Write lock.
+    */
+   protected void writeLock()
+   {
+      lock.writeLock().lock();
+   }
+
+   /**
+    * Write unlock.
+    */
+   protected void writeUnlock()
+   {
+      lock.writeLock().unlock();
+   }
+}

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,146 +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.cache;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collections;
-
-import org.jboss.util.CachePolicy;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class CachePolicyVFSCache extends PathMatchingVFSCache
-{
-   private CachePolicy policy;
-   private boolean started;
-
-   public Iterable<VFSContext> getCachedContexts()
-   {
-      // cannot pull all cache entries from policy
-      return Collections.emptySet();
-   }
-
-   public int size()
-   {
-      return policy != null ? policy.size() : -1;
-   }
-
-   protected void check()
-   {
-      if (policy == null)
-         throw new IllegalArgumentException("Cache needs to be started first.");
-   }
-
-   public void start() throws Exception
-   {
-      if (started == false)
-      {
-         policy = createCachePolicy();
-
-         policy.create();
-         policy.start();
-
-         started = true;
-      }
-   }
-
-   public void stop()
-   {
-      if (started)
-      {
-         policy.stop();
-         policy.destroy();
-      }
-      policy = null;
-   }
-
-   public void flush()
-   {
-      if (policy != null)
-         policy.flush();
-   }
-
-   protected VFSContext getContext(String path)
-   {
-      return VFSContext.class.cast(policy.get(path));
-   }
-
-   protected void putContext(String path, VFSContext context)
-   {
-      Object result = policy.peek(path);
-      if (result == null)
-         policy.insert(path, context);
-   }
-
-   public void removeContext(String key, VFSContext context)
-   {
-      policy.remove(key);
-   }
-
-   /**
-    * Create cache policy.
-    *
-    * @return the cache policy
-    */
-   protected abstract CachePolicy createCachePolicy();
-
-   /**
-    * Read system property.
-    *
-    * @param key the property key
-    * @param defaultValue the default value
-    * @return system property or default value
-    */
-   protected static String readSystemProperty(final String key, final String defaultValue)
-   {
-      SecurityManager sm = System.getSecurityManager();
-      if (sm == null)
-         return System.getProperty(key, defaultValue);
-      else
-         return AccessController.doPrivileged(new PrivilegedAction<String>()
-         {
-            public String run()
-            {
-               return System.getProperty(key, defaultValue);
-            }
-         });
-   }
-
-   /**
-    * Parse integer.
-    *
-    * @param value the string int value
-    * @return integer value of null
-    */
-   protected static Integer parseInteger(String value)
-   {
-      if (value == null)
-         return null;
-
-      return Integer.parseInt(value);
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,146 @@
+/*
+* 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.cache;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CachePolicyVFSCache extends PathMatchingVFSCache
+{
+   private CachePolicy policy;
+   private boolean started;
+
+   public Iterable<VFSContext> getCachedContexts()
+   {
+      // cannot pull all cache entries from policy
+      return Collections.emptySet();
+   }
+
+   public int size()
+   {
+      return policy != null ? policy.size() : -1;
+   }
+
+   protected void check()
+   {
+      if (policy == null)
+         throw new IllegalArgumentException("Cache needs to be started first.");
+   }
+
+   public void start() throws Exception
+   {
+      if (started == false)
+      {
+         policy = createCachePolicy();
+
+         policy.create();
+         policy.start();
+
+         started = true;
+      }
+   }
+
+   public void stop()
+   {
+      if (started)
+      {
+         policy.stop();
+         policy.destroy();
+      }
+      policy = null;
+   }
+
+   public void flush()
+   {
+      if (policy != null)
+         policy.flush();
+   }
+
+   protected VFSContext getContext(String path)
+   {
+      return VFSContext.class.cast(policy.get(path));
+   }
+
+   protected void putContext(String path, VFSContext context)
+   {
+      Object result = policy.peek(path);
+      if (result == null)
+         policy.insert(path, context);
+   }
+
+   public void removeContext(String key, VFSContext context)
+   {
+      policy.remove(key);
+   }
+
+   /**
+    * Create cache policy.
+    *
+    * @return the cache policy
+    */
+   protected abstract CachePolicy createCachePolicy();
+
+   /**
+    * Read system property.
+    *
+    * @param key the property key
+    * @param defaultValue the default value
+    * @return system property or default value
+    */
+   protected static String readSystemProperty(final String key, final String defaultValue)
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+         return System.getProperty(key, defaultValue);
+      else
+         return AccessController.doPrivileged(new PrivilegedAction<String>()
+         {
+            public String run()
+            {
+               return System.getProperty(key, defaultValue);
+            }
+         });
+   }
+
+   /**
+    * Parse integer.
+    *
+    * @param value the string int value
+    * @return integer value of null
+    */
+   protected static Integer parseInteger(String value)
+   {
+      if (value == null)
+         return null;
+
+      return Integer.parseInt(value);
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,64 +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.cache;
-
-import java.net.URI;
-
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Iterable vfs cache.
- *
- * Knows how to iterate over cache keys,
- * matching them to uri's path.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class IterableVFSCache extends AbstractVFSCache
-{
-   /**
-    * Get cache keys.
-    *
-    * @return the cache keys
-    */
-   protected abstract Iterable<String> getKeys();
-
-   protected VFSContext findContext(URI uri)
-   {
-      String uriString = stripProtocol(uri);
-      Iterable<String> keys = getKeys();
-      readLock();
-      try
-      {
-         for (String key : keys)
-         {
-            if (uriString.startsWith(key))
-               return getContext(key);
-         }
-      }
-      finally
-      {
-         readUnlock();
-      }
-      return null;
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/IterableVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,64 @@
+/*
+* 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.cache;
+
+import java.net.URI;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Iterable vfs cache.
+ *
+ * Knows how to iterate over cache keys,
+ * matching them to uri's path.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class IterableVFSCache extends AbstractVFSCache
+{
+   /**
+    * Get cache keys.
+    *
+    * @return the cache keys
+    */
+   protected abstract Iterable<String> getKeys();
+
+   protected VFSContext findContext(URI uri)
+   {
+      String uriString = stripProtocol(uri);
+      Iterable<String> keys = getKeys();
+      readLock();
+      try
+      {
+         for (String key : keys)
+         {
+            if (uriString.startsWith(key))
+               return getContext(key);
+         }
+      }
+      finally
+      {
+         readUnlock();
+      }
+      return null;
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,82 +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.cache;
-
-import org.jboss.util.CachePolicy;
-import org.jboss.util.LRUCachePolicy;
-import org.jboss.virtual.VFSUtils;
-
-/**
- * LRU cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class LRUVFSCache extends CachePolicyVFSCache
-{
-   private Integer min;
-   private Integer max;
-
-   public LRUVFSCache()
-   {
-   }
-
-   public LRUVFSCache(Integer min, Integer max)
-   {
-      this.min = min;
-      this.max = max;
-   }
-
-   protected CachePolicy createCachePolicy()
-   {
-      if (min == null)
-         min = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", null));
-      if (max == null)
-         max = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", null));
-
-      if (min == null || max == null)
-         throw new IllegalArgumentException("Missing min (" + min + ") or max (" + max + ").");
-
-      log.debug("Creating LRU cache policy, min: " + min + ", max: " + max);
-
-      return new LRUCachePolicy(min, max);
-   }
-
-   /**
-    * Set min.
-    *
-    * @param min the min
-    */
-   public void setMin(Integer min)
-   {
-      this.min = min;
-   }
-
-   /**
-    * set max.
-    *
-    * @param max the max
-    */
-   public void setMax(Integer max)
-   {
-      this.max = max;
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,82 @@
+/*
+* 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.cache;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.util.LRUCachePolicy;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * LRU cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LRUVFSCache extends CachePolicyVFSCache
+{
+   private Integer min;
+   private Integer max;
+
+   public LRUVFSCache()
+   {
+   }
+
+   public LRUVFSCache(Integer min, Integer max)
+   {
+      this.min = min;
+      this.max = max;
+   }
+
+   protected CachePolicy createCachePolicy()
+   {
+      if (min == null)
+         min = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", null));
+      if (max == null)
+         max = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", null));
+
+      if (min == null || max == null)
+         throw new IllegalArgumentException("Missing min (" + min + ") or max (" + max + ").");
+
+      log.debug("Creating LRU cache policy, min: " + min + ", max: " + max);
+
+      return new LRUCachePolicy(min, max);
+   }
+
+   /**
+    * Set min.
+    *
+    * @param min the min
+    */
+   public void setMin(Integer min)
+   {
+      this.min = min;
+   }
+
+   /**
+    * set max.
+    *
+    * @param max the max
+    */
+   public void setMax(Integer max)
+   {
+      this.max = max;
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,101 +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.cache;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Map vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class MapVFSCache extends IterableVFSCache
-{
-   private Map<String, VFSContext> cache;
-
-   public Iterable<VFSContext> getCachedContexts()
-   {
-      if (cache == null)
-         return Collections.emptySet();
-      else
-         return cache.values(); 
-   }
-
-   public int size()
-   {
-      return cache != null ? cache.size() : -1;
-   }
-
-   protected void check()
-   {
-      if (cache == null)
-         throw new IllegalArgumentException("Cache needs to be started first.");
-   }
-
-   protected Iterable<String> getKeys()
-   {
-      return cache.keySet();
-   }
-
-   protected VFSContext getContext(String path)
-   {
-      return cache.get(path);
-   }
-
-   protected void putContext(String path, VFSContext context)
-   {
-      cache.put(path, context);
-   }
-
-   protected void removeContext(String path, VFSContext context)
-   {
-      cache.remove(path);
-   }
-
-   /**
-    * Create cache map.
-    *
-    * @return cache map
-    */
-   protected abstract Map<String, VFSContext> createMap();
-
-   public void start() throws Exception
-   {
-      if (cache == null)
-         cache = createMap();
-   }
-
-   public void stop()
-   {
-      flush();
-      cache = null;
-   }
-
-   public void flush()
-   {
-      if (cache != null)
-         cache.clear();
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,101 @@
+/*
+* 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.cache;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Map vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class MapVFSCache extends IterableVFSCache
+{
+   private Map<String, VFSContext> cache;
+
+   public Iterable<VFSContext> getCachedContexts()
+   {
+      if (cache == null)
+         return Collections.emptySet();
+      else
+         return cache.values(); 
+   }
+
+   public int size()
+   {
+      return cache != null ? cache.size() : -1;
+   }
+
+   protected void check()
+   {
+      if (cache == null)
+         throw new IllegalArgumentException("Cache needs to be started first.");
+   }
+
+   protected Iterable<String> getKeys()
+   {
+      return cache.keySet();
+   }
+
+   protected VFSContext getContext(String path)
+   {
+      return cache.get(path);
+   }
+
+   protected void putContext(String path, VFSContext context)
+   {
+      cache.put(path, context);
+   }
+
+   protected void removeContext(String path, VFSContext context)
+   {
+      cache.remove(path);
+   }
+
+   /**
+    * Create cache map.
+    *
+    * @return cache map
+    */
+   protected abstract Map<String, VFSContext> createMap();
+
+   public void start() throws Exception
+   {
+      if (cache == null)
+         cache = createMap();
+   }
+
+   public void stop()
+   {
+      flush();
+      cache = null;
+   }
+
+   public void flush()
+   {
+      if (cache != null)
+         cache.clear();
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,65 +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.cache;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
-
-/**
- * Iterable vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class PathMatchingVFSCache extends AbstractVFSCache
-{
-   /**
-    * Match the uri's path with cached contexts path.
-    *
-    * @param uri the uri to match
-    * @return found context or null
-    */
-   protected VFSContext findContext(URI uri)
-   {
-      String uriString = stripProtocol(uri);
-      List<String> tokens = PathTokenizer.getTokens(uriString);
-      StringBuilder sb = new StringBuilder("/");
-      readLock();
-      try
-      {
-         for (String token : tokens)
-         {
-            sb.append(token).append("/");
-            VFSContext context = getContext(sb.toString());
-            if (context != null)
-               return context;
-         }
-      }
-      finally
-      {
-         readUnlock();
-      }
-      return null;
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PathMatchingVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,65 @@
+/*
+* 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.cache;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
+
+/**
+ * Iterable vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class PathMatchingVFSCache extends AbstractVFSCache
+{
+   /**
+    * Match the uri's path with cached contexts path.
+    *
+    * @param uri the uri to match
+    * @return found context or null
+    */
+   protected VFSContext findContext(URI uri)
+   {
+      String uriString = stripProtocol(uri);
+      List<String> tokens = PathTokenizer.getTokens(uriString);
+      StringBuilder sb = new StringBuilder("/");
+      readLock();
+      try
+      {
+         for (String token : tokens)
+         {
+            sb.append(token).append("/");
+            VFSContext context = getContext(sb.toString());
+            if (context != null)
+               return context;
+         }
+      }
+      finally
+      {
+         readUnlock();
+      }
+      return null;
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,105 +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.cache;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.virtual.VFS;
-
-/**
- * Initialize vfs contexts - performance improvements.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class PreInitializeVFSContexts
-{
-   private Logger log = Logger.getLogger(PreInitializeVFSContexts.class);
-   private List<URL> initializedVFSContexts;
-   private boolean holdReference;
-   private List<VFS> references;
-
-   /**
-    * Start initializer.
-    *
-    * @throws Exception for any exception
-    */
-   public void start() throws Exception
-   {
-      if (initializedVFSContexts != null && initializedVFSContexts.isEmpty() == false)
-      {
-         if (holdReference)
-            references = new ArrayList<VFS>();
-
-         for (URL url : initializedVFSContexts)
-         {
-            VFS vfs = VFS.getVFS(url);
-            log.debug("Initialized Virtual File: " + vfs.getRoot());
-            if (holdReference)
-            {
-               references.add(vfs);
-            }
-         }
-      }
-   }
-
-   /**
-    * Clear possible references.
-    */
-   public void stop()
-   {
-      if (references != null)
-         references.clear();
-   }
-
-   /**
-    * Get VFS references.
-    *
-    * @return the VFS references
-    */
-   public List<VFS> getReferences()
-   {
-      return references;
-   }
-
-   /**
-    * Set URLs that need to be initialized before anything else.
-    *
-    * @param initializedVFSContexts the URLs to be initialized
-    */
-   public void setInitializedVFSContexts(List<URL> initializedVFSContexts)
-   {
-      this.initializedVFSContexts = initializedVFSContexts;
-   }
-
-   /**
-    * Should we hold the reference to initialized VFSs.
-    *
-    * @param holdReference the hold reference flag
-    */
-   public void setHoldReference(boolean holdReference)
-   {
-      this.holdReference = holdReference;
-   }
-}

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,105 @@
+/*
+* 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.cache;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+
+/**
+ * Initialize vfs contexts - performance improvements.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PreInitializeVFSContexts
+{
+   private Logger log = Logger.getLogger(PreInitializeVFSContexts.class);
+   private List<URL> initializedVFSContexts;
+   private boolean holdReference;
+   private List<VFS> references;
+
+   /**
+    * Start initializer.
+    *
+    * @throws Exception for any exception
+    */
+   public void start() throws Exception
+   {
+      if (initializedVFSContexts != null && initializedVFSContexts.isEmpty() == false)
+      {
+         if (holdReference)
+            references = new ArrayList<VFS>();
+
+         for (URL url : initializedVFSContexts)
+         {
+            VFS vfs = VFS.getVFS(url);
+            log.debug("Initialized Virtual File: " + vfs.getRoot());
+            if (holdReference)
+            {
+               references.add(vfs);
+            }
+         }
+      }
+   }
+
+   /**
+    * Clear possible references.
+    */
+   public void stop()
+   {
+      if (references != null)
+         references.clear();
+   }
+
+   /**
+    * Get VFS references.
+    *
+    * @return the VFS references
+    */
+   public List<VFS> getReferences()
+   {
+      return references;
+   }
+
+   /**
+    * Set URLs that need to be initialized before anything else.
+    *
+    * @param initializedVFSContexts the URLs to be initialized
+    */
+   public void setInitializedVFSContexts(List<URL> initializedVFSContexts)
+   {
+      this.initializedVFSContexts = initializedVFSContexts;
+   }
+
+   /**
+    * Should we hold the reference to initialized VFSs.
+    *
+    * @param holdReference the hold reference flag
+    */
+   public void setHoldReference(boolean holdReference)
+   {
+      this.holdReference = holdReference;
+   }
+}

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,41 +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.cache;
-
-import java.util.Map;
-
-import org.jboss.util.collection.SoftValueTreeMap;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * SoftRef vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class SoftRefVFSCache extends MapVFSCache
-{
-   @SuppressWarnings("unchecked")
-   protected Map<String, VFSContext> createMap()
-   {
-      return new SoftValueTreeMap();
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/SoftRefVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,41 @@
+/*
+* 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.cache;
+
+import java.util.Map;
+
+import org.jboss.util.collection.SoftValueTreeMap;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * SoftRef vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SoftRefVFSCache extends MapVFSCache
+{
+   @SuppressWarnings("unchecked")
+   protected Map<String, VFSContext> createMap()
+   {
+      return new SoftValueTreeMap();
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,103 +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.cache;
-
-import org.jboss.util.CachePolicy;
-import org.jboss.util.TimedCachePolicy;
-import org.jboss.virtual.VFSUtils;
-
-/**
- * Timed cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class TimedVFSCache extends CachePolicyVFSCache
-{
-   private Integer defaultLifetime;
-   private Boolean threadSafe;
-   private Integer resolution;
-
-   public TimedVFSCache()
-   {
-   }
-
-   public TimedVFSCache(Integer defaultLifetime)
-   {
-      this(defaultLifetime, null, null);
-   }
-
-   public TimedVFSCache(Integer defaultLifetime, Boolean threadSafe, Integer resolution)
-   {
-      this.defaultLifetime = defaultLifetime;
-      this.threadSafe = threadSafe;
-      this.resolution = resolution;
-   }
-
-   protected CachePolicy createCachePolicy()
-   {
-      if (defaultLifetime == null)
-         defaultLifetime = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", null));
-      if (threadSafe == null)
-         threadSafe = Boolean.valueOf(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.threadSafe", Boolean.TRUE.toString()));
-      if (resolution == null)
-         resolution = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.resolution", null));
-
-      log.debug("Creating timed cache policy, lifetime: " + defaultLifetime + ", threadSafe: " + threadSafe + ", resolution: " + resolution);
-
-      if (defaultLifetime == null)
-         return new TimedCachePolicy();
-      else if (resolution != null)
-         return new TimedCachePolicy(defaultLifetime, threadSafe, resolution);
-      else
-         return new TimedCachePolicy(defaultLifetime);
-   }
-
-   /**
-    * Set default lifetime.
-    *
-    * @param defaultLifetime the default lifetime
-    */
-   public void setDefaultLifetime(Integer defaultLifetime)
-   {
-      this.defaultLifetime = defaultLifetime;
-   }
-
-   /**
-    * Set threadsafe flag.
-    *
-    * @param threadSafe the threadsafe flag
-    */
-   public void setThreadSafe(Boolean threadSafe)
-   {
-      this.threadSafe = threadSafe;
-   }
-
-   /**
-    * The resollution.
-    *
-    * @param resolution the resolution
-    */
-   public void setResolution(Integer resolution)
-   {
-      this.resolution = resolution;
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,103 @@
+/*
+* 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.cache;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.util.TimedCachePolicy;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * Timed cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TimedVFSCache extends CachePolicyVFSCache
+{
+   private Integer defaultLifetime;
+   private Boolean threadSafe;
+   private Integer resolution;
+
+   public TimedVFSCache()
+   {
+   }
+
+   public TimedVFSCache(Integer defaultLifetime)
+   {
+      this(defaultLifetime, null, null);
+   }
+
+   public TimedVFSCache(Integer defaultLifetime, Boolean threadSafe, Integer resolution)
+   {
+      this.defaultLifetime = defaultLifetime;
+      this.threadSafe = threadSafe;
+      this.resolution = resolution;
+   }
+
+   protected CachePolicy createCachePolicy()
+   {
+      if (defaultLifetime == null)
+         defaultLifetime = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", null));
+      if (threadSafe == null)
+         threadSafe = Boolean.valueOf(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.threadSafe", Boolean.TRUE.toString()));
+      if (resolution == null)
+         resolution = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.resolution", null));
+
+      log.debug("Creating timed cache policy, lifetime: " + defaultLifetime + ", threadSafe: " + threadSafe + ", resolution: " + resolution);
+
+      if (defaultLifetime == null)
+         return new TimedCachePolicy();
+      else if (resolution != null)
+         return new TimedCachePolicy(defaultLifetime, threadSafe, resolution);
+      else
+         return new TimedCachePolicy(defaultLifetime);
+   }
+
+   /**
+    * Set default lifetime.
+    *
+    * @param defaultLifetime the default lifetime
+    */
+   public void setDefaultLifetime(Integer defaultLifetime)
+   {
+      this.defaultLifetime = defaultLifetime;
+   }
+
+   /**
+    * Set threadsafe flag.
+    *
+    * @param threadSafe the threadsafe flag
+    */
+   public void setThreadSafe(Boolean threadSafe)
+   {
+      this.threadSafe = threadSafe;
+   }
+
+   /**
+    * The resollution.
+    *
+    * @param resolution the resolution
+    */
+   public void setResolution(Integer resolution)
+   {
+      this.resolution = resolution;
+   }
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,41 +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.cache;
-
-import java.util.Map;
-
-import org.jboss.util.collection.WeakValueTreeMap;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * WeakRef vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class WeakRefVFSCache extends MapVFSCache
-{
-   @SuppressWarnings("unchecked")
-   protected Map<String, VFSContext> createMap()
-   {
-      return new WeakValueTreeMap();
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/WeakRefVFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,41 @@
+/*
+* 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.cache;
+
+import java.util.Map;
+
+import org.jboss.util.collection.WeakValueTreeMap;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * WeakRef vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WeakRefVFSCache extends MapVFSCache
+{
+   @SuppressWarnings("unchecked")
+   protected Map<String, VFSContext> createMap()
+   {
+      return new WeakValueTreeMap();
+   }
+}
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -25,10 +25,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.Collections;
-import java.util.Map;
 
-import org.jboss.util.collection.SoftValueHashMap;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 
@@ -41,9 +38,6 @@
  */
 public class VirtualFileURLConnection extends URLConnection
 {
-   @SuppressWarnings("unchecked")
-   public static Map<URL, VFS> urlCache = Collections.<URL, VFS>synchronizedMap(new SoftValueHashMap());
-
    protected VirtualFile file;
    protected URL vfsurl;
    protected String relativePath;
@@ -102,31 +96,14 @@
    @SuppressWarnings("deprecation")
    protected 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().hasBeenModified())
-         {
-            vfs = VFS.getVFS(vfsurl);
-            urlCache.put(vfsurl, vfs);
-         }
-      }
-      return vfs.findChild(relativePath);
+      return resolveVirtualFile(vfsurl, relativePath);
    }
 
    @SuppressWarnings("deprecation")
    protected static VirtualFile resolveVirtualFile(URL vfsurl, String relativePath) throws IOException
    {
-      VFS vfs = VFS.getVFS(vfsurl);
-      return vfs.findChild(relativePath);
+      VirtualFile file = VFS.getCachedFile(vfsurl);
+      return file.findChild(relativePath);
    }
 
    /**
@@ -138,16 +115,8 @@
    protected synchronized VirtualFile getVirtualFile() throws IOException
    {
       if (file == null)
-      {
-         if (getUseCaches())
-         {
-            file = resolveCachedVirtualFile(vfsurl, relativePath);
-         }
-         else
-         {
-            file = resolveVirtualFile(vfsurl, relativePath);
-         }
-      }
+         file = resolveVirtualFile(vfsurl, relativePath);
+      
       return file;
    }
 }

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache)

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,53 +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.spi.cache;
-
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Simple vfs cache statistics
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface CacheStatistics
-{
-   /**
-    * Get cached contexts.
-    *
-    * @return the cached contexts
-    */
-   Iterable<VFSContext> getCachedContexts();
-
-   /**
-    * Get cache size.
-    *
-    * @return the cache size
-    */
-   int size();
-
-   /**
-    * Get last insert timestamp.
-    *
-    * @return the last insert timestamp
-    */
-   long lastInsert();
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,53 @@
+/*
+* 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.spi.cache;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Simple vfs cache statistics
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface CacheStatistics
+{
+   /**
+    * Get cached contexts.
+    *
+    * @return the cached contexts
+    */
+   Iterable<VFSContext> getCachedContexts();
+
+   /**
+    * Get cache size.
+    *
+    * @return the cache size
+    */
+   int size();
+
+   /**
+    * Get last insert timestamp.
+    *
+    * @return the last insert timestamp
+    */
+   long lastInsert();
+}
\ No newline at end of file

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,86 +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.spi.cache;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Simple vfs cache interface.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface VFSCache
-{
-   /**
-    * Get the file.
-    *
-    * @param uri the file's uri
-    * @return virtual file instance
-    * @throws IOException for any error
-    */
-   VirtualFile getFile(URI uri) throws IOException;
-
-   /**
-    * Get the file.
-    *
-    * @param url the file's url
-    * @return virtual file instance
-    * @throws IOException for any error
-    */
-   VirtualFile getFile(URL url) throws IOException;
-
-   /**
-    * Put vfs context to cache.
-    *
-    * @param context the vfs context
-    */
-   void putContext(VFSContext context);
-
-   /**
-    * Remove vfs context from cache.
-    *
-    * @param context the vfs context
-    */
-   void removeContext(VFSContext context);
-
-   /**
-    * Start the cache.
-    *
-    * @throws Exception for any error
-    */
-   void start() throws Exception;
-
-   /**
-    * Stop the cache.
-    */
-   void stop();
-
-   /**
-    * Flush the cache.
-    */
-   void flush();
-}

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,86 @@
+/*
+* 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.spi.cache;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Simple vfs cache interface.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface VFSCache
+{
+   /**
+    * Get the file.
+    *
+    * @param uri the file's uri
+    * @return virtual file instance
+    * @throws IOException for any error
+    */
+   VirtualFile getFile(URI uri) throws IOException;
+
+   /**
+    * Get the file.
+    *
+    * @param url the file's url
+    * @return virtual file instance
+    * @throws IOException for any error
+    */
+   VirtualFile getFile(URL url) throws IOException;
+
+   /**
+    * Put vfs context to cache.
+    *
+    * @param context the vfs context
+    */
+   void putContext(VFSContext context);
+
+   /**
+    * Remove vfs context from cache.
+    *
+    * @param context the vfs context
+    */
+   void removeContext(VFSContext context);
+
+   /**
+    * Start the cache.
+    *
+    * @throws Exception for any error
+    */
+   void start() throws Exception;
+
+   /**
+    * Stop the cache.
+    */
+   void stop();
+
+   /**
+    * Flush the cache.
+    */
+   void flush();
+}

Deleted: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1,148 +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.spi.cache;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.jboss.logging.Logger;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Simple vfs cache factory.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class VFSCacheFactory
-{
-   private static final Object lock = new Object();
-   private static Logger log = Logger.getLogger(VFSCacheFactory.class);
-
-   private static VFSCache instance;
-
-   private VFSCacheFactory()
-   {
-   }
-
-   /**
-    * Get VFS cache instance.
-    *
-    * @return the vfs cache instance
-    */
-   public static VFSCache getInstance()
-   {
-      if (instance == null)
-      {
-         synchronized (lock)
-         {
-            if (instance == null)
-               instance = AccessController.doPrivileged(new VFSCacheCreatorAction());
-         }
-      }
-
-      return instance;
-   }
-
-   /**
-    * Set instance.
-    *
-    * This should be used with care.
-    * Better to leave it to getInstance method creation.
-    *
-    * @param cache cache instance to set
-    */
-   public static void setInstance(VFSCache cache)
-   {
-      if (cache != null && instance != null && instance instanceof NoopVFSCache == false)
-         throw new IllegalArgumentException("Instance already set!");
-
-      instance = cache;
-   }
-
-   private static class VFSCacheCreatorAction implements PrivilegedAction<VFSCache>
-   {
-      public VFSCache run()
-      {
-         try
-         {
-            String className = System.getProperty(VFSUtils.VFS_CACHE_KEY);
-            if (className != null)
-            {
-               log.info("Initializing VFSCache [" + className + "] ...");
-               ClassLoader cl = VFSCacheFactory.class.getClassLoader();
-               Class<?> clazz = cl.loadClass(className);
-               VFSCache cache = VFSCache.class.cast(clazz.newInstance());
-               cache.start(); // start here, so we fall back to default no-op in case start fails
-               return cache;
-            }
-         }
-         catch (Throwable t)
-         {
-            log.warn("Exception instantiating VFS cache: " + t);
-         }
-         return new NoopVFSCache();
-      }
-   }
-
-   /**
-    * Noop cache.
-    * Doesn't do any caching.
-    */
-   private static class NoopVFSCache implements VFSCache
-   {
-      public VirtualFile getFile(URI uri) throws IOException
-      {
-         return VFS.getRoot(uri);
-      }
-
-      public VirtualFile getFile(URL url) throws IOException
-      {
-         return VFS.getRoot(url);
-      }
-
-      public void putContext(VFSContext context)
-      {
-      }
-
-      public void removeContext(VFSContext context)
-      {
-      }
-
-      public void start() throws Exception
-      {
-      }
-
-      public void stop()
-      {
-      }
-
-      public void flush()
-      {
-      }
-   }
-}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java (from rev 80460, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,148 @@
+/*
+* 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.spi.cache;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Simple vfs cache factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VFSCacheFactory
+{
+   private static final Object lock = new Object();
+   private static Logger log = Logger.getLogger(VFSCacheFactory.class);
+
+   private static VFSCache instance;
+
+   private VFSCacheFactory()
+   {
+   }
+
+   /**
+    * Get VFS cache instance.
+    *
+    * @return the vfs cache instance
+    */
+   public static VFSCache getInstance()
+   {
+      if (instance == null)
+      {
+         synchronized (lock)
+         {
+            if (instance == null)
+               instance = AccessController.doPrivileged(new VFSCacheCreatorAction());
+         }
+      }
+
+      return instance;
+   }
+
+   /**
+    * Set instance.
+    *
+    * This should be used with care.
+    * Better to leave it to getInstance method creation.
+    *
+    * @param cache cache instance to set
+    */
+   public static void setInstance(VFSCache cache)
+   {
+      if (cache != null && instance != null && instance instanceof NoopVFSCache == false)
+         throw new IllegalArgumentException("Instance already set!");
+
+      instance = cache;
+   }
+
+   private static class VFSCacheCreatorAction implements PrivilegedAction<VFSCache>
+   {
+      public VFSCache run()
+      {
+         try
+         {
+            String className = System.getProperty(VFSUtils.VFS_CACHE_KEY);
+            if (className != null)
+            {
+               log.info("Initializing VFSCache [" + className + "] ...");
+               ClassLoader cl = VFSCacheFactory.class.getClassLoader();
+               Class<?> clazz = cl.loadClass(className);
+               VFSCache cache = VFSCache.class.cast(clazz.newInstance());
+               cache.start(); // start here, so we fall back to default no-op in case start fails
+               return cache;
+            }
+         }
+         catch (Throwable t)
+         {
+            log.warn("Exception instantiating VFS cache: " + t);
+         }
+         return new NoopVFSCache();
+      }
+   }
+
+   /**
+    * Noop cache.
+    * Doesn't do any caching.
+    */
+   private static class NoopVFSCache implements VFSCache
+   {
+      public VirtualFile getFile(URI uri) throws IOException
+      {
+         return VFS.getRoot(uri);
+      }
+
+      public VirtualFile getFile(URL url) throws IOException
+      {
+         return VFS.getRoot(url);
+      }
+
+      public void putContext(VFSContext context)
+      {
+      }
+
+      public void removeContext(VFSContext context)
+      {
+      }
+
+      public void start() throws Exception
+      {
+      }
+
+      public void stop()
+      {
+      }
+
+      public void flush()
+      {
+      }
+   }
+}
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -69,6 +69,18 @@
    {
       super.setUp();
 
+/*
+      // LRU
+      System.setProperty(VFSUtils.VFS_CACHE_KEY, LRUVFSCache.class.getName());
+      System.setProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", "2");
+      System.setProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", "100");
+*/
+/*
+      // Timed
+      System.setProperty(VFSUtils.VFS_CACHE_KEY, TimedVFSCache.class.getName());
+      System.setProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", "60");
+*/
+
       VFSContextFactoryLocator.registerFactory(fileFactory);
       VFSContextFactoryLocator.registerFactory(jarFactory);
 

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/CachePolicyVFSCacheTest.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CachePolicyVFSCacheTest.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/CachePolicyVFSCacheTest.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/CachePolicyVFSCacheTest.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,42 @@
+/*
+* 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.test.virtual.test;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Map VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CachePolicyVFSCacheTest extends VFSCacheTest
+{
+   public CachePolicyVFSCacheTest(String name)
+   {
+      super(name);
+   }
+
+   protected void testCachedContexts(Iterable<VFSContext> iter)
+   {
+      assertFalse(iter.iterator().hasNext());
+   }
+}
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -1485,11 +1485,11 @@
       VFS vfs = VFS.getVFS(rootURL);
       URL[] cp = {vfs.getRoot().toURL()};
       URLClassLoader ucl = new URLClassLoader(cp);
-      // Search for a non-existent absolute resource
-      URL qp = ucl.findResource("/nosuch-quartz.props");
-      assertNull("findResource(/nosuch-quartz.props)", qp);
-      InputStream is = ucl.getResourceAsStream("/nosuch-quartz.props");
-      assertNull("getResourceAsStream(/nosuch-quartz.props)", is);
+      // Search for a non-existent resource
+      URL qp = ucl.findResource("nosuch-quartz.props");
+      assertNull("findResource(nosuch-quartz.props)", qp);
+      InputStream is = ucl.getResourceAsStream("nosuch-quartz.props");
+      assertNull("getResourceAsStream(nosuch-quartz.props)", is);
    }
 
    /**

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,49 @@
+/*
+* 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.test.virtual.test;
+
+import junit.framework.Test;
+import org.jboss.virtual.plugins.cache.LRUVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+
+/**
+ * LRU VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LRUCacheTestCase extends CachePolicyVFSCacheTest
+{
+   public LRUCacheTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(LRUCacheTestCase.class);
+   }
+
+   protected VFSCache createCache()
+   {
+      return new LRUVFSCache(2, 10);
+   }
+}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,43 @@
+/*
+* 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.test.virtual.test;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Map VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class MapVFSCacheTest extends VFSCacheTest
+{
+   public MapVFSCacheTest(String name)
+   {
+      super(name);
+   }
+
+   protected void testCachedContexts(Iterable<VFSContext> iter)
+   {
+      VFSContext context = iter.iterator().next();
+      assertNotNull(context);
+   }
+}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,49 @@
+/*
+* 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.test.virtual.test;
+
+import org.jboss.virtual.plugins.cache.SoftRefVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import junit.framework.Test;
+
+/**
+ * SoftRef VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SoftRefCacheTestCase extends MapVFSCacheTest
+{
+   public SoftRefCacheTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(SoftRefCacheTestCase.class);
+   }
+
+   protected VFSCache createCache()
+   {
+      return new SoftRefVFSCache();
+   }
+}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,49 @@
+/*
+* 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.test.virtual.test;
+
+import org.jboss.virtual.plugins.cache.TimedVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import junit.framework.Test;
+
+/**
+ * Timed VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TimedCacheTestCase extends CachePolicyVFSCacheTest
+{
+   public TimedCacheTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(TimedCacheTestCase.class);
+   }
+
+   protected VFSCache createCache()
+   {
+      return new TimedVFSCache(60);
+   }
+}
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2008-11-04 09:27:54 UTC (rev 80460)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -86,6 +86,11 @@
       // custom
       suite.addTest(CustomTestCase.suite());
       suite.addTest(VFSResourceTestCase.suite());
+      // cache
+      suite.addTest(LRUCacheTestCase.suite());
+      suite.addTest(TimedCacheTestCase.suite());
+      suite.addTest(SoftRefCacheTestCase.suite());
+      suite.addTest(WeakRefCacheTestCase.suite());
 
       return suite;
    }

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,166 @@
+/*
+* 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.test.virtual.test;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCacheFactory;
+import org.jboss.virtual.spi.cache.CacheStatistics;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class VFSCacheTest extends AbstractVFSTest
+{
+   public VFSCacheTest(String name)
+   {
+      super(name);
+   }
+
+   protected abstract VFSCache createCache();
+
+   @SuppressWarnings("deprecation")
+   public void testCache() throws Exception
+   {
+      URL url = getResource("/vfs/test/nested");
+
+      VFSCache cache = createCache();
+      cache.start();
+      try
+      {
+         VFSCacheFactory.setInstance(cache);
+         try
+         {
+            VirtualFile root = VFS.getRoot(url);
+
+            VirtualFile file = root.findChild("/nested.jar/META-INF/empty.txt");
+            URL fileURL = file.toURL();
+            VirtualFile nested = root.findChild("/nested.jar/complex.jar/subfolder/subsubfolder/subsubchild");
+            URL nestedURL = nested.toURL();
+
+            assertEquals(file, cache.getFile(fileURL));
+            assertEquals(nested, cache.getFile(nestedURL));
+
+            VFSCacheFactory.setInstance(null);
+            VFSCache wrapper = new WrapperVFSCache(cache);
+            VFSCacheFactory.setInstance(wrapper);
+
+            assertEquals(file, wrapper.getFile(fileURL));
+            assertEquals(nested, wrapper.getFile(nestedURL));
+         }
+         finally
+         {
+            VFSCacheFactory.setInstance(null);
+         }
+      }
+      finally
+      {
+         cache.stop();
+      }
+   }
+
+   protected abstract void testCachedContexts(Iterable<VFSContext> iter);
+
+   public void testCacheStatistics() throws Exception
+   {
+      URL url = getResource("/vfs/test/nested");
+
+      VFSCache cache = createCache();
+      cache.start();
+      try
+      {
+         if (cache instanceof CacheStatistics)
+         {
+            CacheStatistics statistics = CacheStatistics.class.cast(cache);
+            VFSCacheFactory.setInstance(cache);
+            try
+            {
+               VirtualFile root = VFS.getRoot(url);
+               assertNotNull(root);
+
+               Iterable<VFSContext> iter = statistics.getCachedContexts();
+               testCachedContexts(iter);
+
+               assertEquals(1, statistics.size());
+               assertTrue(statistics.lastInsert() != 0);
+            }
+            finally
+            {
+               VFSCacheFactory.setInstance(null);
+            }
+         }
+      }
+      finally
+      {
+         cache.stop();
+      }
+   }
+
+   private class WrapperVFSCache implements VFSCache
+   {
+      private VFSCache delegate;
+
+      private WrapperVFSCache(VFSCache delegate)
+      {
+         this.delegate = delegate;
+      }
+
+      public VirtualFile getFile(URI uri) throws IOException
+      {
+         return delegate.getFile(uri);
+      }
+
+      public VirtualFile getFile(URL url) throws IOException
+      {
+         return delegate.getFile(url);
+      }
+
+      public void putContext(VFSContext context)
+      {
+         throw new IllegalArgumentException("Context should already be there: " + context);
+      }
+
+      public void removeContext(VFSContext context)
+      {
+      }
+
+      public void start() throws Exception
+      {
+      }
+
+      public void stop()
+      {
+      }
+
+      public void flush()
+      {
+      }
+   }
+}
\ No newline at end of file

Copied: projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java (from rev 80460, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java)
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java	                        (rev 0)
+++ projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java	2008-11-04 10:22:38 UTC (rev 80461)
@@ -0,0 +1,49 @@
+/*
+* 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.test.virtual.test;
+
+import org.jboss.virtual.plugins.cache.WeakRefVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import junit.framework.Test;
+
+/**
+ * SoftRef VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WeakRefCacheTestCase extends MapVFSCacheTest
+{
+   public WeakRefCacheTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(WeakRefCacheTestCase.class);
+   }
+
+   protected VFSCache createCache()
+   {
+      return new WeakRefVFSCache();
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list