[jboss-cvs] JBossAS SVN: r84055 - 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 08:12:40 EST 2009


Author: alesj
Date: 2009-02-10 08:12:40 -0500 (Tue, 10 Feb 2009)
New Revision: 84055

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
Log:
Handle initial empty metadata path.

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:57:34 UTC (rev 84054)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/DefaultStructureCache.java	2009-02-10 13:12:40 UTC (rev 84055)
@@ -24,7 +24,10 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
 
 /**
  * Default structure cache.
@@ -52,8 +55,22 @@
 
    public Set<String> getLeaves(String pathName)
    {
-      // TODO
-      return null;
+      Set<String> result = null;
+      Pattern pattern = Pattern.compile(pathName + "/[^/]+");
+      for (String key : map.keySet())
+      {
+         if (pattern.matcher(key).matches())
+         {
+            if (result == null)
+               result = new HashSet<String>();
+
+            result.add(key);
+         }
+      }
+      if (result != null)
+         return result;
+      else
+         return (map.containsKey(pathName) ? Collections.<String>emptySet() : null);
    }
 
    public void invalidateCache(String pathName)

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:57:34 UTC (rev 84054)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java	2009-02-10 13:12:40 UTC (rev 84055)
@@ -111,7 +111,8 @@
                if (mdpVF != null)
                {
                   List<VirtualFile> children = mdpVF.getChildren(filter);
-                  Set<String> leaves = getCache().getLeaves(mdpVF.getPathName());
+                  String mdpPathName = mdpVF.getPathName();
+                  Set<String> leaves = getCache().getLeaves(mdpPathName);
                   // do we have some new files or some were deleted
                   if (leaves != null && children != null && leaves.size() != children.size())
                   {
@@ -132,15 +133,27 @@
 
                         Long timestamp = getCache().getCacheValue(pathName);
                         long lastModified = child.getLastModified();
-                        getCache().putCacheValue(pathName, lastModified);
-                        if (timestamp != null && timestamp < lastModified)
+                        if (timestamp != null)
                         {
-                           if (log.isTraceEnabled())
-                              log.trace("Metadata location modified: " + child);
-                           return true;
+                           if (timestamp < lastModified)
+                           {
+                              if (log.isTraceEnabled())
+                                 log.trace("Metadata location modified: " + child);
+                              return true;
+                           }
                         }
+                        else
+                        {
+                           // only put if not modified
+                           getCache().putCacheValue(pathName, lastModified);
+                        }
                      }
                   }
+                  else
+                  {                     
+                     // mark empty metadata path
+                     getCache().putCacheValue(mdpPathName, System.currentTimeMillis());
+                  }
                   // not all previous leaves were removed - we're missing some == modified
                   if (leaves != null && leaves.isEmpty() == false)
                   {




More information about the jboss-cvs-commits mailing list