[jboss-cvs] JBossAS SVN: r96420 - in projects/jboss-deployers/branches/Branch_2_0: deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer and 13 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 16 05:52:25 EST 2009


Author: alesj
Date: 2009-11-16 05:52:24 -0500 (Mon, 16 Nov 2009)
New Revision: 96420

Added:
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/NIMDeployer.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/NameIgnoreMechanismTestCase.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt
Removed:
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt
Modified:
   projects/jboss-deployers/branches/Branch_2_0/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/Deployers.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java
   projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/FeedbackDeployer.java
   projects/jboss-deployers/branches/Branch_2_0/pom.xml
Log:
Port changes from trunk; JBDEPLOY-218, JBDEPLOY-220.

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-client-spi/src/main/java/org/jboss/deployers/spi/deployer/DeploymentStages.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -25,6 +25,7 @@
  * The Standard DeploymentStages.
  * 
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
 public interface DeploymentStages
@@ -32,8 +33,11 @@
    /** The not installed stage - nothing is done here */
    DeploymentStage NOT_INSTALLED = new DeploymentStage("Not Installed");
 
+   /** The pre parse stage - where pre parsing stuff can be prepared; altDD, ignore, ... */
+   DeploymentStage PRE_PARSE = new DeploymentStage("PreParse", NOT_INSTALLED);
+
    /** The parse stage - where metadata is read */
-   DeploymentStage PARSE = new DeploymentStage("Parse", NOT_INSTALLED);
+   DeploymentStage PARSE = new DeploymentStage("Parse", PRE_PARSE);
 
    /** The post parse stage - where metadata can be fixed up */
    DeploymentStage POST_PARSE = new DeploymentStage("PostParse", PARSE);

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -158,6 +158,7 @@
 
       // Add the standard stages
       addDeploymentStage(DeploymentStages.NOT_INSTALLED);
+      addDeploymentStage(DeploymentStages.PRE_PARSE);
       addDeploymentStage(DeploymentStages.PARSE);
       addDeploymentStage(DeploymentStages.POST_PARSE);
       addDeploymentStage(DeploymentStages.PRE_DESCRIBE);

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -47,7 +47,6 @@
 import org.jboss.deployers.structure.spi.DeploymentContext;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.StructuralDeployers;
-import org.jboss.deployers.structure.spi.helpers.RevertedDeploymentContextComparator;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ManagedDeployment;
@@ -103,7 +102,6 @@
 
    /** The top deployment context comparator */
    private Comparator<DeploymentContext> comparator;
-   private Comparator<DeploymentContext> reverted;
 
    /** The re-deployments */
    private final Map<String, Deployment> toRedeploy = Collections.synchronizedMap(new LinkedHashMap<String, Deployment>());
@@ -119,7 +117,6 @@
          throw new IllegalArgumentException("Null comparator");
 
       this.comparator = comparator;
-      this.reverted = new RevertedDeploymentContextComparator(comparator);
    }
 
    /**
@@ -669,9 +666,9 @@
             // Undeploy in reverse order (subdeployments first)
             undeployContexts = new ArrayList<DeploymentContext>(undeploy);
             undeploy.clear();
-            Collections.reverse(undeployContexts);
-            if (reverted != null)
-               Collections.sort(undeployContexts, reverted);
+            // order as it was deployed, Deployers::process will revert it 
+            if (comparator != null)
+               Collections.sort(undeployContexts, comparator);
          }
 
          if (undeployContexts != null)

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/Deployers.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/Deployers.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/Deployers.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -49,6 +49,8 @@
    
    /**
     * Process deployment
+    *
+    * Note: the undeploy list must be undeployed in reverse order.
     * 
     * @param deploy the deployments to deploy
     * @param undeploy the deployments to remove

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -26,6 +26,7 @@
 
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.matchers.JarExtensionProvider;
+import org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 
 /**
@@ -37,8 +38,7 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
-public abstract class AbstractParsingDeployerWithOutput<T> extends AbstractParsingDeployer
-   implements JarExtensionProvider
+public abstract class AbstractParsingDeployerWithOutput<T> extends AbstractParsingDeployer implements JarExtensionProvider
 {
    /** The metadata file names */
    private Set<String> names;
@@ -371,6 +371,19 @@
    }
 
    /**
+    * Ignore name.
+    *
+    * @param unit the unit
+    * @param name the name
+    * @return true if we should ignore the name, false otherwise
+    */
+   protected boolean ignoreName(DeploymentUnit unit, String name)
+   {
+      NameIgnoreMechanism mechanism = unit.getAttachment(NameIgnoreMechanism.class);
+      return mechanism != null && mechanism.ignore(unit, name);
+   }
+
+   /**
     * Parse an exact file name
     * 
     * @param unit the unit

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java (from rev 95567, projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,47 @@
+/*
+ * 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.spi.deployer.helpers;
+
+import java.util.Collection;
+
+import org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Ignore a collection of names.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CollectionNameIgnoreMechanism implements NameIgnoreMechanism
+{
+   private Collection<String> ignored;
+
+   public CollectionNameIgnoreMechanism(Collection<String> ignored)
+   {
+      this.ignored = ignored;
+   }
+
+   public boolean ignore(DeploymentUnit unit, String name)
+   {
+      return ignored != null && ignored.contains(name);
+   }
+}

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java (from rev 95567, projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,64 @@
+/*
+ * 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.spi.deployer.helpers;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+import org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Ignore a pattern.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class PatternNameIgnoreMechanism implements NameIgnoreMechanism
+{
+   private Pattern ignored;
+   private boolean match;
+
+   public PatternNameIgnoreMechanism(String regexp)
+   {
+      if (regexp == null)
+         throw new IllegalArgumentException("Null regexp");
+
+      ignored = Pattern.compile(regexp);
+   }
+
+   public boolean ignore(DeploymentUnit unit, String name)
+   {
+      Matcher matcher = ignored.matcher(name);
+      return (match) ? matcher.matches() : matcher.find();
+   }
+
+   /**
+    * Do we use match.
+    * by default find is used.
+    *
+    * @param match the match flag
+    */
+   public void setMatch(boolean match)
+   {
+      this.match = match;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java (from rev 95567, projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,41 @@
+/*
+ * 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.spi.deployer.matchers;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Name ignore mechanism.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface NameIgnoreMechanism
+{
+   /**
+    * Do we ignore this file name.
+    *
+    * @param unit the deployment unit
+    * @param name the name to check
+    * @return true if we should ignore this name, false otherwise
+    */
+   boolean ignore(DeploymentUnit unit, String name);
+}

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/VFSMatchersTestSuite.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -26,6 +26,7 @@
 import junit.textui.TestRunner;
 import org.jboss.test.deployers.vfs.matchers.test.FileMatchersTestCase;
 import org.jboss.test.deployers.vfs.matchers.test.JarExtensionsTestCase;
+import org.jboss.test.deployers.vfs.matchers.test.NameIgnoreMechanismTestCase;
 
 /**
  * Matchers test suite.
@@ -45,6 +46,7 @@
 
       suite.addTest(FileMatchersTestCase.suite());
       suite.addTest(JarExtensionsTestCase.suite());
+      suite.addTest(NameIgnoreMechanismTestCase.suite());
 
       return suite;
    }

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/FeedbackDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/FeedbackDeployer.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/FeedbackDeployer.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -23,6 +23,7 @@
 
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.List;
 
 import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -33,11 +34,11 @@
  * 
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public abstract class FeedbackDeployer extends AbstractVFSParsingDeployer<Object>
+public class FeedbackDeployer extends AbstractVFSParsingDeployer<Object>
 {
    private Set<String> files = new TreeSet<String>();
 
-   protected FeedbackDeployer()
+   public FeedbackDeployer()
    {
       super(Object.class);
    }
@@ -52,4 +53,14 @@
    {
       return files;
    }
+
+   @Override
+   protected Object mergeFiles(VFSDeploymentUnit unit, Object root, List<VirtualFile> files, Set<String> missingFiles) throws Exception
+   {
+      for (VirtualFile file : files)
+      {
+         parse(unit, file, root);
+      }
+      return null;
+   }
 }

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/NIMDeployer.java (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/NIMDeployer.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/NIMDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/support/NIMDeployer.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,47 @@
+/*
+ * 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.matchers.support;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.spi.deployer.matchers.NameIgnoreMechanism;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class NIMDeployer extends AbstractDeployer
+{
+   private NameIgnoreMechanism mechanism;
+
+   public NIMDeployer(NameIgnoreMechanism mechanism)
+   {
+      setStage(DeploymentStages.PRE_PARSE);
+      this.mechanism = mechanism;
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      unit.addAttachment(NameIgnoreMechanism.class, mechanism);
+   }
+}

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/NameIgnoreMechanismTestCase.java (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/NameIgnoreMechanismTestCase.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/NameIgnoreMechanismTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/matchers/test/NameIgnoreMechanismTestCase.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.matchers.test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.deployer.helpers.CollectionNameIgnoreMechanism;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.test.deployers.BaseDeployersVFSTest;
+import org.jboss.test.deployers.vfs.matchers.support.FeedbackDeployer;
+import org.jboss.test.deployers.vfs.matchers.support.NIMDeployer;
+
+/**
+ * Name ignore mechanism tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NameIgnoreMechanismTestCase extends BaseDeployersVFSTest
+{
+   public NameIgnoreMechanismTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(NameIgnoreMechanismTestCase.class);
+   }
+
+   protected void testNameIgnoreMechanism(FeedbackDeployer fbd, int size) throws Throwable
+   {
+      NIMDeployer nimd = new NIMDeployer(new CollectionNameIgnoreMechanism(Collections.singleton("fst.txt")));
+
+      DeployerClient main = createMainDeployer(fbd, nimd);
+      addStructureDeployer(main, new JARStructure());
+
+      Deployment deployment = createDeployment("/matchers", "ignore");
+      main.deploy(deployment);
+
+      assertEquals(size, fbd.getFiles().size());
+      assertFalse(fbd.getFiles().contains("fst.txt"));
+   }
+
+   public void testSingleNameNoSuffix() throws Throwable
+   {
+      FeedbackDeployer fbd1 = new FeedbackDeployer();
+      fbd1.setName("empty.txt");
+      FeedbackDeployer fbd2 = new FeedbackDeployer();
+      fbd2.setName("fst.txt");
+      NIMDeployer nimd = new NIMDeployer(new CollectionNameIgnoreMechanism(Collections.singleton("fst.txt")));
+
+      DeployerClient main = createMainDeployer(fbd1, fbd2, nimd);
+      addStructureDeployer(main, new JARStructure());
+
+      Deployment deployment = createDeployment("/matchers", "ignore");
+      main.deploy(deployment);
+
+      assertFalse(fbd1.getFiles().isEmpty());
+      assertEmpty(fbd2.getFiles());
+   }
+
+   public void testMultipleNamesNoSuffix() throws Throwable
+   {
+      FeedbackDeployer fbd = new FeedbackDeployer();
+      Set<String> names = new HashSet<String>(Arrays.asList("empty.txt", "fst.txt", "snd.txt"));
+      fbd.setNames(names);
+
+      testNameIgnoreMechanism(fbd, 2);
+   }
+
+   public void testNoNameJustSuffix() throws Throwable
+   {
+      FeedbackDeployer fbd = new FeedbackDeployer();
+      fbd.setSuffix(".txt");
+      fbd.setAllowMultipleFiles(true);
+
+      testNameIgnoreMechanism(fbd, 2);
+   }
+
+   public void testNamesWithSuffix() throws Throwable
+   {
+      FeedbackDeployer fbd = new FeedbackDeployer();
+      Set<String> names = new HashSet<String>(Arrays.asList("empty.txt", "fst.txt", "snd.txt"));
+      fbd.setNames(names);
+      fbd.setSuffix(".tmp");
+
+      testNameIgnoreMechanism(fbd, 3);
+   }
+}
\ No newline at end of file

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore)

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF)

Deleted: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt	2009-10-26 16:28:45 UTC (rev 95573)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -1 +0,0 @@
-Empty.

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/empty.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1 @@
+Empty.

Deleted: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt	2009-10-26 16:28:45 UTC (rev 95573)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -1 +0,0 @@
-First.

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/fst.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1 @@
+First.

Deleted: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp	2009-10-26 16:28:45 UTC (rev 95573)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp	2009-11-16 10:52:24 UTC (rev 96420)
@@ -1 +0,0 @@
-Tmp file.

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/qwert.tmp	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1 @@
+Tmp file.

Deleted: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt	2009-10-26 16:28:45 UTC (rev 95573)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -1,2 +0,0 @@
-Second.
-

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt (from rev 95573, projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/test/resources/matchers/ignore/META-INF/snd.txt	2009-11-16 10:52:24 UTC (rev 96420)
@@ -0,0 +1,2 @@
+Second.
+

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -178,14 +178,14 @@
    @Override
    protected T parse(DeploymentUnit unit, String name, T root) throws Exception
    {
+      if (ignoreName(unit, name))
+         return null;
+
       // Try to find the metadata
       VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
 
       VirtualFile file = getMetadataFile(vfsDeploymentUnit, getOutput(), name, true);
-      if(file == null)
-            return null;
-
-      return parseAndInit(vfsDeploymentUnit, file, root);
+      return (file != null) ? parseAndInit(vfsDeploymentUnit, file, root) : null;
    }
 
    protected T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception
@@ -197,17 +197,25 @@
 
       List<VirtualFile> files = new ArrayList<VirtualFile>();
       Set<String> missingFiles = new HashSet<String>();
+      Set<String> ignoredFiles = new HashSet<String>();
 
       for (String name : names)
       {
-         VirtualFile file = getMetadataFile(vfsDeploymentUnit, matchFileToClass(unit, name), name, true);
-         if (file != null)
-            files.add(file);
+         if (ignoreName(unit, name))
+         {
+            ignoredFiles.add(name);
+         }
          else
-            missingFiles.add(name);
+         {
+            VirtualFile file = getMetadataFile(vfsDeploymentUnit, matchFileToClass(unit, name), name, true);
+            if (file != null)
+               files.add(file);
+            else
+               missingFiles.add(name);
+         }
       }
 
-      if (missingFiles.size() == names.size())
+      if (missingFiles.size() + ignoredFiles.size() == names.size())
          return null;
 
       return mergeFiles(vfsDeploymentUnit, root, files, missingFiles);
@@ -220,14 +228,14 @@
       // The infrastructure will only check leafs anyway so no need to check here
       if (name == null && isIncludeDeploymentFile())
          name = unit.getName();
-      
+
       // Try to find the metadata
       VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
 
       // let's check altDD first
       VirtualFile file = getMetadataFile(vfsDeploymentUnit, getOutput(), name, false);
       if (file != null)
-         return parseAndInit(vfsDeploymentUnit, file, root);
+         return parseAndInit(vfsDeploymentUnit, file, root, true);
 
       // try all name+suffix matches
       List<VirtualFile> files = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
@@ -236,7 +244,7 @@
          case 0 :
             return null;
          case 1 :
-            return parseAndInit(vfsDeploymentUnit, files.get(0), root);
+            return parseAndInit(vfsDeploymentUnit, files.get(0), root, true);
          default :
             return handleMultipleFiles(vfsDeploymentUnit, root, files);
       }
@@ -253,6 +261,24 @@
     */
    protected T parseAndInit(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
    {
+      return parseAndInit(unit, file, root, false);
+   }
+
+   /**
+    * Parse the file, initialize the result if exists.
+    *
+    * @param unit the deployment unit
+    * @param file the file
+    * @param root the root
+    * @param checkIgnore do we check for ignored names
+    * @return parsed result
+    * @throws Exception for any error
+    */
+   protected T parseAndInit(VFSDeploymentUnit unit, VirtualFile file, T root, boolean checkIgnore) throws Exception
+   {
+      if (checkIgnore && ignoreName(unit, file.getName()))
+         return null;
+
       T result = parse(unit, file, root);
       if (result != null)
          init(unit, result, file);
@@ -268,26 +294,34 @@
 
       List<VirtualFile> files = new ArrayList<VirtualFile>();
       Set<String> missingFiles = new HashSet<String>();
+      Set<String> ignoredFiles = new HashSet<String>();
 
       for (String name : names)
       {
-         // try finding altDD file
-         VirtualFile file = getMetadataFile(vfsDeploymentUnit, matchFileToClass(unit, name), name, false);
-         if (file == null)
+         if (ignoreName(unit, name))
          {
-            List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
-            if (matched != null && matched.isEmpty() == false)
-               files.addAll(matched);
-            else
-               missingFiles.add(name);
+            ignoredFiles.add(name);
          }
          else
          {
-            files.add(file);
+            // try finding altDD file
+            VirtualFile file = getMetadataFile(vfsDeploymentUnit, matchFileToClass(unit, name), name, false);
+            if (file == null)
+            {
+               List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
+               if (matched != null && matched.isEmpty() == false)
+                  files.addAll(matched);
+               else
+                  missingFiles.add(name);
+            }
+            else
+            {
+               files.add(file);
+            }
          }
       }
 
-      if (missingFiles.size() == names.size())
+      if (missingFiles.size() + ignoredFiles.size() == names.size())
          return null;
 
       return mergeFiles(vfsDeploymentUnit, root, files, missingFiles);
@@ -325,11 +359,14 @@
 
       for (VirtualFile file : files)
       {
-         T result = parse(unit, file, root);
-         if (result != null)
+         if (ignoreName(unit, file.getName()) == false)
          {
-            init(unit, result, file);
-            unit.addAttachment(file.toURL().toString(), result, getOutput());
+            T result = parse(unit, file, root);
+            if (result != null)
+            {
+               init(unit, result, file);
+               unit.addAttachment(file.toURL().toString(), result, getOutput());
+            }
          }
       }
 

Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractStructureModificationChecker.java	2009-11-16 10:52:24 UTC (rev 96420)
@@ -69,7 +69,7 @@
     *
     * Use DefaultRootFilter if no explicit config
     *
-    * @return
+    * @return root filter
     */
    protected ModificationCheckerFilter getRootFilter()
    {

Modified: projects/jboss-deployers/branches/Branch_2_0/pom.xml
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/pom.xml	2009-11-16 09:56:17 UTC (rev 96419)
+++ projects/jboss-deployers/branches/Branch_2_0/pom.xml	2009-11-16 10:52:24 UTC (rev 96420)
@@ -25,16 +25,16 @@
     <version.jboss.man>2.1.1.CR1</version.jboss.man>
     <version.jboss.mdr>2.0.2.GA</version.jboss.mdr>
     <version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
-    <version.jboss.classloader>2.0.8-SNAPSHOT</version.jboss.classloader>
+    <version.jboss.classloader>2.0.8.GA</version.jboss.classloader>
     <version.jboss.classloading.spi>5.1.0.SP1</version.jboss.classloading.spi>
-    <version.jboss.common.core>2.2.14.GA</version.jboss.common.core>
+    <version.jboss.common.core>2.2.16.GA</version.jboss.common.core>
     <version.jboss.logging.spi>2.0.5.GA</version.jboss.logging.spi>
     <version.jboss.logging.log4j>2.0.5.GA</version.jboss.logging.log4j>
-    <version.jbossxb>2.0.2-SNAPSHOT</version.jbossxb>
+    <version.jbossxb>2.0.2.Beta1</version.jbossxb>
     <version.jboss.aop>2.1.0.CR3</version.jboss.aop>
     <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
-    <version.javassist>3.10.0.GA</version.javassist>
+    <version.javassist>3.11.0.GA</version.javassist>
     <version.stax.staxapi>1.0</version.stax.staxapi>
   </properties>
 




More information about the jboss-cvs-commits mailing list