[jboss-cvs] JBossAS SVN: r84053 - 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
Tue Feb 10 07:26:10 EST 2009


Author: alesj
Date: 2009-02-10 07:26:10 -0500 (Tue, 10 Feb 2009)
New Revision: 84053

Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DefaultStructureCache.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureCache.java
Log:
Handle metadata add/remove, attempt #2.

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DefaultStructureCache.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DefaultStructureCache.java	2009-02-10 12:18:00 UTC (rev 84052)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DefaultStructureCache.java	2009-02-10 12:26:10 UTC (rev 84053)
@@ -23,6 +23,7 @@
 
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -49,7 +50,7 @@
       return map.get(pathName);
    }
 
-   public Integer getLeavesCount(String pathName)
+   public Set<String> getLeaves(String pathName)
    {
       // TODO
       return null;

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java	2009-02-10 12:18:00 UTC (rev 84052)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java	2009-02-10 12:26:10 UTC (rev 84053)
@@ -23,6 +23,7 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Set;
 
 import org.jboss.deployers.spi.structure.ContextInfo;
 import org.jboss.deployers.spi.structure.StructureMetaData;
@@ -110,18 +111,25 @@
                if (mdpVF != null)
                {
                   List<VirtualFile> children = mdpVF.getChildren(filter);
+                  Set<String> leaves = getCache().getLeaves(mdpVF.getPathName());
+                  // do we have some new files or some were deleted
+                  if (leaves != null && children != null && leaves.size() != children.size())
+                  {
+                     return true;
+                  }
+
                   if (children != null && children.isEmpty() == false)
                   {
-                     Integer cachedSize = getCache().getLeavesCount(mdpVF.getPathName());
-                     // do we have some new files or some were deleted
-                     if (cachedSize != null && cachedSize != children.size())
-                     {
-                        return true;
-                     }
-
                      for (VirtualFile child : children)
                      {
                         String pathName = child.getPathName();
+
+                        // we tried to remove non existing leaf - it's new == modified 
+                        if (leaves != null && leaves.remove(pathName) == false)
+                        {
+                           return true;
+                        }
+
                         Long timestamp = getCache().getCacheValue(pathName);
                         long lastModified = child.getLastModified();
                         getCache().putCacheValue(pathName, lastModified);
@@ -133,6 +141,11 @@
                         }
                      }
                   }
+                  // not all previous leaves were removed - we're missing some == modified
+                  if (leaves != null && leaves.isEmpty() == false)
+                  {
+                     return true;
+                  }
                }
             }
          }

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureCache.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureCache.java	2009-02-10 12:18:00 UTC (rev 84052)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureCache.java	2009-02-10 12:26:10 UTC (rev 84053)
@@ -21,6 +21,8 @@
  */
 package org.jboss.deployers.vfs.spi.structure.modified;
 
+import java.util.Set;
+
 /**
  * Simple structure cache.
  *
@@ -54,13 +56,16 @@
    T getCacheValue(String pathName);
 
    /**
-    * Get leaves count for this path name parameter.
+    * Get leaves for this path name parameter.
     * Only exact sub path nodes count in.
     *
+    * This method should return a mutable Set copy
+    * as we intend to modify it in checker processing.
+    *
     * @param pathName the path name
-    * @return sub-paths node size or null if no such match yet
+    * @return sub-paths nodes or null if no such match yet
     */
-   Integer getLeavesCount(String pathName);
+   Set<String> getLeaves(String pathName);
 
    /**
     * Invalidate cache for path name.




More information about the jboss-cvs-commits mailing list