[jboss-cvs] JBossAS SVN: r80255 - projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 30 11:10:41 EDT 2008
Author: alesj
Date: 2008-10-30 11:10:41 -0400 (Thu, 30 Oct 2008)
New Revision: 80255
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
Log:
Add a check. e.g. is cache started.
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:57:25 UTC (rev 80254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/AbstractVFSCache.java 2008-10-30 15:10:41 UTC (rev 80255)
@@ -55,8 +55,15 @@
return timestamp;
}
+ /**
+ * Is cache valid.
+ */
+ protected abstract void check();
+
public VirtualFile getFile(URI uri) throws IOException
{
+ check();
+
VFSContext context = findContext(uri);
if (context != null)
{
@@ -84,6 +91,8 @@
public VirtualFile getFile(URL url) throws IOException
{
+ check();
+
try
{
return getFile(VFSUtils.toURI(url));
@@ -177,6 +186,8 @@
if (context == null)
throw new IllegalArgumentException("Null context");
+ check();
+
lock.writeLock().lock();
try
{
@@ -202,6 +213,8 @@
if (context == null)
throw new IllegalArgumentException("Null context");
+ check();
+
lock.writeLock().lock();
try
{
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:57:25 UTC (rev 80254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-10-30 15:10:41 UTC (rev 80255)
@@ -49,6 +49,12 @@
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
{
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:57:25 UTC (rev 80254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java 2008-10-30 15:10:41 UTC (rev 80255)
@@ -48,6 +48,12 @@
return cache != null ? cache.size() : -1;
}
+ protected void check()
+ {
+ if (cache == null)
+ throw new IllegalArgumentException("Cache needs to be started first.");
+ }
+
protected VFSContext getContext(String path)
{
return cache.get(path);
More information about the jboss-cvs-commits
mailing list