[jboss-cvs] JBossAS SVN: r98957 - in projects/jboss-deployers/branches/vfs3: deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/dir and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 30 17:48:51 EST 2009
Author: johnbailey
Date: 2009-12-30 17:48:50 -0500 (Wed, 30 Dec 2009)
New Revision: 98957
Modified:
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchWrapperModificationChecker.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/UpdateDeleteVisitor.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/dir/GroupingStructure.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/support/MockWarStructureDeployer.java
Log:
[JBAS-7362] - Put in a simple first cut at being able synchronize changes for a temporary copy of a deployment root.
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -46,13 +46,12 @@
*/
public boolean determineStructure(StructureContext context) throws DeploymentException
{
- VirtualFile file = context.getFile();
+ VirtualFile root = context.getFile();
boolean valid = false;
try
{
- if (file.isFile())
- {
- if (hasValidSuffix(file.getName()) == false || mountArchive(file) == false)
+ if(root.isFile()) {
+ if (shouldMount(root) == false || mountArchive(root) == false)
{
return false;
}
@@ -68,7 +67,7 @@
{
if (!valid)
{
- Automounter.cleanup(file);
+ Automounter.cleanup(root);
}
}
return valid;
@@ -84,6 +83,17 @@
protected abstract boolean doDetermineStructure(StructureContext context) throws DeploymentException;
/**
+ * Determine whether the {@link VirtualFile} has a name that matches this structure.
+ * Defaults to just checking the suffix.
+ *
+ * @param root the {@link VirtualFile} root to check
+ * @return true if the file name is valid for this {@link StructureDeployer}
+ */
+ protected boolean hasValidName(VirtualFile root) {
+ return hasValidSuffix(root.getName());
+ }
+
+ /**
* Template method for VFS archive structure deployers to correctly match file suffixes for their archive type.
*
* @param name the name of the file
@@ -92,13 +102,13 @@
protected abstract boolean hasValidSuffix(String name);
/**
- * Determine whether to mount the archive as an expanded file system.
- * Defaults to false. Should be overridden by children as needed.
+ * Determine whether to mount the archive.
*
- * @return
+ * @param virtualFile to check
+ * @return true if the {@link VirtualFile} should be mounted
*/
- protected boolean mountExpanded() {
- return false;
+ protected boolean shouldMount(VirtualFile virtualFile) {
+ return virtualFile.isFile() && hasValidName(virtualFile);
}
/**
@@ -112,10 +122,7 @@
{
try
{
- if(!mountExpanded())
- Automounter.mount(file);
- else
- Automounter.mountExpanded(file);
+ Automounter.mount(file);
}
catch (IOException e)
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -108,20 +108,4 @@
{
this.configuration = configuration;
}
-
- @Override
- protected void addClassPath(StructureContext structureContext, VirtualFile entry, boolean includeEntry,
- boolean includeRootManifestCP, ContextInfo context)
- {
- // Need to make sure the entry is mounted before it can be used for classpath data
- try
- {
- Automounter.mount(structureContext.getFile(), entry);
- }
- catch (IOException e)
- {
-
- }
- super.addClassPath(structureContext, entry, includeEntry, includeRootManifestCP, context);
- }
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/dir/GroupingStructure.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/dir/GroupingStructure.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/dir/GroupingStructure.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -33,6 +33,7 @@
import org.jboss.util.collection.CollectionsFactory;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
+import org.jboss.vfs.util.Automounter;
/**
* Similar to jar or directory structure,
@@ -103,7 +104,10 @@
List<VirtualFile> archives = libVF.getChildren(lf);
for (VirtualFile archive : archives)
+ {
+ Automounter.mount(file, archive);
addClassPath(structureContext, archive, true, true, context);
+ }
}
else
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -23,9 +23,14 @@
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.concurrent.Executors;
import org.jboss.deployers.spi.structure.ModificationType;
+import org.jboss.vfs.TempFileProvider;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
/**
* Modification actions.
@@ -41,6 +46,23 @@
return original;
}
};
+
+ private static final ModificationAction TEMP_ACTION = new ModificationAction()
+ {
+ public VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException
+ {
+ VirtualFile backup = Automounter.backup(original);
+ // TODO: This leaks a mount - fix it
+ VFS.mountTemp(original, getTempFileProvider(original.getName()));
+ VFSUtils.copyChildrenRecursive(backup, original);
+ return original;
+ }
+ };
+
+ private static TempFileProvider getTempFileProvider(String name) throws IOException
+ {
+ return TempFileProvider.create(name, Executors.newSingleThreadScheduledExecutor());
+ }
/**
* Get the modification action.
@@ -50,6 +72,8 @@
*/
public static ModificationAction getAction(ModificationType type)
{
+ if(ModificationType.TEMP.equals(type))
+ return TEMP_ACTION;
return ACTION;
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -32,6 +32,7 @@
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.Automounter;
import org.jboss.vfs.util.SuffixMatchFilter;
/**
@@ -123,12 +124,6 @@
return name.endsWith(".war");
}
- @Override
- protected boolean mountExpanded()
- {
- return true;
- }
-
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
@@ -208,8 +203,11 @@
// and the top level jars in WEB-INF/lib
if (archives != null)
{
- for (VirtualFile jar : archives)
+ for (VirtualFile jar : archives)
+ {
+ Automounter.mount(file, jar);
addClassPath(structureContext, jar, true, true, context);
+ }
}
else if (trace)
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -41,6 +41,7 @@
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
+import org.jboss.vfs.util.Automounter;
import org.jboss.vfs.util.SuffixMatchFilter;
import org.jboss.mcann.AnnotationRepository;
@@ -132,7 +133,10 @@
{
List<VirtualFile> archives = lib.getChildren(earLibFilter);
for (VirtualFile archive : archives)
+ {
+ Automounter.mount(file, archive);
addClassPath(structureContext, archive, true, true, context);
+ }
}
}
catch (IOException ignored)
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -88,26 +88,27 @@
public void testWAR() throws Exception
{
VirtualFile originalRoot = createDeploymentRoot("/synch/war", "simple.war");
+ // Capture the root file before it gets swapped for a temp
+ File rootFile = originalRoot.getPhysicalFile();
+
VFSDeploymentUnit deploymentUnit = assertDeploy(originalRoot);
try
{
VirtualFile tempRoot = deploymentUnit.getRoot();
StructureModificationChecker checker = createStructureModificationChecker();
assertFalse(checker.hasStructureBeenModified(originalRoot));
-
// add new file
- File rootFile = originalRoot.getPhysicalFile();
File newFile = newFile(rootFile, "newfile.txt");
try
{
assertFalse(tempRoot.getChild("newfile.txt").exists());
assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertNotNull(tempRoot.getChild("newfile.txt"));
+ assertTrue(tempRoot.getChild("newfile.txt").exists());
// try deleting this one now
assertTrue(newFile.delete());
assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertNull(tempRoot.getChild("newfile.txt"));
+ assertFalse(tempRoot.getChild("newfile.txt").exists());
}
finally
{
@@ -142,20 +143,19 @@
assertEquals(tempTimestamp, tempProps.getLastModified());
// add new file into WEB-INF
- VirtualFile webInfo = originalRoot.getChild("WEB-INF");
- File webInfFile = webInfo.getPhysicalFile();
+ File webInfFile = new File(rootFile, "WEB-INF");
File newWebInfFile = newFile(webInfFile, "newfile.txt");
try
{
- assertNull(tempRoot.getChild("WEB-INF/newfile.txt"));
+ assertFalse(tempRoot.getChild("WEB-INF/newfile.txt").exists());
assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertNotNull(tempRoot.getChild("WEB-INF/newfile.txt"));
+ assertTrue(tempRoot.getChild("WEB-INF/newfile.txt").exists());
assertFalse(checker.hasStructureBeenModified(originalRoot));
// try deleting this one now
assertTrue(newWebInfFile.delete());
assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertNull(tempRoot.getChild("WEB-INF/newfile.txt"));
+ assertFalse(tempRoot.getChild("WEB-INF/newfile.txt").exists());
}
finally
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/support/MockWarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/support/MockWarStructureDeployer.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/support/MockWarStructureDeployer.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -32,6 +32,7 @@
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.Automounter;
import org.jboss.vfs.util.SuffixMatchFilter;
/**
@@ -173,7 +174,7 @@
addClassPath(structureContext, file, false, true, context);
// Add WEB-INF/classes if present
- if (classes != null)
+ if (classes.exists())
addClassPath(structureContext, classes, true, false, context);
else if (trace)
log.trace("No WEB-INF/classes for: " + file.getPathName());
@@ -182,7 +183,10 @@
if (archives != null)
{
for (VirtualFile jar : archives)
+ {
+ Automounter.mount(file, jar);
addClassPath(structureContext, jar, true, true, context);
+ }
}
else if (trace)
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchWrapperModificationChecker.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchWrapperModificationChecker.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchWrapperModificationChecker.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -28,6 +28,7 @@
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.Automounter;
/**
* Synch wrapper modification checker.
@@ -86,15 +87,17 @@
{
boolean modified = delegate.hasStructureBeenModifed(root, deploymentContext);
// it was not modifed & we're actually temped
- if (modified == false && root != deploymentContext.getRoot())
+ if (modified == false && Automounter.hasBackup(root))
{
+ VirtualFile original = Automounter.getBackup(root);
+
// check for update or delete
- UpdateDeleteVisitor udVisitor = new UpdateDeleteVisitor(filter, tempAttributes, getCache(), synchAdapter, root);
- VirtualFile tempRoot = deploymentContext.getRoot();
- tempRoot.visit(udVisitor);
+ UpdateDeleteVisitor udVisitor = new UpdateDeleteVisitor(filter, tempAttributes, getCache(), synchAdapter, original, root);
+ //VirtualFile tempRoot = deploymentContext.getRoot();
+ root.visit(udVisitor);
// check for addition
- AddVisitor addVisitor = new AddVisitor(filter, originalAttributes, getCache(), synchAdapter, tempRoot, root.getPathName().length());
- root.visit(addVisitor);
+ AddVisitor addVisitor = new AddVisitor(filter, originalAttributes, getCache(), synchAdapter, root, original.getPathName().length());
+ original.visit(addVisitor);
}
return modified;
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/UpdateDeleteVisitor.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/UpdateDeleteVisitor.java 2009-12-30 22:39:34 UTC (rev 98956)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/UpdateDeleteVisitor.java 2009-12-30 22:48:50 UTC (rev 98957)
@@ -21,6 +21,7 @@
*/
package org.jboss.deployers.vfs.spi.structure.modified;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
@@ -33,20 +34,22 @@
public class UpdateDeleteVisitor extends SynchVisitor
{
private VirtualFile originalRoot;
+ private VirtualFile tmpRoot;
private String initialPath;
- public UpdateDeleteVisitor(VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile originalRoot)
+ public UpdateDeleteVisitor(VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile originalRoot, VirtualFile tmpRoot)
{
- this(null, attributes, cache, synchAdapter, originalRoot);
+ this(null, attributes, cache, synchAdapter, originalRoot, tmpRoot);
}
- public UpdateDeleteVisitor(VirtualFileFilter filter, VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile originalRoot)
+ public UpdateDeleteVisitor(VirtualFileFilter filter, VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile originalRoot, VirtualFile tmpRoot)
{
super(filter, attributes, cache, synchAdapter);
if (originalRoot == null)
throw new IllegalArgumentException("Null original root");
this.originalRoot = originalRoot;
+ this.tmpRoot = tmpRoot;
initialPath = originalRoot.getPathName();
if (initialPath.endsWith("/") == false)
initialPath += "/";
@@ -54,9 +57,8 @@
protected void doVisit(VirtualFile file) throws Exception
{
- String pathName = file.getPathName();
- String originalPathName = initialPath + pathName;
- VirtualFile child = originalRoot.getChild(pathName);
+ String originalPathName = VFSUtils.getRelativePathString(tmpRoot, file);
+ VirtualFile child = originalRoot.getChild(originalPathName);
if (! child.exists())
{
// original was deleted, try deleting the temp
More information about the jboss-cvs-commits
mailing list