[jboss-cvs] JBossAS SVN: r84121 - 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 12 07:04:24 EST 2009
Author: alesj
Date: 2009-02-12 07:04:23 -0500 (Thu, 12 Feb 2009)
New Revision: 84121
Modified:
branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile-repository.xml
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/SerializableDeploymentRepositoryFactory.java
Log:
[JBAS-6491]; use StructureModificationChecker.
Modified: branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile-repository.xml
===================================================================
--- branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile-repository.xml 2009-02-12 11:20:41 UTC (rev 84120)
+++ branches/Branch_5_0/server/src/etc/conf/default/bootstrap/profile-repository.xml 2009-02-12 12:04:23 UTC (rev 84121)
@@ -11,7 +11,19 @@
<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 file repository profile service which provides full
support ProfileService spi.
-->
@@ -35,10 +47,8 @@
</property>
<property name="serializer"><inject bean="AttachmentsSerializer"/></property>
<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
- <property name="hotDeploymentFilter">
- <bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter"/>
- </property>
<property name="mainDeployer"><inject bean="MainDeployer"/></property>
+ <property name="checker"><inject bean="StructureModificationChecker"/></property>
<depends>ProfileServicePersistenceDeployer</depends>
</bean>
<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer" />
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-12 11:20:41 UTC (rev 84120)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2009-02-12 12:04:23 UTC (rev 84121)
@@ -44,22 +44,21 @@
import java.util.zip.ZipInputStream;
import org.jboss.deployers.spi.attachments.Attachments;
-import org.jboss.deployers.structure.spi.DeploymentContext;
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.logging.Logger;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.spi.DeploymentContentFlags;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.util.file.Files;
import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
@@ -114,17 +113,14 @@
/** Allowed deployments filter */
private VirtualFileFilter deploymentFilter;
- /** The metadata include filter */
- private VirtualFileFilter hotDeploymentFilter;
- /** The last modified cache */
- private Map<String, Long> lastModifiedCache;
+ /** The structure modification checker */
+ private StructureModificationChecker checker;
public SerializableDeploymentRepository(File root, URI[] appURIs, ProfileKey key)
{
this.root = root;
this.key = key;
this.setApplicationURIs(appURIs);
- this.lastModifiedCache = new ConcurrentHashMap<String, Long>();
}
public URI[] getApplicationURIs()
@@ -175,16 +171,30 @@
this.deploymentFilter = deploymentFilter;
}
+ @Deprecated
public VirtualFileFilter getHotDeploymentFilter()
{
- return hotDeploymentFilter;
+ return null;
}
+ @Deprecated
public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
{
- this.hotDeploymentFilter = hotDeploymentFilter;
}
+ protected StructureModificationChecker getChecker()
+ {
+ if (checker == null)
+ throw new IllegalArgumentException("Null checker");
+
+ return checker;
+ }
+
+ public void setChecker(StructureModificationChecker checker)
+ {
+ this.checker = checker;
+ }
+
public long getLastModified()
{
return this.lastModified;
@@ -367,23 +377,20 @@
{
if( log.isTraceEnabled() )
log.trace("lockDeploymentContent, "+vfsPath);
- int flags = setDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
- return flags;
+ return setDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
}
public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
{
if( log.isTraceEnabled() )
log.trace("unlockDeploymentContent, "+vfsPath);
- int flags = clearDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
- return flags;
+ return clearDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
}
public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase)
{
Integer flags = contentFlags.get(vfsPath);
- int iflags = flags != null ? flags.intValue() : 0;
- return iflags;
+ return flags != null ? flags : 0;
}
public synchronized int clearDeploymentContentFlags(String vfsPath,
DeploymentPhase phase,
@@ -395,8 +402,7 @@
dflags &= ~flags;
contentFlags.put(vfsPath, dflags);
}
- int iflags = dflags != null ? dflags.intValue() : 0;
- return iflags;
+ return dflags != null ? dflags : 0;
}
public boolean hasDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
int flag)
@@ -404,7 +410,7 @@
Integer flags = contentFlags.get(vfsPath);
boolean hasFlag = false;
if(flags != null )
- hasFlag = (flags & flag) != 0 ? true : false;
+ hasFlag = (flags & flag) != 0;
return hasFlag;
}
public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
@@ -549,7 +555,7 @@
modified.add(info);
iter.remove();
// Remove last modified cache
- removeLastModifiedCache(pathName);
+ getChecker().removeStructureRoot(root);
if( trace )
log.trace(pathName + " was removed");
}
@@ -584,6 +590,7 @@
VFSDeployment ctx = loadDeploymentData(vf, DeploymentPhase.APPLICATION);
ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
modified.add(info);
+ getChecker().addStructureRoot(vf);
applicationCtxs.put(ctx.getName(), ctx);
}
}
@@ -603,7 +610,6 @@
/**
* Check if the deployment has been modified.
- * Invalidate last modifed cache if modifed.
*
* @param root the virtual file root
* @return true if modifed
@@ -611,42 +617,10 @@
*/
protected boolean hasBeenModified(VirtualFile root) throws Exception
{
- boolean result = isModified(root);
- if (result)
- {
- removeLastModifiedCache(root.getPathName());
- }
- return result;
+ return getChecker().hasStructureBeenModified(root);
}
/**
- * Check if the deployment has been modified.
- * Note: it doesn't invalidate the last modified cache.
- *
- * @param root the virtual file root
- * @return true if modifed
- * @throws Exception for any error
- */
- private boolean isModified(VirtualFile root) throws Exception
- {
- // skip vfs deployment context lookup if archive or file
- if (root.isArchive() || root.isLeaf())
- return root.hasBeenModified();
-
- 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;
- }
-
- /**
* Has vfs deployment context been modified.
*
* @param deploymentContext the vfs deployment context
@@ -655,83 +629,18 @@
*/
protected boolean hasBeenModified(VFSDeploymentContext deploymentContext) throws IOException
{
- return hasBeenModified(deploymentContext, false);
+ return getChecker().hasStructureBeenModified(deploymentContext);
}
/**
- * 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)
- {
- for(VirtualFile metadataLocation : metadataLocations)
- {
- List<VirtualFile> children = metadataLocation.getChildren(hotDeploymentFilter);
- 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;
- }
-
-
- /**
* Cleanup last modified cache for path name.
*
* @param pathName the path name
*/
+ @Deprecated
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();
- }
+ log.warn("This method has no usage anymore, use StructureModificationChecher instead.");
}
public Collection<VFSDeployment> getDeployments(DeploymentPhase phase)
Modified: branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java 2009-02-12 11:20:41 UTC (rev 84120)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java 2009-02-12 12:04:23 UTC (rev 84121)
@@ -24,8 +24,10 @@
import java.io.File;
import java.net.URI;
import java.util.HashMap;
+import java.util.Map;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.profileservice.spi.AttachmentsSerializer;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
@@ -55,10 +57,11 @@
private VirtualFileFilter deploymentFilter;
/** The HotDeployment filter */
private VirtualFileFilter hotDeploymentFilter;
-
+ /** The structure modification checker */
+ private StructureModificationChecker checker;
+
/** The profile repositories */
- private HashMap<ProfileKey, DeploymentRepository> profileRepositories
- = new HashMap<ProfileKey, DeploymentRepository>();
+ private Map<ProfileKey, DeploymentRepository> profileRepositories = new HashMap<ProfileKey, DeploymentRepository>();
/**
* Get the server profile store root directory.
@@ -114,27 +117,39 @@
{
this.deploymentFilter = deploymentFilter;
}
-
+
+ @Deprecated
public VirtualFileFilter getHotDeploymentFilter()
{
return hotDeploymentFilter;
}
-
+
+ @Deprecated
public void setHotDeploymentFilter(VirtualFileFilter hotDeploymentFilter)
{
this.hotDeploymentFilter = hotDeploymentFilter;
}
-
+
public MainDeployerStructure getMainDeployer()
{
return mainDeployer;
}
-
+
public void setMainDeployer(MainDeployerStructure mainDeployer)
{
this.mainDeployer = mainDeployer;
}
+ public StructureModificationChecker getChecker()
+ {
+ return checker;
+ }
+
+ public void setChecker(StructureModificationChecker checker)
+ {
+ this.checker = checker;
+ }
+
public synchronized DeploymentRepository getDeploymentRepository(ProfileKey key)
{
if (appURIs == null || appURIs.length == 0)
@@ -151,6 +166,7 @@
repo.setDeploymentFilter(deploymentFilter);
repo.setHotDeploymentFilter(hotDeploymentFilter);
repo.setMainDeployer(mainDeployer);
+ repo.setChecker(checker);
profileRepositories.put(key, repo);
dr = repo;
}
More information about the jboss-cvs-commits
mailing list