[Jboss-cvs] JBossAS SVN: r56753 - in projects/microcontainer/trunk/deployers: . src/main/org/jboss/deployers/plugins src/main/org/jboss/deployers/plugins/attachments src/main/org/jboss/deployers/plugins/deployer src/main/org/jboss/deployers/plugins/deployers src/main/org/jboss/deployers/plugins/deployers/helpers src/main/org/jboss/deployers/plugins/deployers/kernel src/main/org/jboss/deployers/plugins/deployment src/main/org/jboss/deployers/plugins/structure src/main/org/jboss/deployers/spi src/main/org/jboss/deployers/spi/attachments src/main/org/jboss/deployers/spi/deployer src/main/org/jboss/deployers/spi/structure src/resources/tests src/resources/tests/bean src/resources/tests/bean/toplevel src/resources/tests/bean/toplevel/test.jar src/resources/tests/bean/toplevel/test.jar/META-INF src/resources/tests/metadata src/resources/tests/metadata/toplevel src/resources/tests/metadata/toplevel/exact src/resources/tests/metadata/toplevel/metadata.jar src/resources/tests/metadata/! toplevel/metadata.jar/META-INF src/resources/tests/metadata/toplevel/partial src/tests/org/jboss/test/deployers src/tests/org/jboss/test/deployers/attachments src/tests/org/jboss/test/deployers/attachments/test src/tests/org/jboss/test/deployers/bean src/tests/org/jboss/test/deployers/bean/support src/tests/org/jboss/test/deployers/bean/test src/tests/org/jboss/test/deployers/deployer src/tests/org/jboss/test/deployers/metadata src/tests/org/jboss/test/deployers/metadata/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 12 05:36:56 EDT 2006


Author: adrian at jboss.org
Date: 2006-09-12 05:36:30 -0400 (Tue, 12 Sep 2006)
New Revision: 56753

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AbstractAttachments.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AttachmentsImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractRealDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/BeanDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/KernelDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/MetaDataMatchFilter.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/attachments/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/attachments/Attachments.java
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/my-beans.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/META-INF/my-beans.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/exact/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/exact/jboss-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata-nometainf.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/1-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/2-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/partial/
   projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/partial/mydb-ds.xml
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentHierarchyUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitPredeterminedManagedObjectsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientAttachmentsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientManagedObjectsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/ExpectedAttachments.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/PredeterminedManagedObjectsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientAttachmentsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientManagedObjectsUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/Simple.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/TestBeanDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/BeanDeployerUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/KernelDeployerUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/test/MetaDataUnitTestCase.java
Modified:
   projects/microcontainer/trunk/deployers/.classpath
   projects/microcontainer/trunk/deployers/build-test.xml
   projects/microcontainer/trunk/deployers/build.xml
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java
Log:
[JBMICROCONT-5] - Deployer attachments, metadata tests and some basic deployer
infrastructure, including the BeanDeployer.

Modified: projects/microcontainer/trunk/deployers/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers/.classpath	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/.classpath	2006-09-12 09:36:30 UTC (rev 56753)
@@ -9,5 +9,8 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/container"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/kernel"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/dependency"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: projects/microcontainer/trunk/deployers/build-test.xml
===================================================================
--- projects/microcontainer/trunk/deployers/build-test.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/build-test.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -2,6 +2,7 @@
 <!DOCTYPE project [
    <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
    <!ENTITY libraries  SYSTEM "../thirdparty/libraries.ent">
+   <!ENTITY modules SYSTEM "../tools/etc/buildmagic/modules.ent">
    <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
 ]>
 
@@ -68,6 +69,7 @@
     <!-- The combined library classpath -->
     <path id="library.classpath">
       <path refid="jboss.common.classpath"/>
+      <path refid="jboss.jbossxb.classpath"/>
       <path refid="jboss.container.classpath"/>
       <path refid="junit.junit.classpath"/>
       <path refid="apache.log4j.classpath"/>
@@ -78,6 +80,8 @@
     <!-- Modules -->
     <!-- ======= -->
 
+    &modules;
+
 <!-- this -->
 <property name="jboss.this.root" value="${module.root}/output"/>
 <property name="jboss.this.lib" value="${jboss.this.root}/lib"/>
@@ -87,17 +91,12 @@
       <exclude name="${jar.prefix}.jar"/>
    </fileset>
 </path>
-<!-- container -->
-<property name="jboss.container.root" value="${project.root}/container"/>
-<property name="jboss.container.lib" value="${jboss.container.root}/output/lib"/>
-<path id="jboss.container.classpath">
-   <fileset dir="${jboss.container.lib}">
-      <include name="jboss-container.jar"/>
-   </fileset>
-</path>
 
     <!-- The combined dependant module classpath -->
     <path id="dependentmodule.classpath">
+      <path refid="jboss.container.classpath"/>
+      <path refid="jboss.dependency.classpath"/>
+      <path refid="jboss.kernel.classpath"/>
       <path refid="jboss.this.classpath"/>
     </path>
 

Modified: projects/microcontainer/trunk/deployers/build.xml
===================================================================
--- projects/microcontainer/trunk/deployers/build.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/build.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -2,6 +2,7 @@
 <!DOCTYPE project [
    <!ENTITY buildmagic SYSTEM "../tools/etc/buildmagic/buildmagic.ent">
    <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+   <!ENTITY modules SYSTEM "../tools/etc/buildmagic/modules.ent">
    <!ENTITY targets SYSTEM "../tools/etc/buildmagic/targets.ent">
 ]>
 
@@ -63,23 +64,20 @@
     <!-- ========= -->
 
     &libraries;
-<!-- container -->
-<property name="jboss.container.root" value="${project.root}/container"/>
-<property name="jboss.container.lib" value="${jboss.container.root}/output/lib"/>
-<path id="jboss.container.classpath">
-   <fileset dir="${jboss.container.lib}">
-      <include name="jboss-container.jar"/>
-   </fileset>
-</path>
 
     <!-- The combined library classpath -->
     <path id="library.classpath">
       <path refid="jboss.common.classpath"/>
-      <path refid="jboss.container.classpath"/>
+      <path refid="jboss.jbossxb.classpath"/>
     </path>
 
+    &modules;
+
     <!-- The combined dependant module classpath -->
     <path id="dependentmodule.classpath">
+      <path refid="jboss.container.classpath"/>
+      <path refid="jboss.dependency.classpath"/>
+      <path refid="jboss.kernel.classpath"/>
     </path>
      
     <!-- ===== -->

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AbstractAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AbstractAttachments.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AbstractAttachments.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -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.deployers.plugins.attachments;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * AbstractAttachments.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractAttachments implements Attachments
+{
+   public <T> T addAttachment(String name, T attachment, Class<T> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      Object result = addAttachment(name, attachment);
+      if (result == null)
+         return null;
+      return expectedType.cast(result);
+   }
+
+   public <T> T addAttachment(Class<T> type, T attachment)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+      return addAttachment(type.getName(), attachment, type);
+   }
+
+   public <T> T getAttachment(String name, Class<T> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      Object result = getAttachment(name);
+      if (result == null)
+         return null;
+      return expectedType.cast(result);
+   }
+
+   public <T> T getAttachment(Class<T> type)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+      return getAttachment(type.getName(), type);
+   }
+
+   public boolean isAttachmentPresent(String name, Class<?> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      Object result = getAttachment(name);
+      if (result == null)
+         return false;
+      try
+      {
+         expectedType.cast(result);
+      }
+      catch (ClassCastException e)
+      {
+         return false;
+      }
+      return true;
+   }
+
+   public boolean isAttachmentPresent(Class<?> type)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+      return isAttachmentPresent(type.getName(), type);
+   }
+
+   public <T> T removeAttachment(String name, Class<T> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      Object result = removeAttachment(name);
+      if (result == null)
+         return null;
+      return expectedType.cast(result);
+   }
+
+   public <T> T removeAttachment(Class<T> type)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+      return removeAttachment(type.getName(), type);
+   }
+
+   public void clear()
+   {
+      throw new UnsupportedOperationException("You cannot clear attachments here.");
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AttachmentsImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AttachmentsImpl.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/attachments/AttachmentsImpl.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,78 @@
+/*
+* 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.deployers.plugins.attachments;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Attachments implementation
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AttachmentsImpl extends AbstractAttachments
+{
+   /** The attachments */
+   private Map<String, Object> attachments = new ConcurrentHashMap<String, Object>();
+
+   public Map<String, Object> getAttachments()
+   {
+      return Collections.unmodifiableMap(attachments);
+   }
+
+   public Object addAttachment(String name, Object attachment)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (attachment == null)
+         throw new IllegalArgumentException("Null attachment");
+      return attachments.put(name, attachment);
+   }
+
+   public Object getAttachment(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      return attachments.get(name);
+   }
+
+   public boolean isAttachmentPresent(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      return attachments.containsKey(name);
+   }
+
+   public Object removeAttachment(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      return attachments.remove(name);
+   }
+
+   public void clear()
+   {
+      attachments.clear();
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -26,10 +26,8 @@
 import org.jboss.logging.Logger;
 
 /**
- * AbstractDeployer.<p>
+ * AbstractDeployer.
  * 
- * We don't care about the order by default.
- * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -21,6 +21,13 @@
 */
 package org.jboss.deployers.plugins.deployer;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.plugins.attachments.AbstractAttachments;
+import org.jboss.deployers.spi.attachments.Attachments;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.virtual.VirtualFile;
@@ -34,7 +41,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public class AbstractDeploymentUnit implements DeploymentUnit
+public class AbstractDeploymentUnit extends AbstractAttachments implements DeploymentUnit
 {
    /** The deployment context */
    private DeploymentContext deploymentContext;
@@ -68,4 +75,52 @@
    {
       return deploymentContext.getMetaDataFile(name);
    }
+
+   public List<VirtualFile> getMetaDataFiles(String name, String suffix)
+   {
+      return deploymentContext.getMetaDataFiles(name, suffix);
+   }
+
+   public Map<String, Object> getAttachments()
+   {
+      HashMap<String, Object> result = new HashMap<String, Object>(deploymentContext.getTransientAttachments().getAttachments());
+      result.putAll(deploymentContext.getTransientManagedObjects().getAttachments());
+      result.putAll(deploymentContext.getPredeterminedManagedObjects().getAttachments());
+      return Collections.unmodifiableMap(result);
+   }
+
+   public Object addAttachment(String name, Object attachment)
+   {
+      return deploymentContext.getTransientAttachments().addAttachment(name, attachment);
+   }
+
+   public Object getAttachment(String name)
+   {
+      Object result = deploymentContext.getPredeterminedManagedObjects().getAttachment(name);
+      if (result != null)
+         return result;
+      result = deploymentContext.getTransientManagedObjects().getAttachment(name);
+      if (result != null)
+         return result;
+      return deploymentContext.getTransientAttachments().getAttachment(name);
+   }
+
+   public boolean isAttachmentPresent(String name)
+   {
+      if (deploymentContext.getPredeterminedManagedObjects().isAttachmentPresent(name))
+         return true;
+      if (deploymentContext.getTransientManagedObjects().isAttachmentPresent(name))
+         return true;
+      return deploymentContext.getTransientAttachments().isAttachmentPresent(name);
+   }
+
+   public Object removeAttachment(String name)
+   {
+      return deploymentContext.getTransientAttachments().removeAttachment(name);
+   }
+
+   public Attachments getTransientManagedObjects()
+   {
+      return deploymentContext.getTransientManagedObjects();
+   }
 }

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -82,9 +82,9 @@
 
       try
       {
-         log.debug("Preparing deployment: " + unit.getName());
+         log.trace("Preparing deployment: " + unit.getName());
          deployer.prepareDeploy(unit);
-         log.debug("Prepared deployment:  " + unit.getName());
+         log.trace("Prepared deployment:  " + unit.getName());
       }
       catch (Throwable t)
       {
@@ -100,11 +100,11 @@
 
       try
       {
-         // TODO log.debug("Prepare undeployment: " + unit.getName());
-         log.debug("Undeploying: " + unit.getName());
+         // TODO log.trace("Prepare undeployment: " + unit.getName());
+         log.trace("Undeploying: " + unit.getName());
          deployer.prepareUndeploy(unit);
-         // TODO log.debug("Prepared undeployment:  " + unit.getName());
-         log.debug("Undeployed:  " + unit.getName());
+         // TODO log.trace("Prepared undeployment:  " + unit.getName());
+         log.trace("Undeployed:  " + unit.getName());
       }
       catch (Throwable t)
       {
@@ -122,9 +122,9 @@
 
       try
       {
-         log.debug("Handing off from=" + from.getName() + " to=" + to.getName());
+         log.trace("Handing off from=" + from.getName() + " to=" + to.getName());
          deployer.handoff(from, to);
-         log.debug("Handed off from=" + from.getName() + " to=" + to.getName());
+         log.trace("Handed off from=" + from.getName() + " to=" + to.getName());
       }
       catch (Throwable t)
       {
@@ -141,10 +141,10 @@
       try
       {
          // TODO log.debug("Commiting deployment: " + unit.getName());
-         log.debug("Deploying: " + unit.getName());
+         log.trace("Deploying: " + unit.getName());
          deployer.commitDeploy(unit);
          // TODO log.debug("Commited deployment:  " + unit.getName());
-         log.debug("Deployed:  " + unit.getName());
+         log.trace("Deployed:  " + unit.getName());
       }
       catch (Throwable t)
       {
@@ -162,9 +162,9 @@
 
       try
       {
-         log.debug("Commiting undeployment: " + unit.getName());
+         log.trace("Commiting undeployment: " + unit.getName());
          deployer.commitUndeploy(unit);
-         log.debug("Commited undeployment:  " + unit.getName());
+         log.trace("Commited undeployment:  " + unit.getName());
       }
       catch (Throwable t)
       {

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,194 @@
+/*
+* 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.deployers.plugins.deployers.helpers;
+
+import java.util.List;
+
+import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * AbstractParsingDeployer.
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractParsingDeployer<T> extends AbstractSimpleDeployer
+{
+   /** The expected type */
+   private final Class<T> expectedType;
+   
+   /**
+    * Create a new AbstractParsingDeployer.
+    * 
+    * @param expectedType the expected type
+    * @throws IllegalArgumentException if the expected type is null
+    */
+   protected AbstractParsingDeployer(Class<T> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      this.expectedType = expectedType;
+   }
+   
+   /**
+    * Get the expected type
+    * 
+    * @return the expected type
+    */
+   protected Class<T> getExpectedType()
+   {
+      return expectedType;
+   }
+   
+   /**
+    * Get some meta data
+    * 
+    * @param unit the deployment unit
+    * @param key the key into the managed objects
+    * @return the metadata or null if it doesn't exist
+    */
+   protected T getMetaData(DeploymentUnit unit, String key)
+   {
+      return unit.getAttachment(key, expectedType);
+   }
+   
+   /**
+    * Create some meta data
+    * 
+    * @param unit the deployment unit
+    * @param name the name
+    * @param suffix the suffix
+    * @throws DeploymentException for any error
+    */
+   protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+   {
+      createMetaData(unit, name, suffix, expectedType.getName());
+   }
+   
+   /**
+    * Create some meta data
+    * 
+    * @param unit the deployment unit
+    * @param name the name
+    * @param suffix the suffix
+    * @param key the key into the managed objects
+    * @throws DeploymentException for any error
+    */
+   protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
+   {
+      // First see whether it already exists
+      T result = getMetaData(unit, key);
+      if (result != null)
+         return;
+
+      // Create it
+      try
+      {
+         if (suffix == null)
+            result = parse(unit, name);
+         else
+            result = parse(unit, name, suffix);
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e);
+      }
+      
+      // Doesn't exist
+      if (result == null)
+         return;
+      
+      // Register it
+      unit.getTransientManagedObjects().addAttachment(key, result, expectedType);
+   }
+
+   /**
+    * Parse an exact file name
+    * 
+    * @param unit the unit
+    * @param name the exact name to match
+    * @return the metadata or null if it doesn't exist
+    * @throws Exception for any error
+    */
+   protected T parse(DeploymentUnit unit, String name) throws Exception
+   {
+      // Try to find the metadata
+      VirtualFile file = unit.getMetaDataFile(name);
+      if (file == null)
+         return null;
+      
+      T result = parse(unit, file);
+      init(unit, result, file);
+      return result;
+   }
+   
+   /**
+    * Parse an exact file name
+    * 
+    * @param unit the unit
+    * @param name the exact name to match
+    * @param suffix the suffix to match
+    * @return the metadata or null if it doesn't exist
+    * @throws Exception for any error
+    */
+   protected T parse(DeploymentUnit unit, String name, String suffix) throws Exception
+   {
+      // Try to find the metadata
+      List<VirtualFile> files = unit.getMetaDataFiles(name, suffix);
+      if (files.size() == 0)
+         return null;
+      
+      // TODO remove this limitation
+      if (files.size() > 1)
+         throw new DeploymentException("Only one file is allowed, found=" + files);
+
+      VirtualFile file = files.get(0);
+      
+      T result = parse(unit, file);
+      init(unit, result, file);
+      return result;
+   }
+   
+   /**
+    * Parse a deployment
+    * 
+    * @param unit the deployment unit
+    * @param file the metadata file
+    * @return the metadata
+    * @throws Exception for any error
+    */
+   protected abstract T parse(DeploymentUnit unit, VirtualFile file) throws Exception;
+   
+   /**
+    * Initialise the metadata
+    * 
+    * @param unit the unit
+    * @param metaData the metadata
+    * @param file the metadata file
+    * @throws Exception for any error
+    */
+   protected abstract void init(DeploymentUnit unit, T metaData, VirtualFile file) throws Exception;
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractRealDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractRealDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,77 @@
+/*
+* 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.deployers.plugins.deployers.helpers;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * AbstractRealDeployer.
+ * 
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractRealDeployer<T> extends AbstractSimpleDeployer
+{
+   /** The expected type */
+   private Class<T> expectedType;
+
+   /**
+    * Create a new AbstractRealDeployer.
+    * 
+    * @param expectedType the expected type
+    * @throws IllegalArgumentException if the expected type is null
+    */
+   public AbstractRealDeployer(Class<T> expectedType)
+   {
+      if (expectedType == null)
+         throw new IllegalArgumentException("Null expectedType");
+      this.expectedType = expectedType;
+   }
+   
+   /**
+    * Get all the metadata for the expected type
+    * 
+    * @param unit the unit
+    * @return a set of metadata matching the type
+    */
+   @SuppressWarnings("unchecked")
+   protected Set<T> getAllMetaData(DeploymentUnit unit)
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+      
+      Set<T> result = new HashSet<T>();
+      Map<String, Object> attachments = unit.getAttachments();
+      for (Object object : attachments.values())
+      {
+         if (expectedType.isInstance(object))
+            result.add((T) object);
+      }
+      return result;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/SchemaResolverDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,95 @@
+/*
+* 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.deployers.plugins.deployers.helpers;
+
+import java.io.InputStream;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * SchemaResolverDeployer.
+ * 
+ * @param <T> the expected type 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class SchemaResolverDeployer<T> extends AbstractParsingDeployer<T>
+{
+   /** Unmarshaller factory */
+   private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+
+   /** The resolver */
+   private static final SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+   
+   /**
+    * Create a new SchemaResolverDeployer.
+    * 
+    * @param expectedType the expected type
+    * @throws IllegalArgumentException if the expected type is null
+    */
+   public SchemaResolverDeployer(Class<T> expectedType)
+   {
+      super(expectedType);
+   }
+
+   /**
+    * Parse a deployment
+    * 
+    * @param unit the deployment unit
+    * @param file the metadata file
+    * @return the metadata
+    * @throws Exception for any error
+    */
+   protected T parse(DeploymentUnit unit, VirtualFile file) throws Exception
+   {
+      if (file == null)
+         throw new IllegalArgumentException("Null file");
+      
+      Unmarshaller unmarshaller = factory.newUnmarshaller();
+      InputStream is = file.openStream();
+      Object parsed = null;
+      try
+      {
+         parsed = unmarshaller.unmarshal(is, resolver);
+      }
+      finally
+      {
+         try
+         {
+            is.close();
+         }
+         catch (Exception ignored)
+         {
+         }
+      }
+      if (parsed == null)
+         throw new DeploymentException("The xml " + file.getPathName() + " is not well formed!");
+
+      return getExpectedType().cast(parsed);
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/BeanDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/BeanDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/BeanDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,72 @@
+/*
+* 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.deployers.plugins.deployers.kernel;
+
+import org.jboss.deployers.plugins.deployers.helpers.SchemaResolverDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * BeanDeployer.<p>
+ * 
+ * This deployer is responsible for looking for -beans.xml
+ * and creating the metadata object.<p>
+ * 
+ * The {@link KernelDeployer} does the real work of deployment.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanDeployer extends SchemaResolverDeployer<KernelDeployment>
+{
+   /**
+    * Create a new BeanDeployer.
+    * 
+    * @throws IllegalArgumentException for a null kernel
+    */
+   public BeanDeployer()
+   {
+      super(KernelDeployment.class);
+   }
+
+   public int getRelativeOrder()
+   {
+      return 1000;
+   }
+
+   protected void init(DeploymentUnit unit, KernelDeployment metaData, VirtualFile file) throws Exception
+   {
+      String name = file.toURI().toString();
+      metaData.setName(name);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      createMetaData(unit, null, "-beans.xml");
+   }
+
+   public void undeploy(DeploymentUnit unit)
+   {
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/KernelDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/KernelDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/kernel/KernelDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,84 @@
+/*
+* 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.deployers.plugins.deployers.kernel;
+
+import java.util.Set;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+
+/**
+ * KernelDeployer.<p>
+ * 
+ * This deployer is responsible for deploying all metadata of
+ * type {@link org.jboss.kernel.spi.deployment.KernelDeployment}.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class KernelDeployer extends AbstractRealDeployer<KernelDeployment>
+{
+   /** The kernel deployer */
+   private final BasicXMLDeployer deployer;
+   
+   /**
+    * Create a new BeanDeployer.
+    * 
+    * @param kernel the kernel
+    * @throws IllegalArgumentException for a null kernel
+    */
+   public KernelDeployer(Kernel kernel)
+   {
+      super(KernelDeployment.class);
+      if (kernel == null)
+         throw new IllegalArgumentException("Null kernel");
+      deployer = new BasicXMLDeployer(kernel);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      Set<KernelDeployment> deployments = getAllMetaData(unit);
+      for (KernelDeployment deployment : deployments)
+      {
+         try
+         {
+            deployer.deploy(deployment);
+         }
+         catch (Throwable t)
+         {
+            undeploy(unit); // TODO better unwind
+            throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + deployment.getName(), t);
+         }
+      }
+   }
+
+   public void undeploy(DeploymentUnit unit)
+   {
+      Set<KernelDeployment> deployments = getAllMetaData(unit);
+      for (KernelDeployment deployment : deployments)
+         deployer.undeploy(deployment);
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -54,6 +54,7 @@
  * MainDeployerImpl.
  * 
  * TODO full deployer protocol
+ * TODO sort out a proper state machine
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
@@ -319,7 +320,10 @@
             }
          }
          for (DeploymentContext context : undeployContexts)
+         {
             context.setState(UNDEPLOYED);
+            log.debug("Undeployed: " + context.getName());
+         }
       }
       
       if (deployContexts != null)
@@ -352,7 +356,10 @@
             deployContexts.removeAll(errors);
          }
          for (DeploymentContext context : deployContexts)
+         {
             context.setState(DEPLOYED);
+            log.debug("Deployed: " + context.getName());
+         }
       }
    }
 

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -28,6 +28,8 @@
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArraySet;
 
+import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
+import org.jboss.deployers.spi.attachments.Attachments;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.DeploymentState;
@@ -79,6 +81,15 @@
    /** The child contexts */
    private Set<DeploymentContext> children = new CopyOnWriteArraySet<DeploymentContext>();
    
+   /** The predtermined managed objects */
+   private Attachments predeterminedManagedObjects = new AttachmentsImpl();
+   
+   /** The attachments */
+   private Attachments transientAttachments = new AttachmentsImpl();
+   
+   /** The managed objects */
+   private Attachments transientManagedObjects = new AttachmentsImpl();
+   
    /** Throwable */
    private Throwable problem;
    
@@ -341,6 +352,21 @@
          throw new IllegalArgumentException("Null child");
       return children.remove(child);
    }
+   
+   public Attachments getPredeterminedManagedObjects()
+   {
+      return predeterminedManagedObjects;
+   }
+   
+   public Attachments getTransientManagedObjects()
+   {
+      return transientManagedObjects;
+   }
+   
+   public Attachments getTransientAttachments()
+   {
+      return transientAttachments;
+   }
 
    public Throwable getProblem()
    {
@@ -354,10 +380,25 @@
 
    public VirtualFile getMetaDataFile(String name)
    {
-      if (metaDataLocation == null)
-         return null;
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
       try
       {
+         // There isn't a metadata location so let's see whether the root matches.
+         if (metaDataLocation == null)
+         {
+            // It has to be a plain file that is not an archive
+            if (root != null && root.isFile() && root.isArchive() == false)
+            {
+               String fileName = root.getName();
+               if (fileName.equals(name))
+                  return root;
+            }
+            
+            // No match
+            return null;
+         }
+         // Look in the meta data location
          return metaDataLocation.findChild(name);
       }
       catch (Exception e)
@@ -366,6 +407,39 @@
          return null;
       }
    }
+
+   public List<VirtualFile> getMetaDataFiles(String name, String suffix)
+   {
+      if (name == null && suffix == null)
+         throw new IllegalArgumentException("Null name and suffix");
+      try
+      {
+         // There isn't a metadata location so let's see whether the root matches.
+         // i.e. the top level is an xml
+         if (metaDataLocation == null)
+         {
+            // It has to be a plain file that is not an archive
+            if (root != null && root.isFile() && root.isArchive() == false)
+            {
+               String fileName = root.getName();
+               if (name != null && fileName.equals(name))
+                  return Collections.singletonList(root);
+               if (suffix != null && fileName.endsWith(suffix))
+                  return Collections.singletonList(root);
+            }
+            
+            // No match
+            return Collections.emptyList();
+         }
+         // Look in the meta data location
+         return metaDataLocation.getChildren(new MetaDataMatchFilter(name, suffix));
+      }
+      catch (Exception e)
+      {
+         log.debug("Error retrieving meta data: name=" + name + " suffix=" + suffix, e);
+         return Collections.emptyList();
+      }
+   }
    
    public void reset()
    {
@@ -376,6 +450,9 @@
          for (DeploymentContext child : children)
             child.reset();
       }
+      
+      transientManagedObjects.clear();
+      transientAttachments.clear();
    }
 
    public String toString()

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/MetaDataMatchFilter.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/MetaDataMatchFilter.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/MetaDataMatchFilter.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,91 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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.deployers.plugins.structure;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * Matches meta data
+ * 
+ * @author adrian at jboss.org
+ * @version $Revision: 44223 $
+ */
+public class MetaDataMatchFilter implements VirtualFileFilterWithAttributes
+{
+   /** The name */
+   private String name;
+
+   /** The suffix */
+   private String suffix;
+   
+   /** The attributes */
+   private VisitorAttributes attributes;
+   
+   /**
+    * Create a new MetaDataMatchFilter.
+    * using {@link VisitorAttributes#NO_DIRECTORIES}
+    * 
+    * @param name the name to exactly match
+    * @param suffix the suffix to partially match
+    * @throws IllegalArgumentException if both the name and suffix are null
+    */
+   public MetaDataMatchFilter(String name, String suffix)
+   {
+      this(name, suffix, null);
+   }
+   
+   /**
+    * Create a new MetaDataMatchFilter.
+    * 
+    * @param name the name to exactly match
+    * @param suffix the suffix to partially match
+    * @param attributes the attributes, pass null to use {@link VisitorAttributes#NO_DIRECTORIES}
+    * @throws IllegalArgumentException if both the name and suffix are null
+    */
+   public MetaDataMatchFilter(String name, String suffix, VisitorAttributes attributes)
+   {
+      if (name == null && suffix == null)
+         throw new IllegalArgumentException("Null name and suffix");
+      this.name = name;
+      this.suffix = suffix;
+      if (attributes == null)
+         attributes = VisitorAttributes.NO_DIRECTORIES;
+      this.attributes = attributes;
+   }
+   
+   public VisitorAttributes getAttributes()
+   {
+      return attributes;
+   }
+
+   public boolean accepts(VirtualFile file)
+   {
+      String fileName = file.getName();
+      if (name != null && fileName.equals(name))
+         return true;
+      if (suffix != null)
+         return fileName.endsWith(suffix);
+      return false;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/attachments/Attachments.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/attachments/Attachments.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/attachments/Attachments.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,173 @@
+/*
+* 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.deployers.spi.attachments;
+
+import java.util.Map;
+
+/**
+ * Attachments
+ * 
+ * Represents a set of attachments
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Attachments
+{
+   /**
+    * Get all the attachments
+    * 
+    * @return the unmodifiable attachments
+    */
+   Map<String, Object> getAttachments();
+
+   /**
+    * Add attachment
+    *
+    * @param name the name of the attachment
+    * @param attachment the attachment
+    * @return any previous attachment
+    * @throws IllegalArgumentException for a null name or attachment
+    */
+   Object addAttachment(String name, Object attachment);
+
+   /**
+    * Add attachment
+    *
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param attachment the attachment
+    * @param expectedType the expected type
+    * @return any previous attachment
+    * @throws IllegalArgumentException for a null name, attachment or expectedType
+    */
+   <T> T addAttachment(String name, T attachment, Class<T> expectedType);
+
+   /**
+    * Add attachment
+    *
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param attachment the attachment
+    * @param type the type
+    * @return any previous attachment
+    * @throws IllegalArgumentException for a null name, attachment or type
+    */
+   <T> T addAttachment(Class<T> type, T attachment);
+
+   /**
+    * Get attachment
+    * 
+    * @param name the name of the attachment
+    * @return the attachment or null if not present
+    * @throws IllegalArgumentException for a null name
+    */
+   Object getAttachment(String name);
+
+   /**
+    * Get attachment
+    * 
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param expectedType the expected type
+    * @return the attachment or null if not present
+    * @throws IllegalArgumentException for a null name or expectedType
+    */
+   <T> T getAttachment(String name, Class<T> expectedType);
+
+   /**
+    * Get attachment
+    * 
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param type the type
+    * @return the attachment or null if not present
+    * @throws IllegalArgumentException for a null name or type
+    */
+   <T> T getAttachment(Class<T> type);
+   
+   /**
+    * Is the attachment present
+    * 
+    * @param name the name of the attachment
+    * @return true when the attachment is present
+    * @throws IllegalArgumentException for a null name
+    */
+   boolean isAttachmentPresent(String name);
+   
+   /**
+    * Is the attachment present
+    * 
+    * @param name the name of the attachment
+    * @param expectedType the expected type
+    * @return true when the attachment is present
+    * @throws IllegalArgumentException for a null name or expectedType
+    */
+   boolean isAttachmentPresent(String name, Class<?> expectedType);
+   
+   /**
+    * Is the attachment present
+    * 
+    * @param name the name of the attachment
+    * @param type the type
+    * @return true when the attachment is present
+    * @throws IllegalArgumentException for a null name or type
+    */
+   boolean isAttachmentPresent(Class<?> type);
+
+   /**
+    * Remove attachment
+    * 
+    * @param name the name of the attachment
+    * @return the attachment or null if not present
+    * @throws IllegalArgumentException for a null name
+    */
+   Object removeAttachment(String name);
+
+   /**
+    * Remove attachment
+    * 
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @return the attachment or null if not present
+    * @param expectedType the expected type
+    * @throws IllegalArgumentException for a null name or expectedType
+    */
+   <T> T removeAttachment(String name, Class<T> expectedType);
+
+   /**
+    * Remove attachment
+    * 
+    * @param <T> the expected type
+    * @return the attachment or null if not present
+    * @param type the type
+    * @throws IllegalArgumentException for a null name or type
+    */
+   <T> T removeAttachment(Class<T> type);
+   
+   /**
+    * Clear the attachments
+    * 
+    * @throws UnsupportedOperationException when not supported by the implementation
+    */
+   void clear();
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -21,6 +21,9 @@
 */
 package org.jboss.deployers.spi.deployer;
 
+import java.util.List;
+
+import org.jboss.deployers.spi.attachments.Attachments;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -29,12 +32,10 @@
  * A deployment unit represents a single unit
  * that deployers work with.
  * 
- * TODO managed object stuff
- * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public interface DeploymentUnit
+public interface DeploymentUnit extends Attachments
 {
    /**
     * Get the deployment units name
@@ -44,17 +45,35 @@
    String getName();
    
    /**
-    * Gets some metadata for this deployment unit
+    * Gets a metadata file
     * 
-    * @param name the resource name
-    * @return the url of the metadata or null if not found
+    * @param name the name to exactly match
+    * @return the virtual file or null if not found
+    * @throws IllegalArgumentException for a null name
     */
    VirtualFile getMetaDataFile(String name);
    
    /**
+    * Gets the metadata files for this deployment unit
+    * 
+    * @param name the name to exactly match
+    * @param suffix the suffix to partially match
+    * @return the virtual files that match
+    * @throws IllegalArgumentException if both the name and suffix are null
+    */
+   List<VirtualFile> getMetaDataFiles(String name, String suffix);
+   
+   /**
     * Gets the classloader for this deployment unit
     * 
     * @return the classloader
     */
    ClassLoader getClassLoader();
+
+   /**
+    * Get the managed objects
+    * 
+    * @return the managed objects
+    */
+   Attachments getTransientManagedObjects();
 }

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.jboss.deployers.spi.attachments.Attachments;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.virtual.VirtualFile;
 
@@ -120,14 +121,25 @@
    void setMetaDataLocation(VirtualFile location);
    
    /**
-    * Gets a metadata file for this deployment unit
+    * Gets a metadata file
     * 
-    * @param name the resource name
-    * @return the url of the metadata or null if not found
+    * @param name the name to exactly match
+    * @return the virtual file or null if not found
+    * @throws IllegalArgumentException for a null name
     */
    VirtualFile getMetaDataFile(String name);
 
    /**
+    * Gets metadata files for this deployment
+    * 
+    * @param name the name to exactly match
+    * @param suffix the suffix to partially match
+    * @return the virtual files that match
+    * @throws IllegalArgumentException if both the name and suffix are null
+    */
+   List<VirtualFile> getMetaDataFiles(String name, String suffix);
+
+   /**
     * Gets the classloader for this deployment unit
     * 
     * @return the classloader
@@ -197,8 +209,29 @@
     * @return whether it was removed
     */
    boolean removeChild(DeploymentContext child);
-   
+
    /**
+    * Get the predetermined managed objects
+    * 
+    * @return the predetermined managed objects
+    */
+   Attachments getPredeterminedManagedObjects();
+
+   /**
+    * Get the managed objects
+    * 
+    * @return the managed objects
+    */
+   Attachments getTransientManagedObjects();
+
+   /**
+    * Get the transient attachments
+    * 
+    * @return the attachments
+    */
+   Attachments getTransientAttachments();
+
+   /**
     * Get the problem for this context
     * 
     * @return the problem

Added: projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/my-beans.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/my-beans.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/my-beans.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="Test" class="org.jboss.test.deployers.bean.support.Simple"/>
+</deployment>

Added: projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/META-INF/my-beans.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/META-INF/my-beans.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/bean/toplevel/test.jar/META-INF/my-beans.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="Test" class="org.jboss.test.deployers.bean.support.Simple"/>
+</deployment>

Added: projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/exact/jboss-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/exact/jboss-service.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/exact/jboss-service.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/1-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/1-ds.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/1-ds.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/2-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/2-ds.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/2-ds.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/partial/mydb-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/partial/mydb-ds.xml	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/metadata/toplevel/partial/mydb-ds.xml	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/DeployersAllTestSuite.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -21,6 +21,7 @@
 */
 package org.jboss.test.deployers;
 
+import org.jboss.test.deployers.attachments.AttachmentsTestSuite;
 import org.jboss.test.deployers.deployer.DeployerTestSuite;
 import org.jboss.test.deployers.structure.StructureTestSuite;
 
@@ -45,6 +46,7 @@
    {
       TestSuite suite = new TestSuite("Deployers All Tests");
 
+      suite.addTest(AttachmentsTestSuite.suite());
       suite.addTest(StructureTestSuite.suite());
       suite.addTest(DeployerTestSuite.suite());
 

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/AttachmentsTestSuite.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,67 @@
+/*
+* 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.attachments;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.deployers.attachments.test.AttachmentsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentUnitAttachmentHierarchyUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentUnitAttachmentsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentUnitPredeterminedManagedObjectsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentUnitTransientAttachmentsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.DeploymentUnitTransientManagedObjectsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.PredeterminedManagedObjectsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.TransientAttachmentsUnitTestCase;
+import org.jboss.test.deployers.attachments.test.TransientManagedObjectsUnitTestCase;
+
+/**
+ * Attachments Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class AttachmentsTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Attachments Tests");
+
+      suite.addTest(AttachmentsUnitTestCase.suite());
+      suite.addTest(PredeterminedManagedObjectsUnitTestCase.suite());
+      suite.addTest(TransientManagedObjectsUnitTestCase.suite());
+      suite.addTest(TransientAttachmentsUnitTestCase.suite());
+      suite.addTest(DeploymentUnitAttachmentsUnitTestCase.suite());
+      suite.addTest(DeploymentUnitPredeterminedManagedObjectsUnitTestCase.suite());
+      suite.addTest(DeploymentUnitTransientManagedObjectsUnitTestCase.suite());
+      suite.addTest(DeploymentUnitTransientAttachmentsUnitTestCase.suite());
+      suite.addTest(DeploymentUnitAttachmentHierarchyUnitTestCase.suite());
+
+      return suite;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsTest.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,476 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * Attachments Test.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AttachmentsTest extends BaseTestCase
+{
+   public static Test suite()
+   {
+      return new TestSuite(AttachmentsTest.class);
+   }
+   
+   public AttachmentsTest(String name)
+   {
+      super(name);
+   }
+   
+   protected abstract Attachments getAttachments();
+   
+   protected abstract Attachments getMutable();
+   
+   public void testAddAttachmentErrors() throws Exception
+   {
+      Attachments mutable = getMutable();
+      
+      try
+      {
+         mutable.addAttachment((String) null, "attachment");
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment("name", null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment((String) null, "attachment", String.class);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment("name", null, String.class);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment("name", "attachment", null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment((Class<String>) null, "attachment");
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.addAttachment(String.class, null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testAddAttachmentByName() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertAddFreshAttachmentByName(expected, "name1", "attachment");
+      assertAddFreshAttachmentByName(expected, "name2", "attachment");
+      
+      assertAddReplaceAttachmentByName(expected, "name1", "different", "attachment");
+   }
+
+   protected void assertAddFreshAttachmentByName(ExpectedAttachments expected, String name, Object attachment)
+   {
+      assertAddReplaceAttachmentByName(expected, name, attachment, null);
+   }
+
+   protected void assertAddReplaceAttachmentByName(ExpectedAttachments expected, String name, Object attachment, Object replaced)
+   {
+      Object result = assertAddAttachmentByName(expected, name, attachment);
+      assertEquals(replaced, result);
+   }
+
+   protected Object assertAddAttachmentByName(ExpectedAttachments expected, String name, Object attachment)
+   {
+      Object result = getMutable().addAttachment(name, attachment);
+      checkAdd(getAttachments(), expected, name, attachment, result);
+      return result;
+   }
+      
+   protected Object checkAdd(Attachments attachments, ExpectedAttachments expected, String name, Object attachment, Object result)
+   {
+      assertEquals(attachment, attachments.getAttachment(name));
+      assertTrue(attachments.isAttachmentPresent(name));
+      Object expectedResult = assertExpectedAdd(attachments, expected, name, attachment);
+      assertEquals(expectedResult, result);
+      return result;
+   }
+   
+   protected Object assertExpectedAdd(Attachments attachments, ExpectedAttachments expected, String name, Object attachment)
+   {
+      Object result = expected.add(name, attachment);
+      assertEquals(expected.expected, attachments.getAttachments());
+      return result;
+   }
+   
+   public void testAddAttachmentByNameAndType() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertAddFreshAttachmentByNameAndType(expected, "name1", "attachment", String.class);
+      assertAddFreshAttachmentByNameAndType(expected, "name2", "attachment", String.class);
+      
+      assertAddReplaceAttachmentByNameAndType(expected, "name1", "different", "attachment", String.class);
+   }
+
+   protected <T> void assertAddFreshAttachmentByNameAndType(ExpectedAttachments expected, String name, T attachment, Class<T> expectedType)
+   {
+      assertAddReplaceAttachmentByNameAndType(expected, name, attachment, null, expectedType);
+   }
+
+   protected <T> void assertAddReplaceAttachmentByNameAndType(ExpectedAttachments expected, String name, T attachment, Object replaced, Class<T> expectedType)
+   {
+      Object result = assertAddAttachmentByNameAndType(expected, name, attachment, expectedType);
+      assertEquals(replaced, result);
+   }
+
+   protected <T> Object assertAddAttachmentByNameAndType(ExpectedAttachments expected, String name, T attachment, Class<T> expectedType)
+   {
+      Object result = getMutable().addAttachment(name, attachment, expectedType);
+      Attachments attachments = getAttachments();
+      checkAdd(attachments, expected, name, attachment, result);
+      assertEquals(attachment, attachments.getAttachment(name, expectedType));
+      assertTrue(attachments.isAttachmentPresent(name, expectedType));
+      return result;
+   }
+   
+   public void testAddAttachmentByType() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertAddFreshAttachmentByType(expected, Integer.class, 1);
+      assertAddFreshAttachmentByType(expected, String.class, "attachment");
+      
+      assertAddReplaceAttachmentByType(expected, String.class, "different", "attachment");
+   }
+
+   protected <T> void assertAddFreshAttachmentByType(ExpectedAttachments expected, Class<T> type, T attachment)
+   {
+      assertAddReplaceAttachmentByType(expected, type, attachment, null);
+   }
+
+   protected <T> void assertAddReplaceAttachmentByType(ExpectedAttachments expected, Class<T> type, T attachment, Object replaced)
+   {
+      Object result = assertAddAttachmentByType(expected, type, attachment);
+      assertEquals(replaced, result);
+   }
+
+   protected <T> Object assertAddAttachmentByType(ExpectedAttachments expected, Class<T> type, T attachment)
+   {
+      Object result = getMutable().addAttachment(type, attachment);
+      String name = type.getName();
+      Attachments attachments = getAttachments();
+      checkAdd(attachments, expected, name, attachment, result);
+      assertEquals(attachment, attachments.getAttachment(type));
+      assertTrue(attachments.isAttachmentPresent(type));
+      assertEquals(attachment, attachments.getAttachment(name, type));
+      assertTrue(attachments.isAttachmentPresent(name, type));
+      return result;
+   }
+   
+   public void testRemoveAttachmentErrors() throws Exception
+   {
+      Attachments mutable = getMutable();
+      
+      try
+      {
+         mutable.removeAttachment((String) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.removeAttachment((String) null, String.class);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.removeAttachment("name", null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         mutable.removeAttachment((Class<String>) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testRemoveAttachmentByName() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertRemoveNotPresentAttachmentByName(expected, "name1");
+      
+      assertAddAttachmentByName(expected, "name1", "attachment");
+      assertAddAttachmentByName(expected, "name2", "different");
+      assertRemoveAttachmentByName(expected, "name1", "attachment");
+   }
+
+   protected void assertRemoveNotPresentAttachmentByName(ExpectedAttachments expected, String name)
+   {
+      assertRemoveAttachmentByName(expected, name, null);
+   }
+
+   protected void assertRemoveAttachmentByName(ExpectedAttachments expected, String name, Object removed)
+   {
+      Object result = assertRemoveAttachmentByName(expected, name);
+      assertEquals(removed, result);
+   }
+
+   protected Object assertRemoveAttachmentByName(ExpectedAttachments expected, String name)
+   {
+      Object result = getMutable().removeAttachment(name);
+      checkRemove(getAttachments(), expected, name, result);
+      return result;
+   }
+      
+   protected Object checkRemove(Attachments attachments, ExpectedAttachments expected, String name, Object result)
+   {
+      assertNull(attachments.getAttachment(name));
+      assertFalse(attachments.isAttachmentPresent(name));
+      Object expectedResult = assertExpectedRemove(attachments, expected, name);
+      assertEquals(expectedResult, result);
+      return result;
+   }
+   
+   protected Object assertExpectedRemove(Attachments attachments, ExpectedAttachments expected, String name)
+   {
+      Object result = expected.remove(name);
+      assertEquals(expected.expected, attachments.getAttachments());
+      return result;
+   }
+   
+   public void testRemoveAttachmentByNameAndType() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertRemoveNotPresentAttachmentByNameAndType(expected, "name1", String.class);
+      
+      assertAddAttachmentByNameAndType(expected, "name1", "attachment", String.class);
+      assertAddAttachmentByNameAndType(expected, "name2", "different", String.class);
+      assertRemoveAttachmentByNameAndType(expected, "name1", "attachment", String.class);
+   }
+
+   protected <T> void assertRemoveNotPresentAttachmentByNameAndType(ExpectedAttachments expected, String name, Class<T> expectedType)
+   {
+      assertRemoveAttachmentByNameAndType(expected, name, null, expectedType);
+   }
+
+   protected <T> void assertRemoveAttachmentByNameAndType(ExpectedAttachments expected, String name, Object removed, Class<T> expectedType)
+   {
+      Object result = assertRemoveAttachmentByNameAndType(expected, name, expectedType);
+      assertEquals(removed, result);
+   }
+
+   protected <T> Object assertRemoveAttachmentByNameAndType(ExpectedAttachments expected, String name, Class<T> expectedType)
+   {
+      Object result = getMutable().removeAttachment(name, expectedType);
+      Attachments attachments = getAttachments();
+      checkRemove(attachments, expected, name, result);
+      assertNull(attachments.getAttachment(name, expectedType));
+      assertFalse(attachments.isAttachmentPresent(name, expectedType));
+      return result;
+   }
+   
+   public void testRemoveAttachmentByType() throws Exception
+   {
+      ExpectedAttachments expected = new ExpectedAttachments();
+      assertRemoveNotPresentAttachmentByType(expected, Integer.class);
+      
+      assertAddAttachmentByType(expected, Integer.class, 1);
+      assertAddAttachmentByType(expected, String.class, "attachment");
+      assertRemoveAttachmentByType(expected, String.class, "attachment");
+   }
+
+   protected <T> void assertRemoveNotPresentAttachmentByType(ExpectedAttachments expected, Class<T> type)
+   {
+      assertRemoveAttachmentByType(expected, type, null);
+   }
+
+   protected <T> void assertRemoveAttachmentByType(ExpectedAttachments expected, Class<T> type, Object removed)
+   {
+      Object result = assertRemoveAttachmentByType(expected, type);
+      assertEquals(removed, result);
+   }
+
+   protected <T> Object assertRemoveAttachmentByType(ExpectedAttachments expected, Class<T> type)
+   {
+      Object result = getMutable().removeAttachment(type);
+      String name = type.getName();
+      Attachments attachments = getAttachments();
+      checkRemove(attachments, expected, name, result);
+      assertNull(attachments.getAttachment(type));
+      assertFalse(attachments.isAttachmentPresent(type));
+      assertNull(attachments.getAttachment(name, type));
+      assertFalse(attachments.isAttachmentPresent(name, type));
+      return result;
+   }
+   
+   public void testGetAttachmentErrors() throws Exception
+   {
+      Attachments attachments = getAttachments();
+      
+      try
+      {
+         attachments.getAttachment((String) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.getAttachment((String) null, String.class);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.getAttachment("name", null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.getAttachment((Class<String>) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+   
+   public void testIsAttachmentPresentErrors() throws Exception
+   {
+      Attachments attachments = getAttachments();
+      
+      try
+      {
+         attachments.isAttachmentPresent((String) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.isAttachmentPresent((String) null, String.class);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.isAttachmentPresent("name", null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+      
+      try
+      {
+         attachments.isAttachmentPresent((Class<String>) null);
+         fail("Should not be here!");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalArgumentException.class, t);
+      }
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/AttachmentsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,59 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.attachments.AttachmentsImpl;
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * AttachmentsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AttachmentsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(AttachmentsUnitTestCase.class);
+   }
+   
+   private Attachments impl = new AttachmentsImpl();
+   
+   public AttachmentsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected Attachments getAttachments()
+   {
+      return impl;
+   }
+
+   protected Attachments getMutable()
+   {
+      return impl;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentHierarchyUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentHierarchyUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentHierarchyUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,157 @@
+/*
+* 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.attachments.test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * DeploymentUnitAttachmentHierarchyUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentUnitAttachmentHierarchyUnitTestCase extends BaseTestCase
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeploymentUnitAttachmentHierarchyUnitTestCase.class);
+   }
+   
+   private DeploymentUnit unit;
+
+   private Attachments predeterminedManagedObjects;
+   
+   private Attachments transientManagedObjects;
+
+   private Attachments transientAttachments;
+   
+   public DeploymentUnitAttachmentHierarchyUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      unit = new AbstractDeploymentUnit(context);
+      context.setDeploymentUnit(unit);
+      predeterminedManagedObjects = context.getPredeterminedManagedObjects();
+      transientManagedObjects = context.getTransientManagedObjects();
+      transientAttachments = context.getTransientAttachments();
+   }
+   
+   public void testPredeterminedIsFirstByName()
+   {
+      predeterminedManagedObjects.addAttachment("Name", "pMO");
+      transientManagedObjects.addAttachment("Name", "tMO");
+      transientAttachments.addAttachment("Name", "tA");
+      assertEquals("pMO", unit.getAttachment("Name"));
+      Map<String, String> expected = Collections.singletonMap("Name", "pMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testPredeterminedIsFirstByNameAndType()
+   {
+      predeterminedManagedObjects.addAttachment("Name", "pMO", String.class);
+      transientManagedObjects.addAttachment("Name", "tMO", String.class);
+      transientAttachments.addAttachment("Name", "tA", String.class);
+      assertEquals("pMO", unit.getAttachment("Name"));
+      assertEquals("pMO", unit.getAttachment("Name", String.class));
+      Map<String, String> expected = Collections.singletonMap("Name", "pMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testPredeterminedIsFirstByType()
+   {
+      predeterminedManagedObjects.addAttachment(String.class, "pMO");
+      transientManagedObjects.addAttachment(String.class, "tMO");
+      transientAttachments.addAttachment(String.class, "tA");
+      assertEquals("pMO", unit.getAttachment(String.class.getName()));
+      assertEquals("pMO", unit.getAttachment(String.class.getName(), String.class));
+      assertEquals("pMO", unit.getAttachment(String.class));
+      Map<String, String> expected = Collections.singletonMap(String.class.getName(), "pMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientManagedObjectsIsSecondByName()
+   {
+      transientManagedObjects.addAttachment("Name", "tMO");
+      transientAttachments.addAttachment("Name", "tA");
+      assertEquals("tMO", unit.getAttachment("Name"));
+      Map<String, String> expected = Collections.singletonMap("Name", "tMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientManagedObjectsIsSecondAndType()
+   {
+      transientManagedObjects.addAttachment("Name", "tMO", String.class);
+      transientAttachments.addAttachment("Name", "tA", String.class);
+      assertEquals("tMO", unit.getAttachment("Name"));
+      assertEquals("tMO", unit.getAttachment("Name", String.class));
+      Map<String, String> expected = Collections.singletonMap("Name", "tMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientManagedObjectsIsSecondByType()
+   {
+      transientManagedObjects.addAttachment(String.class, "tMO");
+      transientAttachments.addAttachment(String.class, "tA");
+      assertEquals("tMO", unit.getAttachment(String.class.getName()));
+      assertEquals("tMO", unit.getAttachment(String.class.getName(), String.class));
+      assertEquals("tMO", unit.getAttachment(String.class));
+      Map<String, String> expected = Collections.singletonMap(String.class.getName(), "tMO");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientAttrachmentsIsThirdByName()
+   {
+      transientAttachments.addAttachment("Name", "tA");
+      assertEquals("tA", unit.getAttachment("Name"));
+      Map<String, String> expected = Collections.singletonMap("Name", "tA");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientAttrachmentsIsThirdAndType()
+   {
+      transientAttachments.addAttachment("Name", "tA", String.class);
+      assertEquals("tA", unit.getAttachment("Name"));
+      assertEquals("tA", unit.getAttachment("Name", String.class));
+      Map<String, String> expected = Collections.singletonMap("Name", "tA");
+      assertEquals(expected, unit.getAttachments());
+   }
+   
+   public void testTransientAttrachmentsIsThirdByType()
+   {
+      transientAttachments.addAttachment(String.class, "tA");
+      assertEquals("tA", unit.getAttachment(String.class.getName()));
+      assertEquals("tA", unit.getAttachment(String.class.getName(), String.class));
+      assertEquals("tA", unit.getAttachment(String.class));
+      Map<String, String> expected = Collections.singletonMap(String.class.getName(), "tA");
+      assertEquals(expected, unit.getAttachments());
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitAttachmentsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,67 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * DeploymentUnitAttachmentsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentUnitAttachmentsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeploymentUnitAttachmentsUnitTestCase.class);
+   }
+   
+   private DeploymentUnit unit;
+
+   private Attachments mutable; 
+   
+   public DeploymentUnitAttachmentsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      unit = new AbstractDeploymentUnit(context);
+      context.setDeploymentUnit(unit);
+      mutable = unit;
+   }
+
+   protected Attachments getAttachments()
+   {
+      return unit;
+   }
+
+   protected Attachments getMutable()
+   {
+      return mutable;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitPredeterminedManagedObjectsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitPredeterminedManagedObjectsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitPredeterminedManagedObjectsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,67 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * DeploymentUnitPredeterminedManagedObjectsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentUnitPredeterminedManagedObjectsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeploymentUnitPredeterminedManagedObjectsUnitTestCase.class);
+   }
+   
+   private DeploymentUnit unit;
+
+   private Attachments mutable; 
+   
+   public DeploymentUnitPredeterminedManagedObjectsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      unit = new AbstractDeploymentUnit(context);
+      context.setDeploymentUnit(unit);
+      mutable = context.getPredeterminedManagedObjects();
+   }
+
+   protected Attachments getAttachments()
+   {
+      return unit;
+   }
+
+   protected Attachments getMutable()
+   {
+      return mutable;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientAttachmentsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientAttachmentsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientAttachmentsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,67 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * DeploymentUnitTransientAttachmentsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentUnitTransientAttachmentsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeploymentUnitTransientAttachmentsUnitTestCase.class);
+   }
+   
+   private DeploymentUnit unit;
+
+   private Attachments mutable; 
+   
+   public DeploymentUnitTransientAttachmentsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      unit = new AbstractDeploymentUnit(context);
+      context.setDeploymentUnit(unit);
+      mutable = context.getTransientAttachments();
+   }
+
+   protected Attachments getAttachments()
+   {
+      return unit;
+   }
+
+   protected Attachments getMutable()
+   {
+      return mutable;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientManagedObjectsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientManagedObjectsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/DeploymentUnitTransientManagedObjectsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,67 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployer.AbstractDeploymentUnit;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+
+/**
+ * DeploymentUnitTransientManagedObjectsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentUnitTransientManagedObjectsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(DeploymentUnitTransientManagedObjectsUnitTestCase.class);
+   }
+   
+   private DeploymentUnit unit;
+
+   private Attachments mutable; 
+   
+   public DeploymentUnitTransientManagedObjectsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      unit = new AbstractDeploymentUnit(context);
+      context.setDeploymentUnit(unit);
+      mutable = context.getTransientManagedObjects();
+   }
+
+   protected Attachments getAttachments()
+   {
+      return unit;
+   }
+
+   protected Attachments getMutable()
+   {
+      return mutable;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/ExpectedAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/ExpectedAttachments.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/ExpectedAttachments.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,46 @@
+/*
+* 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.attachments.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ExpectedAttachments.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExpectedAttachments
+{
+   public Map<String, Object> expected = new HashMap<String, Object>();
+   
+   public Object add(String name, Object attachment)
+   {
+      return expected.put(name, attachment);
+   }
+   
+   public Object remove(String name)
+   {
+      return expected.remove(name);
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/PredeterminedManagedObjectsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/PredeterminedManagedObjectsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/PredeterminedManagedObjectsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,61 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * PredeterminedManagedObjectsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PredeterminedManagedObjectsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(PredeterminedManagedObjectsUnitTestCase.class);
+   }
+   
+   private Attachments impl;
+   
+   public PredeterminedManagedObjectsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      impl = context.getPredeterminedManagedObjects();
+   }
+
+   protected Attachments getAttachments()
+   {
+      return impl;
+   }
+
+   protected Attachments getMutable()
+   {
+      return impl;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientAttachmentsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientAttachmentsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientAttachmentsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,62 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * TransientAttachmentsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TransientAttachmentsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(TransientAttachmentsUnitTestCase.class);
+   }
+   
+   private Attachments impl;
+   
+   public TransientAttachmentsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      impl = context.getTransientAttachments();
+   }
+   
+   protected Attachments getAttachments()
+   {
+      return impl;
+   }
+
+   protected Attachments getMutable()
+   {
+      return impl;
+   }
+
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientManagedObjectsUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientManagedObjectsUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/attachments/test/TransientManagedObjectsUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,62 @@
+/*
+* 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.attachments.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.attachments.Attachments;
+
+/**
+ * TransientManagedObjectsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TransientManagedObjectsUnitTestCase extends AttachmentsTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(TransientManagedObjectsUnitTestCase.class);
+   }
+   
+   private Attachments impl;
+   
+   public TransientManagedObjectsUnitTestCase(String name)
+   {
+      super(name);
+      AbstractDeploymentContext context = new AbstractDeploymentContext("attachments");
+      impl = context.getTransientManagedObjects();
+   }
+   
+   protected Attachments getAttachments()
+   {
+      return impl;
+   }
+
+   protected Attachments getMutable()
+   {
+      return impl;
+   }
+
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/Simple.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/Simple.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/Simple.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,32 @@
+/*
+* 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.bean.support;
+
+/**
+ * Simple.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Simple
+{
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/TestBeanDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/TestBeanDeployer.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/support/TestBeanDeployer.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -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.bean.support;
+
+import java.util.Collections;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+
+/**
+ * TestBeanDeployer.<p>
+ * 
+ * This just creates some metadata for use by the KernelDeployer
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestBeanDeployer extends AbstractSimpleDeployer
+{
+
+   public int getRelativeOrder()
+   {
+      return 1;
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      deployment.setName("KernelDeployerTest");
+      
+      BeanMetaDataFactory metaData = new AbstractBeanMetaData("Test", Simple.class.getName());
+      deployment.setBeanFactories(Collections.singletonList(metaData));
+      
+      unit.getTransientManagedObjects().addAttachment("KernelDeployerTest", deployment);
+   }
+
+   public void undeploy(DeploymentUnit unit)
+   {
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/BeanDeployerUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/BeanDeployerUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/BeanDeployerUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,119 @@
+/*
+* 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.bean.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployers.kernel.BeanDeployer;
+import org.jboss.deployers.plugins.deployers.kernel.KernelDeployer;
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentState;
+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.BaseDeployersTest;
+
+/**
+ * BeanDeployerUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanDeployerUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(BeanDeployerUnitTestCase.class);
+   }
+
+   private MainDeployerImpl main;
+   
+   private KernelController controller;
+   
+   public BeanDeployerUnitTestCase(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 = new MainDeployerImpl();
+         main.addStructureDeployer(new JARStructure());
+         main.addStructureDeployer(new FileStructure());
+         
+         BeanDeployer beanDeployer = new BeanDeployer();
+         KernelDeployer kernelDeployer = new KernelDeployer(kernel);
+         main.addDeployer(beanDeployer);
+         main.addDeployer(kernelDeployer);
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   public void testTopLevelFile() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/bean", "toplevel/my-beans.xml");
+      assertDeploy(context);
+      assertNotNull(controller.getInstalledContext("Test"));
+      
+      assertUndeploy(context);
+      assertNull(controller.getContext("Test", null));
+   }
+
+   public void testMetaInfFile() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/bean", "toplevel/test.jar");
+      assertDeploy(context);
+      assertNotNull(controller.getInstalledContext("Test"));
+      
+      assertUndeploy(context);
+      assertNull(controller.getContext("Test", null));
+   }
+
+   protected void assertDeploy(DeploymentContext context) throws Exception
+   {
+      main.addDeploymentContext(context);
+      main.process();
+      assertTrue(context.getState() == DeploymentState.DEPLOYED);
+   }
+
+   protected void assertUndeploy(DeploymentContext context) throws Exception
+   {
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      assertTrue(context.getState() == DeploymentState.UNDEPLOYED);
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/KernelDeployerUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/KernelDeployerUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/bean/test/KernelDeployerUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,134 @@
+/*
+* 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.bean.test;
+
+import java.util.Collections;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.deployers.plugins.deployers.kernel.KernelDeployer;
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentState;
+import org.jboss.deployers.spi.structure.StructureDetermined;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.bean.support.Simple;
+import org.jboss.test.deployers.bean.support.TestBeanDeployer;
+
+/**
+ * BeanDeployerUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class KernelDeployerUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(KernelDeployerUnitTestCase.class);
+   }
+
+   private MainDeployerImpl main;
+   
+   private KernelController controller;
+   
+   public KernelDeployerUnitTestCase(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 = new MainDeployerImpl();
+         
+         TestBeanDeployer testDeployer = new TestBeanDeployer();
+         KernelDeployer kernelDeployer = new KernelDeployer(kernel);
+         main.addDeployer(testDeployer);
+         main.addDeployer(kernelDeployer);
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   public void testKernelDeployerPredetermined() throws Exception
+   {
+      DeploymentContext context = createSimpleDeployment("KernelDeployerTest");
+      context.setStructureDetermined(StructureDetermined.PREDETERMINED);
+
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      deployment.setName("KernelDeployerTest");
+      
+      BeanMetaDataFactory metaData = new AbstractBeanMetaData("Test", Simple.class.getName());
+      deployment.setBeanFactories(Collections.singletonList(metaData));
+      
+      context.getPredeterminedManagedObjects().addAttachment("KernelDeployerTest", deployment);
+      
+      assertDeploy(context);
+      assertNotNull(controller.getInstalledContext("Test"));
+      
+      assertUndeploy(context);
+      assertNull(controller.getContext("Test", null));
+   }
+
+   public void testKernelDeployerTransient() throws Exception
+   {
+      DeploymentContext context = createSimpleDeployment("KernelDeployerTest");
+      context.setStructureDetermined(StructureDetermined.PREDETERMINED);
+      
+      assertDeploy(context);
+      assertNotNull(controller.getInstalledContext("Test"));
+      
+      assertUndeploy(context);
+      assertNull(controller.getContext("Test", null));
+   }
+
+   protected void assertDeploy(DeploymentContext context) throws Exception
+   {
+      main.addDeploymentContext(context);
+      main.process();
+      assertTrue(context.getState() == DeploymentState.DEPLOYED);
+   }
+
+   protected void assertUndeploy(DeploymentContext context) throws Exception
+   {
+      main.removeDeploymentContext(context.getName());
+      main.process();
+      assertTrue(context.getState() == DeploymentState.UNDEPLOYED);
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -25,10 +25,13 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.jboss.test.deployers.bean.test.BeanDeployerUnitTestCase;
+import org.jboss.test.deployers.bean.test.KernelDeployerUnitTestCase;
 import org.jboss.test.deployers.deployer.test.DeployerOrderingUnitTestCase;
 import org.jboss.test.deployers.deployer.test.DeployerProtocolUnitTestCase;
 import org.jboss.test.deployers.deployer.test.DeployerWidthFirstUnitTestCase;
 import org.jboss.test.deployers.deployer.test.MainDeployerDeployerUnitTestCase;
+import org.jboss.test.deployers.metadata.test.MetaDataUnitTestCase;
 
 /**
  * Deployer Test Suite.
@@ -51,6 +54,9 @@
       suite.addTest(DeployerOrderingUnitTestCase.suite());
       suite.addTest(DeployerWidthFirstUnitTestCase.suite());
       suite.addTest(MainDeployerDeployerUnitTestCase.suite());
+      suite.addTest(MetaDataUnitTestCase.suite());
+      suite.addTest(BeanDeployerUnitTestCase.suite());
+      suite.addTest(KernelDeployerUnitTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/test/MetaDataUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/test/MetaDataUnitTestCase.java	2006-09-12 09:35:20 UTC (rev 56752)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/metadata/test/MetaDataUnitTestCase.java	2006-09-12 09:36:30 UTC (rev 56753)
@@ -0,0 +1,199 @@
+/*
+* 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.metadata.test;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * MetaDataUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataUnitTestCase extends BaseDeployersTest
+{
+   public static Test suite()
+   {
+      return new TestSuite(MetaDataUnitTestCase.class);
+   }
+   
+   public MetaDataUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testExactMatchTopLevel() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/exact/jboss-service.xml");
+      String expected = getURL("/metadata/toplevel/exact/jboss-service.xml");
+      assertMetaDataMatch(context, expected, "jboss-service.xml");
+   }
+
+   public void testNotExactMatchTopLevel() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/exact/jboss-service.xml");
+      assertNoMetaDataMatch(context, "not-correct.xml");
+   }
+
+   public void testPartialMatchTopLevel() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/partial/mydb-ds.xml");
+      Set<String> expected = new HashSet<String>();
+      expected.add(getURL("/metadata/toplevel/partial/mydb-ds.xml"));
+      assertMetaDataMatch(context, expected, null, "-ds.xml");
+   }
+
+   public void testNotPartialMatchTopLevel() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/partial/mydb-ds.xml");
+      assertNoMetaDataMatch(context, null, "-not.xml");
+   }
+
+   public void testExactMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      String expected = getURL("/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml");
+      assertMetaDataMatch(context, expected, "jboss-service.xml");
+   }
+
+   public void testNotExactMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "not-correct.xml");
+   }
+
+   public void testExactMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "jboss-service.xml");
+   }
+
+   public void testNotExactMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "not-correct.xml");
+   }
+
+   public void testPartialMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      Set<String> expected = new HashSet<String>();
+      expected.add(getURL("/metadata/toplevel/metadata.jar/META-INF/1-ds.xml"));
+      expected.add(getURL("/metadata/toplevel/metadata.jar/META-INF/2-ds.xml"));
+      assertMetaDataMatch(context, expected, null, "-ds.xml");
+   }
+
+   public void testNotPartialMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, null, "-not.xml");
+   }
+
+   public void testPartialMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, null, "-ds.xml");
+   }
+
+   public void testNotPartialMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, null, "-not.xml");
+   }
+
+   public void testExactAndPartialMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      Set<String> expected = new HashSet<String>();
+      expected.add(getURL("/metadata/toplevel/metadata.jar/META-INF/jboss-service.xml"));
+      expected.add(getURL("/metadata/toplevel/metadata.jar/META-INF/1-ds.xml"));
+      expected.add(getURL("/metadata/toplevel/metadata.jar/META-INF/2-ds.xml"));
+      assertMetaDataMatch(context, expected, "jboss-service.xml", "-ds.xml");
+   }
+
+   public void testNotExactAndPartialMatchMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "not-correct.xml", "-not.xml");
+   }
+
+   public void testExactAndPartialMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "jboss-service.xml", "-ds.xml");
+   }
+
+   public void testNotExactAndPartialMatchNoMetaInf() throws Exception
+   {
+      DeploymentContext context = createDeploymentContext("/metadata", "toplevel/metadata-nometainf.jar");
+      context.setMetaDataPath("META-INF");
+      assertNoMetaDataMatch(context, "jboss-service.xml", "-not.xml");
+   }
+   
+   protected void assertMetaDataMatch(DeploymentContext context, String expected, String name) throws Exception
+   {
+      VirtualFile file = context.getMetaDataFile(name);
+      assertNotNull(file);
+      assertEquals(expected, file.toURL().toString());
+   }
+   
+   protected void assertNoMetaDataMatch(DeploymentContext context, String name) throws Exception
+   {
+      VirtualFile file = context.getMetaDataFile(name);
+      assertNull(file);
+   }
+   
+   protected void assertMetaDataMatch(DeploymentContext context, Set<String> expected, String name, String suffix) throws Exception
+   {
+      List<VirtualFile> files = context.getMetaDataFiles(name, suffix);
+      Set<String> actual = new HashSet<String>(files.size());
+      for (VirtualFile file : files)
+         actual.add(file.toURL().toString());
+      assertEquals(expected, actual);
+   }
+   
+   protected void assertNoMetaDataMatch(DeploymentContext context, String name, String suffix) throws Exception
+   {
+      List<VirtualFile> files = context.getMetaDataFiles(name, suffix);
+      assertEmpty(files);
+   }
+}




More information about the jboss-cvs-commits mailing list