[jboss-cvs] JBossAS SVN: r99626 - in projects/jboss-deployers/branches/vfs3: deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 19 19:22:24 EST 2010
Author: johnbailey
Date: 2010-01-19 19:22:24 -0500 (Tue, 19 Jan 2010)
New Revision: 99626
Removed:
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractSynchAdapter.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AddVisitor.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MergeSynchAdapter.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/OverrideSynchAdapter.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchAdapter.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchVisitor.java
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/test/java/org/jboss/test/deployers/vfs/structure/modified/test/AbstractSynchTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java
Modified:
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java
projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureModificationChecker.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/DefaultVFSDeploymentFactory.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/modify/ModificationActions.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
Log:
[JBAS-7361,JBAS-7362] - Updates to support VFS3 profileservice integration
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -85,6 +85,19 @@
super(safeVirtualFileName(root));
this.root = root;
}
+
+ /**
+ * Create a new VFSDeployment.
+ *
+ * @param name the deployment name
+ * @param root the root
+ * @throws IllegalArgumentException for a null root
+ */
+ public AbstractVFSDeployment(String name, VirtualFile root)
+ {
+ super(name);
+ this.root = root;
+ }
public VirtualFile getRoot()
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/DefaultVFSDeploymentFactory.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/DefaultVFSDeploymentFactory.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/DefaultVFSDeploymentFactory.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -43,4 +43,10 @@
{
return new AbstractVFSDeployment(root);
}
+
+ @Override
+ protected VFSDeployment newVFSDeployment(String name, VirtualFile root)
+ {
+ return new AbstractVFSDeployment(name, 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 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -28,6 +28,7 @@
import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.util.automount.Automounter;
+import org.jboss.vfs.util.automount.MountOption;
/**
* Abstract {@link StructureDeployer} used to help mount VFS archive based {@link StructureDeployer}s.
@@ -132,7 +133,7 @@
}
protected void performMount(VirtualFile file) throws IOException {
- Automounter.mount(file);
+ Automounter.mount(file, MountOption.COPY);
}
}
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 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -23,14 +23,9 @@
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.automount.Automounter;
/**
* Modification actions.
@@ -47,24 +42,6 @@
}
};
- /**
- * Temporary Hack to get the test running. This leaks a mount - TODO: fix it or remove the need to make copies of VFS locations.
- */
- private static final ModificationAction TEMP_ACTION = new ModificationAction()
- {
- public VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException
- {
- VirtualFile backup = Automounter.backup(original);
- 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.
@@ -74,8 +51,6 @@
*/
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/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/VFSStructureTestSuite.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -43,7 +43,6 @@
import org.jboss.test.deployers.vfs.structure.modified.test.DirRemovalModificationTestCase;
import org.jboss.test.deployers.vfs.structure.modified.test.MetaDataStructureModificationTestCase;
import org.jboss.test.deployers.vfs.structure.modified.test.MetaDataStructureModificationTreeCacheTestCase;
-import org.jboss.test.deployers.vfs.structure.modified.test.SynchModificationTestCase;
import org.jboss.test.deployers.vfs.structure.test.StructureDeployerContextClassLoaderTestCase;
import org.jboss.test.deployers.vfs.structure.test.TerminateStructureTestCase;
import org.jboss.test.deployers.vfs.structure.war.test.CombinedWARStructureUnitTestCase;
@@ -91,7 +90,6 @@
suite.addTest(EsbStructureUnitTestCase.suite());
suite.addTest(MetaDataStructureModificationTestCase.suite());
suite.addTest(MetaDataStructureModificationTreeCacheTestCase.suite());
- suite.addTest(SynchModificationTestCase.suite());
suite.addTest(DirRemovalModificationTestCase.suite());
return suite;
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/AbstractSynchTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/AbstractSynchTest.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/AbstractSynchTest.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.deployers.vfs.structure.modified.test;
-
-import org.jboss.deployers.structure.spi.main.MainDeployerInternals;
-import org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker;
-import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
-import org.jboss.deployers.vfs.spi.structure.modified.SynchAdapter;
-import org.jboss.deployers.vfs.spi.structure.modified.SynchWrapperModificationChecker;
-import org.jboss.test.deployers.BootstrapDeployersTest;
-import org.jboss.vfs.VirtualFileFilter;
-import org.jboss.vfs.VisitorAttributes;
-
-/**
- * AbstractSynchTest.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public abstract class AbstractSynchTest extends BootstrapDeployersTest
-{
- protected AbstractSynchTest(String name)
- {
- super(name);
- }
-
- protected StructureModificationChecker createStructureModificationChecker()
- {
- MainDeployerInternals mainDeployerInternals = getMainDeployerInternals();
- VirtualFileFilter filter = createFilter();
- VirtualFileFilter recurseFilter = createRecurseFilter();
- SynchAdapter synchAdapter = createSynchAdapter();
-
- MetaDataStructureModificationChecker mdsmc = new MetaDataStructureModificationChecker(mainDeployerInternals);
- mdsmc.setFilter(filter);
-
- SynchWrapperModificationChecker synch = new SynchWrapperModificationChecker(mdsmc, synchAdapter);
-
- VisitorAttributes attributes = new VisitorAttributes();
- attributes.setLeavesOnly(true);
- attributes.setRecurseFilter(recurseFilter);
-
- synch.setOriginalAttributes(attributes);
- synch.setTempAttributes(attributes);
-
- return synch;
- }
-
- protected abstract VirtualFileFilter createFilter();
-
- protected abstract VirtualFileFilter createRecurseFilter();
-
- protected abstract SynchAdapter createSynchAdapter();
-}
\ No newline at end of file
Deleted: 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 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,211 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.deployers.vfs.structure.modified.test;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.net.URL;
-
-import junit.framework.Test;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.modified.OverrideSynchAdapter;
-import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
-import org.jboss.deployers.vfs.spi.structure.modified.SynchAdapter;
-import org.jboss.test.deployers.vfs.structure.modified.support.XmlIncludeVirtualFileFilter;
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VirtualFileFilter;
-
-/**
- * Test file synch.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class SynchModificationTestCase extends AbstractSynchTest
-{
- public SynchModificationTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(SynchModificationTestCase.class);
- }
-
- protected VirtualFileFilter createFilter()
- {
- return new XmlIncludeVirtualFileFilter();
- }
-
- protected VirtualFileFilter createRecurseFilter()
- {
- return new VirtualFileFilter()
- {
- public boolean accepts(VirtualFile file)
- {
- try
- {
- URL url = file.toURL();
- String path = url.toExternalForm();
- // only wars, but not its classes
- return (path.contains(".war") && path.contains("/WEB-INF/classes") == false);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
- protected SynchAdapter createSynchAdapter()
- {
- return new OverrideSynchAdapter();
- }
-
- 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 newFile = newFile(rootFile, "newfile.txt");
- try
- {
- assertFalse(tempRoot.getChild("newfile.txt").exists());
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertTrue(tempRoot.getChild("newfile.txt").exists());
-
- // try deleting this one now
- assertTrue(newFile.delete());
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertFalse(tempRoot.getChild("newfile.txt").exists());
- }
- finally
- {
- if (newFile.exists())
- assertTrue(newFile.delete());
- }
-
- // update some file
- File updateFile = new File(rootFile, "test.jsp");
- assertTrue(updateFile.exists());
- assertTrue(updateFile.setLastModified(System.currentTimeMillis() + 1500l));
- VirtualFile testJsp = tempRoot.getChild("test.jsp");
- long tempTimestamp = testJsp.getLastModified();
- // Platform dependent precision for last modified, let's wait a minimum of 1 sec
- Thread.sleep(1500l);
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- long lastModified = testJsp.getLastModified();
- long diff = lastModified - tempTimestamp;
- assertTrue("Last modified diff is not bigger then 0, diff: " + diff, diff > 0);
-
- // update something outside recurse filter
- VirtualFile someProps = originalRoot.getChild("WEB-INF/classes/some.properties");
- assertNotNull(someProps);
- updateFile = someProps.getPhysicalFile();
- assertTrue(updateFile.exists());
- assertTrue(updateFile.setLastModified(System.currentTimeMillis() + 1500l));
- VirtualFile tempProps = tempRoot.getChild("WEB-INF/classes/some.properties");
- tempTimestamp = tempProps.getLastModified();
- // Platform dependent precision for last modified, let's wait a minimum of 1 sec
- Thread.sleep(1500l);
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertEquals(tempTimestamp, tempProps.getLastModified());
-
- // add new file into WEB-INF
- File webInfFile = new File(rootFile, "WEB-INF");
- File newWebInfFile = newFile(webInfFile, "newfile.txt");
- try
- {
- assertFalse(tempRoot.getChild("WEB-INF/newfile.txt").exists());
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertTrue(tempRoot.getChild("WEB-INF/newfile.txt").exists());
- assertFalse(checker.hasStructureBeenModified(originalRoot));
-
- // try deleting this one now
- assertTrue(newWebInfFile.delete());
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertFalse(tempRoot.getChild("WEB-INF/newfile.txt").exists());
- }
- finally
- {
- if (newWebInfFile.exists())
- assertTrue(newWebInfFile.delete());
- }
-
- // check we don't update for nothing
- @SuppressWarnings("deprecation")
- VirtualFile xhtml = tempRoot.getChild("test.xhtml");
- long xhtmlTimestamp = xhtml.getLastModified();
- // Platform dependent precision for last modified, let's wait a minimum of 1 sec
- Thread.sleep(1500l);
- assertFalse(checker.hasStructureBeenModified(originalRoot));
- assertEquals(xhtmlTimestamp, xhtml.getLastModified());
- }
- finally
- {
- undeploy(deploymentUnit);
- }
- }
-
- public void testEAR() throws Exception
- {
- VFSDeploymentUnit deploymentUnit = assertDeploy("/synch/ear", "simple.ear");
- try
- {
- VirtualFile root = deploymentUnit.getRoot();
- StructureModificationChecker checker = createStructureModificationChecker();
- assertFalse(checker.hasStructureBeenModified(root));
- }
- finally
- {
- undeploy(deploymentUnit);
- }
- }
-
- protected File newFile(File parent, String name) throws IOException
- {
- File newFile = new File(parent, name);
- FileOutputStream fos = new FileOutputStream(newFile);
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos));
- try
- {
- writer.write("sometext");
- return newFile;
- }
- finally
- {
- writer.close();
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -54,13 +54,36 @@
{
return VFSDeploymentBuilder.getInstance().newVFSDeployment(root);
}
+
+ /**
+ * Create a new VFS deployment with a specific name
+ *
+ * @param name deployment name
+ * @param root the root virtual file
+ * @return the deployment
+ * @throws IllegalArgumentException for a null root
+ */
+ public VFSDeployment createVFSDeployment(String name, VirtualFile root)
+ {
+ return VFSDeploymentBuilder.getInstance().newVFSDeployment(name, root);
+ }
/**
+ * Create a new VFS deployment with a specific name
+ *
+ * @param root the root virtual file
+ * @return the deployment
+ * @throws IllegalArgumentException for a null root
+ */
+ protected abstract VFSDeployment newVFSDeployment(VirtualFile root);
+
+ /**
* Create a new VFS deployment
*
+ * @param name deployment name
* @param root the root virtual file
* @return the deployment
* @throws IllegalArgumentException for a null root
*/
- protected abstract VFSDeployment newVFSDeployment(VirtualFile root);
+ protected abstract VFSDeployment newVFSDeployment(String name, VirtualFile root);
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -146,10 +146,36 @@
return (VFSDeploymentContext) deploymentContext;
}
+ public boolean hasStructureBeenModified(String name, VirtualFile root) throws IOException
+ {
+ return hasStructureBeenModified(root, getDeploymentContext(name));
+ }
+
public boolean hasStructureBeenModified(VirtualFile root) throws IOException
{
+ VFSDeploymentContext deploymentContext = null;
+ try
+ {
+ String name = root.toURI().toString();
+ deploymentContext = getDeploymentContext(name);
+ }
+ catch (URISyntaxException ignore)
+ {
+ }
+ if(deploymentContext == null)
+ {
+ log.trace("Falling back to root name: " + root);
+ deploymentContext = getDeploymentContext(root.getName());
+ }
+ return hasStructureBeenModified(root, deploymentContext);
+ }
+
+ protected boolean hasStructureBeenModified(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
+ {
if (root == null)
throw new IllegalArgumentException("Null root");
+ if (deploymentContext == null)
+ return false;
// skip vfs deployment context lookup accepted by filter
if (getRootFilter().accepts(root))
@@ -163,76 +189,8 @@
return result;
}
}
-
- VFSDeploymentContext deploymentContext;
- try
- {
- String name = root.toURI().toString();
- deploymentContext = getDeploymentContext(name);
- if (deploymentContext != null)
- return hasStructureBeenModified(deploymentContext, false);
- }
- catch (URISyntaxException ignore)
- {
- }
-
- log.trace("Falling back to root name: " + root);
- deploymentContext = getDeploymentContext(root.getName());
- if (deploymentContext != null)
- return hasStructureBeenModified(deploymentContext, false);
-
- return false;
- }
-
- public boolean hasStructureBeenModified(VFSDeployment deployment) throws IOException
- {
- if (deployment == null)
- throw new IllegalArgumentException("Null deployment");
-
- VFSDeploymentContext deploymentContext = getDeploymentContext(deployment.getName());
- return deploymentContext != null && hasStructureBeenModified(deploymentContext);
- }
-
- public boolean hasStructureBeenModified(VFSDeploymentContext deploymentContext) throws IOException
- {
- return hasStructureBeenModified(deploymentContext, true);
- }
-
- /**
- * Has structure been modified.
- *
- * @param deploymentContext the deployment context
- * @param checkRoot should we check root
- * @return true if modifed, false otherwise
- * @throws IOException for any error
- */
- protected boolean hasStructureBeenModified(VFSDeploymentContext deploymentContext, boolean checkRoot) throws IOException
- {
- Deployment deployment = deploymentContext.getDeployment();
- if (deployment == null || deployment instanceof VFSDeployment == false)
- {
- log.warn("Deployment is not VFS or not top level.");
- return false;
- }
-
- VFSDeployment vfsDeployment = VFSDeployment.class.cast(deployment);
- VirtualFile root = vfsDeployment.getRoot();
-
- boolean result = false;
- boolean skip = false; // skip futher check
-
- if (checkRoot && getRootFilter().accepts(root))
- {
- result = hasRootBeenModified(root);
- if (result || getRootFilter().checkRootOnly(root))
- skip = true;
- }
-
- if (skip == false)
- {
- result = hasStructureBeenModifed(root, deploymentContext);
- }
-
+
+ boolean result = hasDeploymentContextBeenModified(root, deploymentContext);
if (result)
{
getCache().invalidateCache(root);
@@ -247,10 +205,7 @@
* @return true if modified, false otherwise
* @throws IOException for any error
*/
- protected boolean hasRootBeenModified(VirtualFile root) throws IOException
- {
- throw new UnsupportedOperationException("Scheduled for removal");
- }
+ protected abstract boolean hasRootBeenModified(VirtualFile root) throws IOException;
/**
* Has structure been modified.
@@ -260,8 +215,9 @@
* @return true if modifed, false otherwise
* @throws IOException for any error
*/
- protected abstract boolean hasStructureBeenModifed(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException;
+ protected abstract boolean hasDeploymentContextBeenModified(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException;
+
public void addStructureRoot(VirtualFile root)
{
if (root == null)
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractSynchAdapter.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractSynchAdapter.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractSynchAdapter.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-import org.jboss.vfs.VFSUtils;
-import org.jboss.vfs.VirtualFile;
-
-/**
- * Abstract synch adapter.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public abstract class AbstractSynchAdapter implements SynchAdapter
-{
- /** The log */
- protected static Logger log = Logger.getLogger(AbstractSynchAdapter.class);
-
- public long add(VirtualFile fileToAdd, VirtualFile tempRoot, String pathToFile) throws IOException
- {
- try
- {
- URL realURL = VFSUtils.getPhysicalURL(tempRoot);
- File rootDir = new File(realURL.toURI());
- File newFile = new File(rootDir, pathToFile);
- return copy(fileToAdd, newFile);
- }
- catch (URISyntaxException e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- /**
- * Do copy.
- *
- * @param fileToAdd file to add
- * @param newFile new file location
- * @return new timestamp
- * @throws IOException for any error
- */
- protected static long copy(VirtualFile fileToAdd, File newFile) throws IOException
- {
- FileOutputStream out = new FileOutputStream(newFile);
- VFSUtils.copyStreamAndClose(fileToAdd.openStream(), out);
- return newFile.lastModified();
- }
-
- public boolean delete(VirtualFile fileToDelete) throws IOException
- {
- return fileToDelete.delete();
- }
-
- /**
- * Merge exception
- */
- static class MergeException extends IOException
- {
- /** The serialVersionUID */
- private static final long serialVersionUID = 5228888050899870372L;
-
- MergeException(VirtualFile dest, VirtualFile source, Exception cause)
- {
- super("Conflict merging files, dest: " + dest + ", source: " + source);
- initCause(cause);
- }
- }
-}
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AddVisitor.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AddVisitor.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AddVisitor.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VirtualFileFilter;
-import org.jboss.vfs.VisitorAttributes;
-
-/**
- * Synch on add file visitor.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class AddVisitor extends SynchVisitor
-{
- private VirtualFile tempRoot;
- private int initialPathLenght;
-
- public AddVisitor(VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile tempRoot, int initialPathLenght)
- {
- this(null, attributes, cache, synchAdapter, tempRoot, initialPathLenght);
- }
-
- public AddVisitor(VirtualFileFilter filter, VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter, VirtualFile tempRoot, int initialPathLenght)
- {
- super(filter, attributes, cache, synchAdapter);
- if (tempRoot == null)
- throw new IllegalArgumentException("Null temp root");
- if (initialPathLenght < 0)
- throw new IllegalArgumentException("Initial path length is negative: " + initialPathLenght);
-
- this.tempRoot = tempRoot;
- this.initialPathLenght = initialPathLenght;
- }
-
- public void doVisit(VirtualFile file) throws Exception
- {
- String originalPathName = file.getPathName();
- String pathName = originalPathName.substring(initialPathLenght);
- VirtualFile child = tempRoot.getChild(pathName);
- if (! child.exists())
- {
- // original was added
- long timestamp = getSynchAdapter().add(file, tempRoot, pathName);
- getCache().putCacheValue(file, timestamp);
- }
- }
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MergeSynchAdapter.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MergeSynchAdapter.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MergeSynchAdapter.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import java.io.IOException;
-
-import org.jboss.vfs.VirtualFile;
-
-/**
- * Merge synch adapter.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class MergeSynchAdapter extends AbstractSynchAdapter
-{
- public long update(VirtualFile fileToUpdate, VirtualFile modifiedFile) throws IOException
- {
- return merge(fileToUpdate, modifiedFile);
- }
-
- /**
- * Do merge changes.
- *
- * @param fileToOverride the file to override
- * @param modifiedFile the modifed file
- * @return new timestamp
- * @throws MergeException for possible merge conflict
- * @throws java.io.IOException for any error
- */
- static long merge(VirtualFile fileToOverride, VirtualFile modifiedFile) throws IOException
- {
- return 0; // TODO
- }
-}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/MetaDataStructureModificationChecker.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -79,7 +79,7 @@
}
}
- protected boolean hasStructureBeenModifed(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
+ protected boolean hasDeploymentContextBeenModified(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
{
StructureMetaData structureMetaData = deploymentContext.getTransientManagedObjects().getAttachment(StructureMetaData.class);
return hasStructureBeenModified(root, structureMetaData, null);
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/OverrideSynchAdapter.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/OverrideSynchAdapter.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/OverrideSynchAdapter.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VFSUtils;
-
-/**
- * Override synch adapter.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class OverrideSynchAdapter extends AbstractSynchAdapter
-{
- public long update(VirtualFile fileToUpdate, VirtualFile modifiedFile) throws IOException
- {
- return override(fileToUpdate, modifiedFile);
- }
-
- /**
- * Do override.
- *
- * @param fileToOverride the file to override
- * @param modifiedFile the modifed file
- * @return new timestamp
- * @throws IOException for any error
- */
- static long override(VirtualFile fileToOverride, VirtualFile modifiedFile) throws IOException
- {
- try
- {
- // get uri before we delete the file
- URI uri = VFSUtils.getVirtualURI(fileToOverride);
- if (fileToOverride.delete())
- {
- File newFile = new File(uri);
- return copy(modifiedFile, newFile);
- }
- else
- {
- log.warn("Could not delete previous file: " + fileToOverride + ", no change applied: " + modifiedFile);
- return fileToOverride.getLastModified();
- }
- }
- catch (URISyntaxException e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureModificationChecker.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/StructureModificationChecker.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -23,8 +23,6 @@
import java.io.IOException;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
import org.jboss.vfs.VirtualFile;
/**
@@ -44,20 +42,14 @@
boolean hasStructureBeenModified(VirtualFile root) throws IOException;
/**
- * Has structure been modified.
- *
- * @param deployment the vfs deployment
- * @return true if structure has been modified, false otherwise
- * @throws IOException for any error
+ * Has structure been modified. This method is used for cases when the DeploymentContext name is not
+ * guaranteed to be the root path.
+ *
+ * @param name context name
+ * @param root
+ * @return
+ * @throws IOException
*/
- boolean hasStructureBeenModified(VFSDeployment deployment) throws IOException;
+ boolean hasStructureBeenModified(String deploymentName, VirtualFile root) throws IOException;
- /**
- * Has structure been modified.
- *
- * @param deploymentContext the vfs deployment context
- * @return true if structure has been modified, false otherwise
- * @throws IOException for any error
- */
- boolean hasStructureBeenModified(VFSDeploymentContext deploymentContext) throws IOException;
}
\ No newline at end of file
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchAdapter.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchAdapter.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchAdapter.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import java.io.IOException;
-
-import org.jboss.vfs.VirtualFile;
-
-/**
- * Synch adapter.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public interface SynchAdapter
-{
- /**
- * Add new file to temp.
- *
- * @param fileToAdd file to add
- * @param tempRoot temp root
- * @param pathToFile the path to file
- * @return addition timestamp
- * @throws IOException for any error
- */
- long add(VirtualFile fileToAdd, VirtualFile tempRoot, String pathToFile) throws IOException;
-
- /**
- * Update file.
- *
- * @param fileToUpdate file to update
- * @param modifiedFile the modified file
- * @return the update timestamp
- * @throws IOException for any error
- */
- long update(VirtualFile fileToUpdate, VirtualFile modifiedFile) throws IOException;
-
- /**
- * Add new file to temp.
- *
- * @param fileToDelete file to delete
- * @throws IOException for any error
- * @return true if deleted, false otherwise
- */
- boolean delete(VirtualFile fileToDelete) throws IOException;
-}
\ No newline at end of file
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchVisitor.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchVisitor.java 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchVisitor.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import org.jboss.logging.Logger;
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VirtualFileFilter;
-import org.jboss.vfs.VisitorAttributes;
-import org.jboss.vfs.VirtualFileVisitor;
-
-/**
- * Synch file visitor.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public abstract class SynchVisitor implements VirtualFileVisitor
-{
- protected final Logger log = Logger.getLogger(getClass());
-
- private VirtualFileFilter filter;
- private VisitorAttributes attributes;
- private StructureCache<Long> cache;
- private SynchAdapter synchAdapter;
-
- protected SynchVisitor(VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter)
- {
- this(null, attributes, cache, synchAdapter);
- }
-
- protected SynchVisitor(VirtualFileFilter filter, VisitorAttributes attributes, StructureCache<Long> cache, SynchAdapter synchAdapter)
- {
- if (cache == null)
- throw new IllegalArgumentException("Null cache");
- if (synchAdapter == null)
- throw new IllegalArgumentException("Null synch adapter");
-
- this.filter = filter;
- if (attributes != null)
- this.attributes = attributes;
- else
- this.attributes = VisitorAttributes.RECURSE_LEAVES_ONLY;
- this.cache = cache;
- this.synchAdapter = synchAdapter;
- }
-
- public VisitorAttributes getAttributes()
- {
- return attributes;
- }
-
- public void visit(VirtualFile file)
- {
- try
- {
- if (filter == null || filter.accepts(file))
- {
- doVisit(file);
- }
- }
- catch (Exception e)
- {
- log.warn("Exception synching file: " + file + ", cause: " + e);
- }
- }
-
- /**
- * Visit a virtual file
- *
- * @param file the virtual file being visited
- * @throws Exception for any error
- */
- protected abstract void doVisit(VirtualFile file) throws Exception;
-
- /**
- * Get cache.
- *
- * @return the cache
- */
- protected StructureCache<Long> getCache()
- {
- return cache;
- }
-
- /**
- * Get synch adapter.
- *
- * @return the syncj adapter
- */
- protected SynchAdapter getSynchAdapter()
- {
- return synchAdapter;
- }
-}
\ No newline at end of file
Deleted: 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 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/SynchWrapperModificationChecker.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,144 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployers.vfs.spi.structure.modified;
-
-import java.io.IOException;
-
-import org.jboss.deployers.structure.spi.main.MainDeployerInternals;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.VirtualFileFilter;
-import org.jboss.vfs.VisitorAttributes;
-import org.jboss.vfs.util.automount.Automounter;
-
-/**
- * Synch wrapper modification checker.
- *
- * If there is no modification, we check if the deployment is perhaps a temp,
- * only then checking if we need to update some resource.
- * e.g. some .jsp or .xhtml file for JBossWeb to pick up the change
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class SynchWrapperModificationChecker extends AbstractStructureModificationChecker<Long>
-{
- /** The true checker delegate */
- private AbstractStructureModificationChecker<Long> delegate;
-
- /** The filter */
- private VirtualFileFilter filter;
-
- /** The synch adapter */
- private SynchAdapter synchAdapter;
-
- /** the visitor attributes */
- private VisitorAttributes originalAttributes;
- private VisitorAttributes tempAttributes;
-
- public SynchWrapperModificationChecker(AbstractStructureModificationChecker<Long> delegate, SynchAdapter synchAdapter)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate");
- if (synchAdapter == null)
- throw new IllegalArgumentException("Null synch adapter");
-
- this.delegate = delegate;
- this.synchAdapter = synchAdapter;
- }
-
- @Override
- protected StructureCache<Long> getCache()
- {
- return delegate.getCache();
- }
-
- @Override
- protected MainDeployerInternals getMainDeployerInternals()
- {
- return delegate.getMainDeployerInternals();
- }
-
- @Override
- protected boolean hasRootBeenModified(VirtualFile root) throws IOException
- {
- return delegate.hasRootBeenModified(root);
- }
-
- protected boolean hasStructureBeenModifed(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
- {
- boolean modified = delegate.hasStructureBeenModifed(root, deploymentContext);
- // it was not modifed & we're actually temped
- if (modified == false && Automounter.hasBackup(root))
- {
- VirtualFile original = Automounter.getBackup(root);
-
- // check for update or delete
- 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, root, original.getPathName().length());
- original.visit(addVisitor);
- }
- return modified;
- }
-
- public void addStructureRoot(VirtualFile root)
- {
- delegate.addStructureRoot(root);
- }
-
- public void removeStructureRoot(VirtualFile root)
- {
- delegate.removeStructureRoot(root);
- }
-
- /**
- * Set the filter.
- *
- * @param filter the filter
- */
- public void setFilter(VirtualFileFilter filter)
- {
- this.filter = filter;
- }
-
- /**
- * Set original visitor attributes.
- *
- * @param attributes the attributes
- */
- public void setOriginalAttributes(VisitorAttributes attributes)
- {
- this.originalAttributes = attributes;
- }
-
- /**
- * Set temp visitor attributes.
- *
- * @param attributes the attributes
- */
- public void setTempAttributes(VisitorAttributes attributes)
- {
- this.tempAttributes = attributes;
- }
-}
\ No newline at end of file
Deleted: 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 2010-01-20 00:07:35 UTC (rev 99625)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/UpdateDeleteVisitor.java 2010-01-20 00:22:24 UTC (rev 99626)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-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;
-
-/**
- * Synch on update and delete file visitor.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-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, VirtualFile tmpRoot)
- {
- this(null, attributes, cache, synchAdapter, originalRoot, tmpRoot);
- }
-
- 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 += "/";
- }
-
- protected void doVisit(VirtualFile file) throws Exception
- {
- String originalPathName = VFSUtils.getRelativePathString(tmpRoot, file);
- VirtualFile child = originalRoot.getChild(originalPathName);
- if (! child.exists())
- {
- // original was deleted, try deleting the temp
- if (getSynchAdapter().delete(file))
- {
- getCache().removeCache(originalRoot, originalPathName);
- }
- }
- else
- {
- Long previous = getCache().getCacheValue(child);
- long lastModified = child.getLastModified();
-
- boolean updateCache = false;
- if (previous == null)
- {
- updateCache = true;
- }
- else if (lastModified > previous)
- {
- lastModified = getSynchAdapter().update(file, child);
- updateCache = true;
- }
-
- if (updateCache)
- {
- getCache().putCacheValue(child, lastModified);
- }
- }
- }
-}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list