[jboss-cvs] JBossAS SVN: r71486 - in projects/jboss-deployers/trunk: deployers-vfs/src/tests/org/jboss/test/deployers and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 31 12:34:37 EDT 2008


Author: alesj
Date: 2008-03-31 12:34:37 -0400 (Mon, 31 Mar 2008)
New Revision: 71486

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/MergeDeployerTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/TestBeanMergeDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/AbstractDeployerUnitTestCase.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/BeanMergeUnitTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/DeployersVFSTestSuite.java
Log:
[JBDEPLOY-4] hande merge of files into single piece of metadata.

Modified: projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java	2008-03-31 15:22:59 UTC (rev 71485)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -22,7 +22,9 @@
 package org.jboss.deployers.spi.deployer.helpers;
 
 import java.io.Serializable;
+import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
@@ -37,14 +39,15 @@
  * 
  * @param <T> the type of output
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
 public abstract class AbstractParsingDeployerWithOutput<T> extends AbstractParsingDeployer
    implements ManagedObjectCreator, JarExtensionProvider
 {
-   /** The metadata file name */
-   private String name;
+   /** The metadata file names */
+   private Set<String> names;
    
    /** The suffix */
    private String suffix;
@@ -85,7 +88,13 @@
     */
    public String getName()
    {
-      return name;
+      if (names == null || names.isEmpty())
+         return null;
+
+      if (names.size() > 1)
+         throw new IllegalArgumentException("Use getNames since more than one name is set: " + names);
+
+      return names.iterator().next();
    }
 
    /**
@@ -95,10 +104,33 @@
     */
    public void setName(String name)
    {
-      this.name = name;
+      if (names != null)
+         throw new IllegalArgumentException("Names already set.");
+
+      this.names = Collections.singleton(name);
    }
 
    /**
+    * Get the names.
+    *
+    * @return the names.
+    */
+   public Set<String> getNames()
+   {
+      return names;
+   }
+
+   /**
+    * Set the names.
+    *
+    * @param names the names.
+    */
+   public void setNames(Set<String> names)
+   {
+      this.names = names;
+   }
+
+   /**
     * Get the suffix.
     * 
     * @return the suffix.
@@ -183,7 +215,11 @@
    {
       if (accepts(unit) == false)
          return;
-      createMetaData(unit, name, suffix);
+
+      if (hasSingleName())
+         createMetaData(unit, getName(), suffix);
+      else
+         createMetaData(unit, names, suffix);
    }
 
    /**
@@ -224,6 +260,19 @@
    }
    
    /**
+    * Create some meta data. Calls createMetaData(unit, name, suffix, getDeploymentType().getName()).
+    *
+    * @param unit the deployment unit
+    * @param names the names
+    * @param suffix the suffix
+    * @throws DeploymentException for any error
+    */
+   protected void createMetaData(DeploymentUnit unit, Set<String> names, String suffix) throws DeploymentException
+   {
+      createMetaData(unit, names, suffix, getOutput().getName());
+   }
+
+   /**
     * Create some meta data. Invokes parse(unit, name, suffix) if there is not already a
     * metadata
     * 
@@ -235,6 +284,31 @@
     */
    protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
    {
+      createMetaData(unit, Collections.singleton(name), suffix, key);
+   }
+
+   /**
+    * Do we have a single name set.
+    *
+    * @return true is just one matching name is set
+    */
+   private boolean hasSingleName()
+   {
+      return names == null || names.size() == 1;
+   }
+
+   /**
+    * Create some meta data. Invokes parse(unit, name, suffix) if there is not already a
+    * metadata
+    *
+    * @param unit the deployment unit
+    * @param names the names
+    * @param suffix the suffix
+    * @param key the key into the managed objects
+    * @throws DeploymentException for any error
+    */
+   protected void createMetaData(DeploymentUnit unit, Set<String> names, String suffix, String key) throws DeploymentException
+   {
       // First see whether it already exists
       T result = getMetaData(unit, key);
       if (result != null && allowsReparse() == false)
@@ -244,9 +318,19 @@
       try
       {
          if (suffix == null)
-            result = parse(unit, name, result);
+         {
+            if (hasSingleName())
+               result = parse(unit, getName(), result);
+            else
+               result = parse(unit, names, result);
+         }
          else
-            result = parse(unit, name, suffix, result);
+         {
+            if (hasSingleName())
+               result = parse(unit, getName(), suffix, result);
+            else
+               result = parse(unit, names, suffix, result);
+         }
       }
       catch (Exception e)
       {
@@ -273,6 +357,17 @@
    protected abstract T parse(DeploymentUnit unit, String name, T root) throws Exception;
    
    /**
+    * Parse an multiple exact file names
+    *
+    * @param unit the unit
+    * @param names the exact names to match
+    * @param root - possibly null pre-existing root
+    * @return the metadata or null if it doesn't exist
+    * @throws Exception for any error
+    */
+   protected abstract T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception;
+
+   /**
     * Parse an exact file name or look for a suffix
     * 
     * @param unit the unit
@@ -285,6 +380,18 @@
    protected abstract T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception;
 
    /**
+    * Parse exact file names or look for a suffix
+    *
+    * @param unit the unit
+    * @param names the exact names to match
+    * @param suffix the suffix to match
+    * @param root - possibly null pre-existing root
+    * @return the metadata or null if it doesn't exist
+    * @throws Exception for any error
+    */
+   protected abstract T parse(DeploymentUnit unit, Set<String> names, String suffix, T root) throws Exception;
+
+   /**
     * Build managed object.
     *
     * @param unit the deployment unit

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/DeployersVFSTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/DeployersVFSTestSuite.java	2008-03-31 15:22:59 UTC (rev 71485)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/DeployersVFSTestSuite.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -29,6 +29,7 @@
 import org.jboss.test.deployers.vfs.deployer.bean.BeanDeployerTestSuite;
 import org.jboss.test.deployers.vfs.deployer.jaxp.VFSDeployerTestSuite;
 import org.jboss.test.deployers.vfs.deployer.nonmetadata.NonMetadataDeployersTestSuite;
+import org.jboss.test.deployers.vfs.deployer.merge.MergeDeployerTestSuite;
 import org.jboss.test.deployers.vfs.deploymentfactory.VFSDeploymentFactoryTestSuite;
 import org.jboss.test.deployers.vfs.metadata.VFSMetaDataTestSuite;
 import org.jboss.test.deployers.vfs.structure.VFSStructureTestSuite;
@@ -65,6 +66,7 @@
       suite.addTest(ClassLoaderTestSuite.suite());
       suite.addTest(VFSMatchersTestSuite.suite());
       suite.addTest(JBossXBDeployersTestSuite.suite());
+      suite.addTest(MergeDeployerTestSuite.suite());
 
       return suite;
    }

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/MergeDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/MergeDeployerTestSuite.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/MergeDeployerTestSuite.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -0,0 +1,49 @@
+/*
+* 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.deployer.merge;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.deployers.vfs.deployer.merge.test.BeanMergeUnitTestCase;
+
+/**
+ * Merge deployers tests.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MergeDeployerTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("VFS Merge Deployer Tests");
+
+      suite.addTest(BeanMergeUnitTestCase.suite());
+
+      return suite;
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/TestBeanMergeDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/TestBeanMergeDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/TestBeanMergeDeployer.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -0,0 +1,64 @@
+/*
+* 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.deployer.merge.support;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestBeanMergeDeployer extends SchemaResolverDeployer<KernelDeployment>
+{
+   public TestBeanMergeDeployer()
+   {
+      super(KernelDeployment.class);
+      setNames(new HashSet<String>(Arrays.asList("first-beans.xml", "snd-beans.xml")));
+   }
+
+   protected KernelDeployment mergeFiles(VFSDeploymentUnit unit, KernelDeployment root, Set<VirtualFile> files, Set<String> missingFiles) throws Exception
+   {
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      for (VirtualFile file : files)
+      {
+         KernelDeployment kd = parse(unit, file, root);
+         List<BeanMetaDataFactory> beans = deployment.getBeanFactories();
+         if (beans == null)
+         {
+            beans = new ArrayList<BeanMetaDataFactory>();
+            deployment.setBeanFactories(beans);
+         }
+         beans.addAll(kd.getBeanFactories());
+      }
+      return deployment;
+   }
+}

Copied: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/AbstractDeployerUnitTestCase.java (from rev 71479, projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/bean/test/AbstractDeployerUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/AbstractDeployerUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/AbstractDeployerUnitTestCase.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -0,0 +1,68 @@
+/*
+* 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.deployer.merge.test;
+
+import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.deployers.vfs.deployer.jaxp.DeployerClientTestCase;
+
+/**
+ * AbstractDeployerUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractDeployerUnitTestCase extends DeployerClientTestCase
+{
+   protected KernelController controller;
+
+   public AbstractDeployerUnitTestCase(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      try
+      {
+         BasicBootstrap bootstrap = new BasicBootstrap();
+         bootstrap.run();
+         Kernel kernel = bootstrap.getKernel();
+         controller = kernel.getController();
+
+         main = createMainDeployer();
+         addStructureDeployer(main, new JARStructure());
+         addStructureDeployer(main, new FileStructure());
+
+         addDeployers(kernel);
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   protected abstract void addDeployers(Kernel kernel);
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/BeanMergeUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/BeanMergeUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/test/BeanMergeUnitTestCase.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -0,0 +1,70 @@
+/*
+* 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.deployer.merge.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer;
+import org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.kernel.Kernel;
+import org.jboss.test.deployers.vfs.deployer.merge.support.TestBeanMergeDeployer;
+
+/**
+ * BeanMergeUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanMergeUnitTestCase extends AbstractDeployerUnitTestCase
+{
+   public static Test suite()
+   {
+      return new TestSuite(BeanMergeUnitTestCase.class);
+   }
+
+   public BeanMergeUnitTestCase(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   protected void addDeployers(Kernel kernel)
+   {
+      TestBeanMergeDeployer beanDeployer = new TestBeanMergeDeployer();
+      KernelDeploymentDeployer kernelDeploymentDeployer = new KernelDeploymentDeployer();
+      BeanMetaDataDeployer beanMetaDataDeployer = new BeanMetaDataDeployer(kernel);
+      addDeployer(main, beanDeployer);
+      addDeployer(main, kernelDeploymentDeployer);
+      addDeployer(main, beanMetaDataDeployer);
+   }
+
+   public void testMultipleMatchingFiles() throws Exception
+   {
+      VFSDeployment context = createDeployment("/bean", "multiple/test.jar");
+      assertDeploy(context);
+      assertNotNull(controller.getInstalledContext("Test1"));
+      assertNotNull(controller.getInstalledContext("Test2"));
+
+      assertUndeploy(context);
+      assertNull(controller.getContext("Test2", null));
+      assertNull(controller.getContext("Test1", null));
+   }
+}

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2008-03-31 15:22:59 UTC (rev 71485)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java	2008-03-31 16:34:37 UTC (rev 71486)
@@ -22,6 +22,8 @@
 package org.jboss.deployers.vfs.spi.deployer;
 
 import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
 import java.io.InputStream;
 import java.io.IOException;
 
@@ -60,7 +62,7 @@
       String fileName = file.getName();
       String suffix = getSuffix();
       if (suffix == null)
-         return fileName.equals(getName());
+         return getNames() != null && getNames().contains(fileName);
       else
          return fileName.endsWith(suffix);
    }
@@ -124,6 +126,31 @@
       return result;
    }
 
+   protected T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception
+   {
+      if (names == null || names.isEmpty())
+         throw new IllegalArgumentException("Null or empty names.");
+
+      VFSDeploymentUnit  vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+
+      Set<VirtualFile> files = new HashSet<VirtualFile>();
+      Set<String> missingFiles = new HashSet<String>();
+
+      for (String name : names)
+      {
+         VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name);
+         if (file != null)
+            files.add(file);
+         else
+            missingFiles.add(name);
+      }
+
+      if (missingFiles.size() == names.size())
+         return null;
+
+      return mergeFiles(vfsDeploymentUnit, root, files, missingFiles);
+   }
+
    @Override
    protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception
    {
@@ -155,7 +182,48 @@
       }
    }
 
+   protected T parse(DeploymentUnit unit, Set<String> names, String suffix, T root) throws Exception
+   {
+      if (names == null || names.isEmpty())
+         throw new IllegalArgumentException("Null or empty names.");
+
+      VFSDeploymentUnit  vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+
+      Set<VirtualFile> files = new HashSet<VirtualFile>();
+      Set<String> missingFiles = new HashSet<String>();
+
+      for (String name : names)
+      {
+         List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
+         if (matched != null && matched.isEmpty() == false)
+            files.addAll(matched);
+         else
+            missingFiles.add(name);
+      }
+
+      if (missingFiles.size() == names.size())
+         return null;
+
+      return mergeFiles(vfsDeploymentUnit, root, files, missingFiles);
+   }
+
+
    /**
+    * Merge files into one piece of metatdata
+    *
+    * @param unit the unit
+    * @param root possibly null pre-existing root
+    * @param files matching meta files
+    * @param missingFiles file names that are missing matching file
+    * @return merged metadata
+    * @throws Exception for any error
+    */
+   protected T mergeFiles(VFSDeploymentUnit unit, T root, Set<VirtualFile> files, Set<String> missingFiles) throws Exception
+   {
+      return null;
+   }
+
+   /**
     * Handle multiple files.
     *
     * @param unit the vfs deployment unit




More information about the jboss-cvs-commits mailing list