[jboss-cvs] JBossAS SVN: r83883 - trunk/system/src/main/org/jboss/system/server/profileservice/repository.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 5 03:54:13 EST 2009


Author: alesj
Date: 2009-02-05 03:54:12 -0500 (Thu, 05 Feb 2009)
New Revision: 83883

Modified:
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
Log:
Cleanup lastModCache - when modified or removed.

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-02-05 08:28:49 UTC (rev 83882)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-02-05 08:54:12 UTC (rev 83883)
@@ -53,11 +53,11 @@
  * A mutable deployment repository, with hot deployment capabilities.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision$
  */
 public class MutableDeploymentRepository extends AbstractDeploymentRepository
 {
-   
    /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
    private boolean failIfAlreadyExists = false;
    
@@ -197,9 +197,9 @@
             {
                ProfileDeployment ctx = iter.next();
                VirtualFile root = ctx.getRoot();
-               String name = root.getPathName();
+               String pathName = root.getPathName();
                // Ignore locked or disabled applications
-               if (this.hasDeploymentContentFlags(name, ignoreFlags))
+               if (this.hasDeploymentContentFlags(pathName, ignoreFlags))
                {
                   if (trace)
                      log.trace("Ignoring locked application: " + root);
@@ -213,17 +213,17 @@
                   modified.add(info);
                   iter.remove();
                   // Remove last modified cache
-                  this.lastModifiedCache.remove(root.getPathName());
+                  removeLastModifiedCache(pathName);
                   if (trace)
-                     log.trace(name + " was removed");
+                     log.trace(pathName + " was removed");
                }
                // Check for modification
                else if (hasBeenModified(root)
-                     || hasDeploymentContentFlags(root.getPathName(), DeploymentContentFlags.MODIFIED))
+                     || hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED))
                {
                   long rootLastModified = root.getLastModified();
                   if (trace)
-                     log.trace(name + " was modified: " + rootLastModified);
+                     log.trace(pathName + " was modified: " + rootLastModified);
                   // Need to create a duplicate ctx
                   ProfileDeployment ctx2 = loadDeploymentData(root);
                   ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
@@ -273,6 +273,17 @@
     */
    protected boolean hasBeenModified(VirtualFile root) throws Exception
    {
+      boolean result = isModified(root);
+      if (result)
+      {
+         removeLastModifiedCache(root.getPathName());
+      }
+      return result;
+   }
+
+   protected boolean isModified(VirtualFile root) throws Exception
+   {
+      // skip vfs deployment context lookup if archive or file
       if (root.isArchive() || root.isLeaf())
          return root.hasBeenModified();
 
@@ -280,12 +291,12 @@
       String name = root.toURI().toString();
       VFSDeploymentContext deploymentContext = getDeploymentContext(name);
       if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
+         return hasBeenModified(deploymentContext, false);
 
       log.trace("Falling back to root name: " + root);
       deploymentContext = getDeploymentContext(root.getName());
       if (deploymentContext != null)
-         return hasBeenModified(deploymentContext);
+         return hasBeenModified(deploymentContext, false);
 
       return false;
    }
@@ -293,12 +304,21 @@
    /**
     * Check for modifications.
     * 
-    * @param deploymentContext
-    * @return
-    * @throws IOException
+    * @param deploymentContext the vfs deployment context
+    * @param checkRoot do we check the root
+    * @return true if modifed, false otherwise
+    * @throws IOException for any error
     */
-   protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
+   protected boolean hasBeenModified(VFSDeploymentContext deploymentContext, boolean checkRoot) throws IOException
    {
+      if (checkRoot)
+      {
+         VirtualFile root = deploymentContext.getRoot();
+         // no need to check metadata locations if archive or root
+         if (root.isArchive() || root.isLeaf())
+            return root.hasBeenModified();
+      }
+
       // hasBeenModified
       boolean hasBeenModified = false;
       List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
@@ -319,7 +339,7 @@
                   {
                      if (log.isTraceEnabled())
                         log.trace("Metadata location modified: " + child);
-                     hasBeenModified = true;
+                     return true;
                   }
                }
             }
@@ -332,14 +352,32 @@
          {
             if (childContext instanceof VFSDeploymentContext)
             {
-               if (hasBeenModified((VFSDeploymentContext)childContext))
-                  hasBeenModified = true;
+               if (hasBeenModified((VFSDeploymentContext)childContext, true))
+                  return true;
             }
          }
       }
       return hasBeenModified;
    }
 
+   /**
+    * Cleanup last modified cache for path name.
+    *
+    * @param pathName the path name
+    */
+   protected void removeLastModifiedCache(String pathName)
+   {
+      if (log.isTraceEnabled())
+         log.trace("Removing last modified cache info for: " + pathName);
+
+      Iterator<String> iter = lastModifiedCache.keySet().iterator();
+      while (iter.hasNext())
+      {
+         if (iter.next().startsWith(pathName))
+            iter.remove();
+      }
+   }
+
    public ProfileDeployment removeDeployment(String vfsPath) throws Exception
    {
       ProfileDeployment vfsDeployment = getDeployment(vfsPath);




More information about the jboss-cvs-commits mailing list