[jboss-cvs] JBossAS SVN: r88223 - projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 5 11:07:56 EDT 2009


Author: alesj
Date: 2009-05-05 11:07:56 -0400 (Tue, 05 May 2009)
New Revision: 88223

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
Log:
Refactor cachable check.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java	2009-05-05 15:06:30 UTC (rev 88222)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java	2009-05-05 15:07:56 UTC (rev 88223)
@@ -26,13 +26,14 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.List;
+import java.util.Set;
 
+import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.spi.TempInfo;
 import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VFSContextConstraints;
 import org.jboss.virtual.spi.VirtualFileHandler;
-import org.jboss.virtual.spi.TempInfo;
-import org.jboss.virtual.spi.VFSContextConstraints;
 import org.jboss.virtual.spi.cache.VFSCache;
 import org.jboss.virtual.spi.cache.VFSCacheFactory;
 import org.jboss.virtual.spi.registry.VFSRegistry;
@@ -54,9 +55,21 @@
       return VFSCacheFactory.getInstance();
    }
 
+   /**
+    * Is the vfs context cacheable.
+    *
+    * @param context the vfs context
+    * @return true if context is cacheable, false otherwise
+    */
+   protected boolean isCacheable(VFSContext context)
+   {
+      Set<VFSContextConstraints> constraints = context.getConstraints();
+      return constraints != null && constraints.contains(VFSContextConstraints.CACHEABLE);
+   }
+
    public void addContext(VFSContext context)
    {
-      if (context.getConstraints().contains(VFSContextConstraints.CACHEABLE))
+      if (isCacheable(context))
       {
          getCache().putContext(context);
       }
@@ -64,7 +77,7 @@
 
    public void removeContext(VFSContext context)
    {
-      if (context.getConstraints().contains(VFSContextConstraints.CACHEABLE))
+      if (isCacheable(context))
       {
          getCache().removeContext(context);
       }




More information about the jboss-cvs-commits mailing list