[jboss-cvs] JBossAS SVN: r89188 - branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 20 10:12:20 EDT 2009


Author: emuckenhuber
Date: 2009-05-20 10:12:20 -0400 (Wed, 20 May 2009)
New Revision: 89188

Modified:
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java
   branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
Log:
update check when applying the persisted changes.

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java	2009-05-20 14:08:34 UTC (rev 89187)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java	2009-05-20 14:12:20 UTC (rev 89188)
@@ -21,11 +21,16 @@
  */ 
 package org.jboss.system.server.profileservice.persistence.deployer;
 
+import java.io.IOException;
 import java.util.List;
 
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
+import org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -33,25 +38,61 @@
  */
 public class PersistenceModificationChecker
 {
+   
    /** The logger. */
    private static final Logger log = Logger.getLogger(PersistenceModificationChecker.class);
    
-   private static final String suffix = ".xml";
+   /** The filter. */
+   private static VirtualFileFilter filter = new XmlIncludeVirtualFileFilter();
    
-   public static boolean hasBeenModified(VFSDeploymentUnit unit, long lastModified)
+   public static boolean hasBeenModified(VFSDeploymentUnit unit, long lastModified) throws Exception
    {
-      List<VirtualFile> files = unit.getMetaDataFiles(null, suffix);
-      for(VirtualFile vf : files)
+      VirtualFile root = unit.getRoot();
+      if (root.isArchive() || root.isLeaf())
       {
-         try
+         if(root.getLastModified() > lastModified)
+            return true;
+      }
+
+      StructureMetaData structureMetaData = unit.getAttachment(StructureMetaData.class);
+      if(structureMetaData == null)
+         return false;
+      
+      ContextInfo info = structureMetaData.getContext(unit.getSimpleName());
+      if(info == null && unit.isTopLevel())
+         info = structureMetaData.getContext("");
+      
+      if(info == null)
+         return false;
+      
+      return hasBeenModifed(root, info, lastModified);
+   }
+
+   protected static boolean hasBeenModifed(VirtualFile root, ContextInfo contextInfo, long lastModified) throws IOException
+   {
+      List<String> metadataPaths = contextInfo.getMetaDataPath();
+      if (metadataPaths != null && metadataPaths.isEmpty() == false)
+      {
+         for (String metaDataPath : metadataPaths)
          {
-            if(vf.getLastModified() > lastModified)
-               return true;            
+            VirtualFile mdpVF = root.getChild(metaDataPath);
+            if (mdpVF != null)
+            {
+               List<VirtualFile> children = mdpVF.getChildren(filter);
+               if (children != null && children.isEmpty() == false)
+               {
+                  for (VirtualFile child : children)
+                  {
+                     if (child.getLastModified() > lastModified)
+                     {
+                        if (log.isTraceEnabled())
+                           log.trace("Metadata location modified: " + child);
+                        return true;
+                     }
+                  }
+               }
+            }
          }
-         catch(Exception e)
-         {
-            log.debug("failed to check modified ", e);
-         }
       }
       return false;
    }

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java	2009-05-20 14:08:34 UTC (rev 89187)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java	2009-05-20 14:12:20 UTC (rev 89188)
@@ -27,7 +27,6 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
-import org.jboss.metadata.spi.MetaData;
 import org.jboss.system.server.profileservice.attachments.AttachmentMetaData;
 import org.jboss.system.server.profileservice.attachments.AttachmentStore;
 import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaData;
@@ -91,7 +90,7 @@
          return;
       try
       {
-         internalDeployment((VFSDeploymentUnit) unit);
+         applyPersistentChanges((VFSDeploymentUnit) unit);
       }
       catch(Throwable e)
       {
@@ -99,7 +98,7 @@
       }
    }
    
-   protected void internalDeployment(VFSDeploymentUnit unit) throws Throwable
+   protected void applyPersistentChanges(VFSDeploymentUnit unit) throws Throwable
    {
       VirtualFile vf = unit.getRoot();
       RepositoryAttachmentMetaData metaData = store.loadMetaData(vf);
@@ -109,7 +108,7 @@
       // Check if the deployment was modified
       if(PersistenceModificationChecker.hasBeenModified(unit, metaData.getLastModified()))
       {
-         log.debug("Deployment was modified, not applying persisted information.");
+         log.debug("Deployment was modified, not applying persisted information : " + unit);
          return;
       }
       //
@@ -126,7 +125,6 @@
                   log.warn("Null persisted information for deployment: " + vf);
                }
                // update ...
-               MetaData md = unit.getMetaData();
                getPersistenceFactory().restorePersistenceRoot(root, instance, unit.getClassLoader());
             }
             else




More information about the jboss-cvs-commits mailing list