[jboss-cvs] JBossAS SVN: r80247 - in projects/vfs/trunk/src: main/java/org/jboss/virtual/plugins/vfs and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 30 10:38:28 EDT 2008


Author: alesj
Date: 2008-10-30 10:38:28 -0400 (Thu, 30 Oct 2008)
New Revision: 80247

Added:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/
   projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java
Removed:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java
Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCacheFactory.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java
Log:
[JBVFS-61]; move to spi.cache package.
Add CacheStatistics, optional implementation.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -33,7 +33,8 @@
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.spi.cache.CacheStatistics;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
@@ -42,12 +43,18 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public abstract class AbstractVFSCache implements VFSCache
+public abstract class AbstractVFSCache implements VFSCache, CacheStatistics
 {
    protected Logger log = Logger.getLogger(getClass());
    
    protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+   private long timestamp;
 
+   public long lastInsert()
+   {
+      return timestamp;
+   }
+
    public VirtualFile getFile(URI uri) throws IOException
    {
       lock.readLock().lock();
@@ -175,6 +182,7 @@
       try
       {
          putContext(getKey(context), context);
+         timestamp = System.currentTimeMillis();
       }
       finally
       {

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -23,6 +23,7 @@
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Collections;
 
 import org.jboss.util.CachePolicy;
 import org.jboss.virtual.spi.VFSContext;
@@ -37,6 +38,17 @@
    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;
+   }
+
    public void start() throws Exception
    {
       policy = createCachePolicy();

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -21,6 +21,7 @@
 */
 package org.jboss.virtual.plugins.cache;
 
+import java.util.Collections;
 import java.util.Map;
 
 import org.jboss.virtual.spi.VFSContext;
@@ -34,6 +35,19 @@
 {
    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 VFSContext getContext(String path)
    {
       return cache.get(path);

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/VirtualFileURLConnection.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -27,7 +27,7 @@
 import java.net.URLConnection;
 
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 import org.jboss.virtual.spi.VFSCacheFactory;
 
 /**

Deleted: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -1,80 +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;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-
-import org.jboss.virtual.VirtualFile;
-
-/**
- * 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();
-}

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCacheFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCacheFactory.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCacheFactory.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -32,6 +32,7 @@
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.cache.VFSCache;
 
 /**
  * Simple vfs cache factory.

Copied: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java (from rev 80240, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java)
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	                        (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/CacheStatistics.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -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 inster timestamp.
+    *
+    * @return the last inster timestamp
+    */
+   long lastInsert();
+}
\ No newline at end of file

Copied: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java (from rev 80240, projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/VFSCache.java)
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	                        (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCache.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -0,0 +1,81 @@
+/*
+* 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();
+}

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -23,7 +23,7 @@
 
 import junit.framework.Test;
 import org.jboss.virtual.plugins.cache.LRUVFSCache;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 
 /**
  * LRU VFSCache Test.

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SoftRefCacheTestCase.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -22,7 +22,7 @@
 package org.jboss.test.virtual.test;
 
 import org.jboss.virtual.plugins.cache.SoftRefVFSCache;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 import junit.framework.Test;
 
 /**

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -22,7 +22,7 @@
 package org.jboss.test.virtual.test;
 
 import org.jboss.virtual.plugins.cache.TimedVFSCache;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 import junit.framework.Test;
 
 /**

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -27,7 +27,7 @@
 
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VFSCacheFactory;
 

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java	2008-10-30 14:07:38 UTC (rev 80246)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/WeakRefCacheTestCase.java	2008-10-30 14:38:28 UTC (rev 80247)
@@ -22,7 +22,7 @@
 package org.jboss.test.virtual.test;
 
 import org.jboss.virtual.plugins.cache.WeakRefVFSCache;
-import org.jboss.virtual.spi.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
 import junit.framework.Test;
 
 /**




More information about the jboss-cvs-commits mailing list