[jboss-cvs] JBossAS SVN: r83886 - in branches/Branch_5_0/system/src/main/org/jboss/system/server: profileservice/repository and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 5 04:02:31 EST 2009
Author: alesj
Date: 2009-02-05 04:02:30 -0500 (Thu, 05 Feb 2009)
New Revision: 83886
Modified:
branches/Branch_5_0/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
Log:
Additional archive or leaf check.
Remove last modified cache on update or remove.
Modified: branches/Branch_5_0/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java 2009-02-05 08:57:46 UTC (rev 83885)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java 2009-02-05 09:02:30 UTC (rev 83886)
@@ -81,11 +81,10 @@
protected boolean hasBeenModified(VirtualFile root) throws Exception
{
- // if root is file check its modification
+ // skip vfs deployment context lookup if archive or file
if (root.isArchive() || root.isLeaf())
return root.hasBeenModified();
- // else check metadata
String name = root.toURI().toString();
VFSDeploymentContext deploymentContext = getDeploymentContext(name);
if (deploymentContext != null)
@@ -108,6 +107,27 @@
*/
protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
{
+ return hasBeenModified(deploymentContext, false);
+ }
+
+ /**
+ * Has vfs deployment context been modified.
+ *
+ * @param deploymentContext the vfs deployment context
+ * @param checkRoot do we check the root
+ * @return true if modified
+ * @throws IOException for any error
+ */
+ 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();
+ }
+
List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
if (metadataLocations != null && metadataLocations.isEmpty() == false)
{
@@ -139,7 +159,7 @@
{
if (childContext instanceof VFSDeploymentContext)
{
- if (hasBeenModified((VFSDeploymentContext)childContext))
+ if (hasBeenModified((VFSDeploymentContext)childContext, true))
return true;
}
}
@@ -154,7 +174,7 @@
VirtualFile root = deployment.getRoot();
String pathName = root.getPathName();
if (log.isTraceEnabled())
- log.debug("Removing last modified cache info for: " + pathName);
+ log.trace("Removing last modified cache info for: " + pathName);
Iterator<String> iter = lastModifiedCache.keySet().iterator();
while (iter.hasNext())
Modified: branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2009-02-05 08:57:46 UTC (rev 83885)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2009-02-05 09:02:30 UTC (rev 83886)
@@ -533,9 +533,9 @@
{
VFSDeployment ctx = iter.next();
VirtualFile root = ctx.getRoot();
- String name = root.getPathName();
+ String pathName = root.getPathName();
// Ignore locked or disabled applications
- if(this.hasDeploymentContentFlags(name, DeploymentPhase.APPLICATION, ignoreFlags))
+ if(this.hasDeploymentContentFlags(pathName, DeploymentPhase.APPLICATION, ignoreFlags))
{
if(trace)
log.trace("Ignoring locked application: "+root);
@@ -549,17 +549,17 @@
modified.add(info);
iter.remove();
// Remove last modified cache
- this.lastModifiedCache.remove(root.getPathName());
+ removeLastModifiedCache(pathName);
if( trace )
log.trace(name + " was removed");
}
// Check for modification
else if( hasBeenModified(root) ||
- hasDeploymentContentFlags(root.getPathName(), DeploymentPhase.APPLICATION, DeploymentContentFlags.MODIFIED) )
+ hasDeploymentContentFlags(pathName, DeploymentPhase.APPLICATION, 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
VFSDeployment ctx2 = loadDeploymentData(root, DeploymentPhase.APPLICATION);
ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
@@ -603,6 +603,7 @@
/**
* Check if the deployment has been modified.
+ * Update last modifed cache if modifed.
*
* @param root the virtual file root
* @return true if modifed
@@ -610,16 +611,33 @@
*/
protected boolean hasBeenModified(VirtualFile root) throws Exception
{
+ boolean result = isModified(root);
+ if (result)
+ {
+ removeLastModifiedCache(root.getPathName());
+ }
+ return result;
+ }
+
+ /**
+ * Check if the deployment has been modified.
+ *
+ * @param root the virtual file root
+ * @return true if modifed
+ * @throws Exception for any error
+ */
+ protected boolean isModified(VirtualFile root) throws Exception
+ {
+ // skip vfs deployment context lookup if archive or file
if (root.isArchive() || root.isLeaf())
return root.hasBeenModified();
- // else check metadata
String name = root.toURI().toString();
VFSDeploymentContext deploymentContext = getDeploymentContext(name);
if (deploymentContext != null)
return hasBeenModified(deploymentContext);
- log.trace("Falling back to root name: " + root);
+ log.debug("Falling back to root name: " + root);
deploymentContext = getDeploymentContext(root.getName());
if (deploymentContext != null)
return hasBeenModified(deploymentContext);
@@ -628,16 +646,35 @@
}
/**
- * Check for modifications.
+ * Has vfs deployment context been modified.
*
- * @param deploymentContext
- * @return
- * @throws IOException
+ * @param deploymentContext the vfs deployment context
+ * @return true if modified
+ * @throws IOException for any error
*/
protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
{
- // hasBeenModified
- boolean hasBeenModfied = false;
+ return hasBeenModified(deploymentContext, false);
+ }
+
+ /**
+ * Has vfs deployment context been modified.
+ *
+ * @param deploymentContext the vfs deployment context
+ * @param checkRoot do we check the root
+ * @return true if modified
+ * @throws IOException for any error
+ */
+ 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();
+ }
+
List<VirtualFile> metadataLocations = deploymentContext.getMetaDataLocations();
if (metadataLocations != null && metadataLocations.isEmpty() == false)
{
@@ -656,7 +693,7 @@
{
if (log.isTraceEnabled())
log.trace("Metadata location modified: " + child);
- hasBeenModfied = true;
+ return true;
}
}
}
@@ -669,15 +706,33 @@
{
if (childContext instanceof VFSDeploymentContext)
{
- if (hasBeenModified((VFSDeploymentContext)childContext))
- hasBeenModfied = true;
+ if (hasBeenModified((VFSDeploymentContext)childContext, true))
+ return true;
}
}
}
- return hasBeenModfied;
+ return false;
}
+ /**
+ * 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 Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
throws Exception
{
More information about the jboss-cvs-commits
mailing list