[jboss-cvs] JBossAS SVN: r92381 - projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 12:00:39 EDT 2009


Author: alesj
Date: 2009-08-14 12:00:38 -0400 (Fri, 14 Aug 2009)
New Revision: 92381

Added:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/ModificationCheckerFilter.java
Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
Log:
[JBDEPLOY-207]; expose root check as filter.

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-08-14 15:22:31 UTC (rev 92380)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-08-14 16:00:38 UTC (rev 92381)
@@ -46,8 +46,11 @@
    /** The main deployer structure */
    private MainDeployerInternals mainDeployer;
 
+   /** The root filter */
+   private ModificationCheckerFilter rootFilter;
+
    /** The structure cache */
-   private StructureCache<T> cache;
+   private volatile StructureCache<T> cache;
 
    protected AbstractStructureModificationChecker()
    {
@@ -62,8 +65,38 @@
    }
 
    /**
+    * Get root filter.
+    *
+    * Use DefaultRootFilter if no explicit config
+    *
+    * @return
+    */
+   protected ModificationCheckerFilter getRootFilter()
+   {
+      if (rootFilter == null)
+         rootFilter = new DefaultRootFilter();
+
+      return rootFilter;
+   }
+
+   /**
+    * Set root filter.
+    *
+    * @param rootFilter the root filter
+    */
+   public void setRootFilter(ModificationCheckerFilter rootFilter)
+   {
+      if (rootFilter == null)
+         throw new IllegalArgumentException("Null root filter");
+
+      this.rootFilter = rootFilter;
+   }
+
+   /**
     * Get the structure cache.
     *
+    * Use DefaultStructureCache if no explict config.
+    *
     * @return the structure cache
     */
    protected StructureCache<T> getCache()
@@ -118,15 +151,15 @@
       if (root == null)
          throw new IllegalArgumentException("Null root");
 
-      // skip vfs deployment context lookup if archive or file
-      if (root.isArchive() || root.isLeaf())
+      // skip vfs deployment context lookup accepted by filter
+      if (getRootFilter().accepts(root))
       {
          boolean result = hasRootBeenModified(root);
-         if (result)
+         if (result || getRootFilter().checkTopLevelOnly(root))
          {
             getCache().invalidateCache(root);
+            return result;
          }
-         return result;
       }
 
       VFSDeploymentContext deploymentContext;
@@ -184,13 +217,16 @@
       VirtualFile root = vfsDeployment.getRoot();
 
       boolean result = false;
+      boolean skip = false; // skip futher check
 
-      if (checkRoot && (root.isArchive() || root.isLeaf()))
+      if (checkRoot && getRootFilter().accepts(root))
       {
          result = hasRootBeenModified(root);
+         if (result || getRootFilter().checkTopLevelOnly(root))
+            skip = true;
       }
 
-      if (result == false)
+      if (skip == false)
       {
          result = hasStructureBeenModifed(root, deploymentContext);
       }
@@ -240,4 +276,27 @@
 
       getCache().removeCache(root);
    }
+
+   /**
+    * Default root check constraints.
+    */
+   private static class DefaultRootFilter implements ModificationCheckerFilter
+   {
+      public boolean accepts(VirtualFile file)
+      {
+         try
+         {
+            return file.isArchive() || file.isLeaf();
+         }
+         catch (IOException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      public boolean checkTopLevelOnly(VirtualFile root)
+      {
+         return true; // no point in checking entries 
+      }
+   }
 }

Added: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/ModificationCheckerFilter.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/ModificationCheckerFilter.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/ModificationCheckerFilter.java	2009-08-14 16:00:38 UTC (rev 92381)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployers.vfs.spi.structure.modified;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * ModificationCheckerFilter.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface ModificationCheckerFilter extends VirtualFileFilter
+{
+   /**
+    * Decide whether we should continue with checking for modification
+    * where this filter accepted the root, but root's modification result was false.
+    *
+    * e.g. no point in checking anything further in archives and leaves,
+    * but we should check further if root is a directory
+    *
+    * @param root the current root
+    * @return true if we should go on, false to return false
+    */
+   boolean checkTopLevelOnly(VirtualFile root);
+}




More information about the jboss-cvs-commits mailing list