[jboss-cvs] JBossAS SVN: r95567 - in projects/jboss-deployers/trunk: deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 26 10:59:43 EDT 2009
Author: alesj
Date: 2009-10-26 10:59:42 -0400 (Mon, 26 Oct 2009)
New Revision: 95567
Added:
projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java
projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java
projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/DominoOrdering.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerFlowUnitTestCase.java
projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
Log:
[JBDEPLOY-220]; ignore files before parsing.
TODO - tests.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/DominoOrdering.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/DominoOrdering.java 2009-10-26 14:33:16 UTC (rev 95566)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/DominoOrdering.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -78,7 +78,7 @@
// pass-through deployers
if (oneHead.match(twoHead) && oneTail.match(twoTail))
{
- // lets try do do more exact match
+ // lets try to do more exact match
// although we should aviod singe dimension checks
// which are already part of match() check
// in order not to break comparator comparison
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerFlowUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerFlowUnitTestCase.java 2009-10-26 14:33:16 UTC (rev 95566)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/test/DeployerFlowUnitTestCase.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -1024,76 +1024,4 @@
main.removeDeployment(deployment);
main.process();
}
-
- public void testDeployersOrderTest2() throws Exception
- {
- }
-
- public void x() throws Exception
- {
- DeployerClient main = createMainDeployer();
-
- // "1", "2", "3", "4" and "6" are provided by deployers in different stage
- TestFlowDeployer deployer1 = new TestFlowDeployer( "WSEJBAdapterDeployer" );
- deployer1.setInputs( "1", "2", "3", "4" );
- deployer1.setOutputs( "5" );
- addDeployer(main, deployer1);
-
- TestFlowDeployer deployer2 = new TestFlowDeployer( "WSTypeDeployer" );
- deployer2.setInputs( "5", "4", "6" ); // note 6 is both input and output
- deployer2.setOutputs( "6", "7" );
- addDeployer(main, deployer2);
-
- TestFlowDeployer deployer3 = new TestFlowDeployer( "WSDeploymentDeployer" );
- deployer3.setInputs( "6", "7" ); // note 6 is both input and output
- deployer3.setOutputs( "8", "6" );
- addDeployer( main, deployer3 );
-
- TestFlowDeployer deployer4 = new TestFlowDeployer( "WSDeploymentAspectDeployer" );
- deployer4.setInputs( "8", "6" ); // note 6 is both input and output
- deployer4.setOutputs( "9", "6", "0" );
- addDeployer( main, deployer4 ); // why are we getting cycle detected exception here?
-
- Deployment deployment = createSimpleDeployment( "deployersOrderTest" );
-
- main.addDeployment(deployment);
- main.process();
-
- assertEquals(1, deployer1.getDeployOrder());
- assertEquals(2, deployer2.getDeployOrder());
- assertEquals(3, deployer3.getDeployOrder());
- assertEquals(4, deployer4.getDeployOrder());
- assertEquals(-1, deployer1.getUndeployOrder());
- assertEquals(-1, deployer2.getUndeployOrder());
- assertEquals(-1, deployer3.getUndeployOrder());
- assertEquals(-1, deployer4.getUndeployOrder());
-
- main.removeDeployment(deployment);
- main.process();
-
- assertEquals(1, deployer1.getDeployOrder());
- assertEquals(2, deployer2.getDeployOrder());
- assertEquals(3, deployer3.getDeployOrder());
- assertEquals(4, deployer4.getDeployOrder());
- assertEquals(8, deployer1.getUndeployOrder());
- assertEquals(7, deployer2.getUndeployOrder());
- assertEquals(6, deployer3.getUndeployOrder());
- assertEquals(5, deployer4.getUndeployOrder());
-
- main.addDeployment(deployment);
- main.process();
-
- assertEquals(9, deployer1.getDeployOrder());
- assertEquals(10, deployer2.getDeployOrder());
- assertEquals(11, deployer3.getDeployOrder());
- assertEquals(12, deployer4.getDeployOrder());
- assertEquals(8, deployer1.getUndeployOrder());
- assertEquals(7, deployer2.getUndeployOrder());
- assertEquals(6, deployer3.getUndeployOrder());
- assertEquals(5, deployer4.getUndeployOrder());
-
- main.removeDeployment(deployment);
- main.process();
- }
-
}
Modified: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2009-10-26 14:33:16 UTC (rev 95566)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -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
Added: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/CollectionNameIgnoreMechanism.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -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);
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/PatternNameIgnoreMechanism.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -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
Added: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/matchers/NameIgnoreMechanism.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -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/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-10-26 14:33:16 UTC (rev 95566)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-10-26 14:59:42 UTC (rev 95567)
@@ -190,14 +190,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
@@ -209,17 +209,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);
@@ -232,14 +240,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);
@@ -248,7 +256,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);
}
@@ -265,6 +273,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);
@@ -280,26 +306,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);
@@ -337,11 +371,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());
+ }
}
}
More information about the jboss-cvs-commits
mailing list