[jboss-cvs] JBossAS SVN: r84126 - in branches/Branch_5_0: system/src/main/org/jboss/system/server/profile/basic and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 12 09:57:29 EST 2009
Author: alesj
Date: 2009-02-12 09:57:29 -0500 (Thu, 12 Feb 2009)
New Revision: 84126
Modified:
branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile.xml
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/basic/MetaDataAwareProfileService.java
Log:
[JBAS-6491]; use StructureModificationChecker - port to legacy profile usage.
Modified: branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile.xml
===================================================================
--- branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile.xml 2009-02-12 14:25:43 UTC (rev 84125)
+++ branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile.xml 2009-02-12 14:57:29 UTC (rev 84126)
@@ -11,6 +11,18 @@
<root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
</classloader>
+ <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.DefaultStructureCache">
+ <destroy method="flush"/>
+ </bean>
+
+ <bean name="StructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker">
+ <constructor>
+ <parameter><inject bean="MainDeployer" /></parameter>
+ </constructor>
+ <property name="cache"><inject bean="StructureModCache" /></property>
+ <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+ </bean>
+
<!-- The basic profile service which relies on vfs scanners
to determine the profile deployments. This version does not
support the full ProfileService spi.
@@ -22,9 +34,7 @@
<property name="profileRoot">${jboss.server.home.dir}</property>
<property name="mainDeployer"><inject bean="MainDeployer"/></property>
<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
- <property name="filter">
- <bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter"/>
- </property>
+ <property name="checker"><inject bean="StructureModificationChecker"/></property>
</bean>
<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
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-12 14:25:43 UTC (rev 84125)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profile/basic/MetaDataAwareProfile.java 2009-02-12 14:57:29 UTC (rev 84126)
@@ -21,20 +21,14 @@
*/
package org.jboss.system.server.profile.basic;
-import java.io.File;
import java.io.IOException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import org.jboss.deployers.structure.spi.DeploymentContext;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
@@ -51,12 +45,11 @@
{
private MainDeployerStructure mainDeployer;
private VirtualFileFilter filter;
- private Map<String, Long> lastModifiedCache;
+ private StructureModificationChecker checker;
public MetaDataAwareProfile(String profileRoot, ProfileKey key)
{
super(profileRoot, key);
- lastModifiedCache = new ConcurrentHashMap<String, Long>();
}
/**
@@ -64,6 +57,7 @@
*
* @param mainDeployer the main deployer structure
*/
+ @Deprecated
public void setMainDeployer(MainDeployerStructure mainDeployer)
{
this.mainDeployer = mainDeployer;
@@ -74,114 +68,53 @@
*
* @param filter the metadata resources filter
*/
+ @Deprecated
public void setFilter(VirtualFileFilter filter)
{
this.filter = filter;
}
- protected boolean hasBeenModified(VirtualFile root) throws Exception
+ protected StructureModificationChecker getChecker()
{
- // skip vfs deployment context lookup if archive or file
- if (root.isArchive() || root.isLeaf())
- return root.hasBeenModified();
+ if (checker == null)
+ throw new IllegalArgumentException("Null checker");
- String name = root.toURI().toString();
- VFSDeploymentContext deploymentContext = getDeploymentContext(name);
- if (deploymentContext != null)
- return hasBeenModified(deploymentContext);
-
- log.debug("Falling back to root name: " + root);
- deploymentContext = getDeploymentContext(root.getName());
- if (deploymentContext != null)
- return hasBeenModified(deploymentContext);
-
- return false;
+ return checker;
}
/**
- * Has vfs deployment context been modified.
+ * Set the structure modification checker.
*
- * @param deploymentContext the vfs deployment context
- * @return true if modified
- * @throws IOException for any error
+ * @param checker the structure modification checker
*/
- protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
+ public void setChecker(StructureModificationChecker checker)
{
- return hasBeenModified(deploymentContext, false);
+ this.checker = checker;
}
+ protected boolean hasBeenModified(VirtualFile root) throws Exception
+ {
+ return getChecker().hasStructureBeenModified(root);
+ }
+
/**
* 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
+ @Deprecated
+ protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) 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)
- {
- for(VirtualFile metadataLocation : metadataLocations)
- {
- List<VirtualFile> children = metadataLocation.getChildren(filter);
- if (children != null && children.isEmpty() == false)
- {
- for(VirtualFile child : children)
- {
- String pathName = child.getPathName();
- Long timestamp = lastModifiedCache.get(pathName);
- long lastModified = child.getLastModified();
- lastModifiedCache.put(pathName, lastModified);
- if (timestamp != null && timestamp < lastModified)
- {
- if (log.isTraceEnabled())
- log.trace("Metadata location modified: " + child);
- return true;
- }
- }
- }
- }
- }
- List<DeploymentContext> childContexts = deploymentContext.getChildren();
- if (childContexts != null && childContexts.isEmpty() == false)
- {
- for (DeploymentContext childContext : childContexts)
- {
- if (childContext instanceof VFSDeploymentContext)
- {
- if (hasBeenModified((VFSDeploymentContext)childContext, true))
- return true;
- }
- }
- }
- return false;
+ return getChecker().hasStructureBeenModified(deploymentContext);
}
// expecting all deployments from same context root
// so path name should group them per deployment unit
protected void postRemove(VFSDeployment deployment) throws Exception
{
- VirtualFile root = deployment.getRoot();
- String pathName = root.getPathName();
- 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();
- }
+ getChecker().removeStructureRoot(deployment.getRoot());
}
/**
@@ -191,6 +124,7 @@
* @return vfs deployment context or null if doesn't exist or not vfs based
*/
@SuppressWarnings("deprecation")
+ @Deprecated
protected VFSDeploymentContext getDeploymentContext(String name)
{
if (mainDeployer == null)
Modified: branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java 2009-02-12 14:25:43 UTC (rev 84125)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/basic/MetaDataAwareProfileService.java 2009-02-12 14:57:29 UTC (rev 84126)
@@ -24,6 +24,7 @@
import java.io.IOException;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.system.server.profile.basic.MetaDataAwareProfile;
@@ -40,6 +41,7 @@
{
private MainDeployerStructure mainDeployer;
private VirtualFileFilter filter;
+ private StructureModificationChecker checker;
public MetaDataAwareProfileService(String name) throws IOException
{
@@ -52,9 +54,10 @@
throw new IllegalArgumentException("Null main deployer");
MetaDataAwareProfile profile = new MetaDataAwareProfile(getProfileRoot(), key);
+ profile.setDeploymentFilter(deploymentFilter);
profile.setMainDeployer(mainDeployer);
- profile.setDeploymentFilter(deploymentFilter);
profile.setFilter(filter);
+ profile.setChecker(checker);
return profile;
}
@@ -63,6 +66,7 @@
*
* @param mainDeployer the main deployer structure
*/
+ @Deprecated
public void setMainDeployer(MainDeployerStructure mainDeployer)
{
this.mainDeployer = mainDeployer;
@@ -73,8 +77,19 @@
*
* @param filter the metadata resources filter
*/
+ @Deprecated
public void setFilter(VirtualFileFilter filter)
{
this.filter = filter;
}
+
+ /**
+ * Set the structure modification checker.
+ *
+ * @param checker the structure modification checker
+ */
+ public void setChecker(StructureModificationChecker checker)
+ {
+ this.checker = checker;
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list