[jboss-cvs] JBossAS SVN: r59205 - in projects/microcontainer/trunk: deployers deployers/src/main/org/jboss/deployers/plugins/deployer deployers/src/main/org/jboss/deployers/plugins/deployers/helpers deployers/src/main/org/jboss/deployers/plugins/deployment deployers/src/main/org/jboss/deployers/plugins/structure deployers/src/main/org/jboss/deployers/plugins/structure/vfs deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war deployers/src/main/org/jboss/deployers/spi deployers/src/main/org/jboss/deployers/spi/deployer deployers/src/main/org/jboss/deployers/spi/deployment deployers/src/main/org/jboss/deployers/spi/managed deployers/src/main/org/jboss/deployers/spi/structure/vfs deployers/src/tests/org/jboss/test/deployers deployers/src/tests/org/jboss/test/deployers/deployer deployers/src/tests/org/jboss/test/deployers/managed deployers/src/tests/org/jboss/test/deployers/managed/support deployers/src/te! sts/org/jboss/test/deployers/managed/test deployers/src/tests/org/jboss/test/deployers/structure deployers/src/tests/org/jboss/test/deployers/structure/ear/support deployers/src/tests/org/jboss/test/deployers/structure/ear/test deployers/src/tests/org/jboss/test/deployers/structure/main/test managed/src/main/org/jboss/managed/api managed/src/main/org/jboss/managed/plugins managed/src/tests/org/jboss/test managed/src/tests/org/jboss/test/managed/mock

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 22 00:06:57 EST 2006


Author: adrian at jboss.org
Date: 2006-12-22 00:06:26 -0500 (Fri, 22 Dec 2006)
New Revision: 59205

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/managed/
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/managed/ManagedObjectBuilder.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/ManagedTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestAttachment.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestFields.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
Removed:
   projects/microcontainer/trunk/managed/src/tests/org/jboss/test/empty
Modified:
   projects/microcontainer/trunk/deployers/.classpath
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AttachmentLocator.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/ClassPathInfoImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
   projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java
   projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java
   projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java
Log:
Initial implementation of the hook between the MainDeployer/Deployers
and the ManagedObject creation.

Also some tidyup of the deployers project which has got messy.

Modified: projects/microcontainer/trunk/deployers/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers/.classpath	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/.classpath	2006-12-22 05:06:26 UTC (rev 59205)
@@ -15,5 +15,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/kernel"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/dependency"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/managed"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

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-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,10 +21,14 @@
 */
 package org.jboss.deployers.plugins.deployer;
 
+import java.util.Map;
+
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.Deployer;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.managed.ManagedObjectBuilder;
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
 
 /**
  * DeployerWrapper.<p>
@@ -35,7 +39,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public class DeployerWrapper implements Deployer
+public class DeployerWrapper implements Deployer, ManagedObjectBuilder
 {
    /** The log */
    private Logger log; 
@@ -43,6 +47,9 @@
    /** The deployer */
    private Deployer deployer;
    
+   /** The managed object builder */
+   private ManagedObjectBuilder managedObjectBuilder;
+   
    /**
     * Create a new DeployerWrapper.
     * 
@@ -54,6 +61,10 @@
          throw new IllegalArgumentException("Null deployer");
       this.deployer = deployer;
       this.log = Logger.getLogger(deployer.getClass());
+      
+      // Check to see whether the deployer also builds managed  objects
+      if (deployer instanceof ManagedObjectBuilder)
+         managedObjectBuilder = (ManagedObjectBuilder) deployer;
    }
    
    public boolean isRelevant(DeploymentUnit unit)
@@ -176,11 +187,35 @@
    {
       return deployer.getRelativeOrder();
    }
+
    public void setRelativeOrder(int order)
    {
       deployer.setRelativeOrder(order);
    }
 
+   public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException
+   {
+      // Not a managed object builder
+      if (managedObjectBuilder == null)
+         return;
+      
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+      if (managedObjects == null)
+         throw new IllegalArgumentException("Null managed objects");
+
+      try
+      {
+         log.trace("build: " + unit.getName());
+         managedObjectBuilder.build(unit, managedObjects);
+         log.trace("built: " + unit.getName());
+      }
+      catch (Throwable t)
+      {
+         log.warn("Error during commit undeployment: " + unit.getName(), t);
+      }
+   }
+
    @Override
    public boolean equals(Object obj)
    {

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AttachmentLocator.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AttachmentLocator.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AttachmentLocator.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -36,6 +36,7 @@
    /**
     * Get a named attachment
     * 
+    * @param unit the deployment unit
     * @param name the name of the attachment
     * @return the attachment or null if not present
     * @throws IllegalArgumentException for a null name
@@ -56,6 +57,7 @@
     * Get named attachment of a given type
     * 
     * @param <T> the expected type
+    * @param unit the deployment unit
     * @param name the name of the attachment
     * @param expectedType the expected type
     * @return the attachment or null if not present
@@ -74,6 +76,7 @@
     * 
     * @param <T> the expected type
     * @param type the type
+    * @param unit the deployment unit
     * @return the attachment or null if not present
     * @throws IllegalArgumentException for a null name or type
     */

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-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -33,6 +33,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -57,13 +58,18 @@
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
 import org.jboss.virtual.VirtualFile;
 
 /**
  * MainDeployerImpl.
  * 
  * TODO full deployer protocol
+ * 
  * TODO sort out a proper state machine
+ * 
+ * TODO implement attachment flow see comment in {@link Deployer}
+ * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
@@ -82,7 +88,7 @@
    private StructureBuilder structureBuilder = new DefaultStructureBuilder();
 
    /** The deployers */
-   private SortedSet<Deployer> deployers = new TreeSet<Deployer>(Deployer.COMPARATOR);
+   private SortedSet<DeployerWrapper> deployers = new TreeSet<DeployerWrapper>(Deployer.COMPARATOR);
    
    /** The deployments by name */
    private Map<String, DeploymentContext> topLevelDeployments = new ConcurrentHashMap<String, DeploymentContext>();
@@ -161,7 +167,9 @@
     */
    public synchronized Set<Deployer> getDeployers()
    {
-      return new TreeSet<Deployer>(deployers);
+      TreeSet<Deployer> result = new TreeSet<Deployer>(Deployer.COMPARATOR);
+      result.addAll(deployers);
+      return result;
    }
    
    /**
@@ -224,6 +232,18 @@
       return allDeployments.get(name);
    }
 
+   public Map<String, ManagedObject> getManagedObjects(DeploymentContext context) throws DeploymentException
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Null context");
+      
+      Map<String, ManagedObject> managedObjects = new HashMap<String, ManagedObject>();
+      for (DeployerWrapper deployer : deployers)
+         deployer.build(context.getDeploymentUnit(), managedObjects);
+      
+      return managedObjects;
+   }
+
    public StructureBuilder getStructureBuilder()
    {
       return structureBuilder;

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ClassPathInfoImpl.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -40,7 +40,7 @@
    private static final long serialVersionUID = 1;
 
    private String path;
-   private HashMap options = new HashMap();
+   private HashMap<Object, Object> options = new HashMap<Object, Object>();
 
    public ClassPathInfoImpl()
    {
@@ -65,7 +65,7 @@
       return options.get(key);
    }
 
-   public Map getOptions()
+   public Map<Object, Object> getOptions()
    {
       return options;
    }
@@ -75,7 +75,7 @@
       options.put(key, value);
    }
 
-   public void setOptions(Map options)
+   public void setOptions(Map<Object, Object> options)
    {
       this.options.clear();
       this.options.putAll(options);

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractCandidateStructureVisitor.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -60,6 +60,8 @@
     * Create a new CandidateStructureVisitor.
     * 
     * @param parent the parent
+    * @param metaData the structure meta data
+    * @param deployers the structure deployers
     * @throws IllegalArgumentException for a null parent
     */
    public AbstractCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers)
@@ -71,6 +73,8 @@
     * Create a new CandidateStructureVisitor.
     * 
     * @param parent the parent
+    * @param metaData the structure meta data
+    * @param deployers the structure deployers
     * @param attributes the attributes
     * @throws IllegalArgumentException for a null parent
     */

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/AbstractStructureDeployer.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -96,7 +96,8 @@
     * 
     * @param file
     * @param metaData
-    * @return
+    * @return true when it is top level
+    * @throws IOException for an error accessing the file
     */
    public boolean isTopLevel(VirtualFile file, StructureMetaData metaData)
       throws IOException
@@ -168,6 +169,8 @@
     * Add all children as candidates
     * 
     * @param parent the parent context
+    * @param metaData the structure meta data
+    * @param deployers the structure deployers
     * @throws Exception for any error
     */
    protected void addAllChildren(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers)
@@ -180,6 +183,8 @@
     * Add all children as candidates
     * 
     * @param parent the parent context
+    * @param metaData the structure meta data
+    * @param deployers the structure deployers
     * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null
     * @throws Exception for any error
     */

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/CandidateStructureVisitorFactory.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -38,6 +38,9 @@
    /**
     * Create the visitor
     * 
+    * @param parent the parent virtual file
+    * @param metaData the structure metaData
+    * @param deployers the structure deployers
     * @param context the deployment context
     * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null
     * @return the visitor

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/StructureDeployerWrapper.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,7 +21,6 @@
 */
 package org.jboss.deployers.plugins.structure.vfs;
 
-import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
 import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARCandidateStructureVisitor.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -39,6 +39,8 @@
     * Create a new JARCandidateStructureVisitor.
     * 
     * @param parent the parent
+    * @param metaData the structure meta data
+    * @param deployers the structure deployers
     * @param attributes the attributes
     * @throws IllegalArgumentException for a null parent
     * @throws Exception for any error

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/jar/JARStructure.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -47,6 +47,7 @@
    /**
     * Sets the default relative order 10000.
     *
+    * @param suffixes the suffixes
     */
    public JARStructure(Set<String> suffixes)
    {

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/vfs/war/WebInfLibFilter.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,7 +21,6 @@
   */
 package org.jboss.deployers.plugins.structure.vfs.war;
 
-import org.jboss.logging.Logger;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilterWithAttributes;
 import org.jboss.virtual.VisitorAttributes;
@@ -35,9 +34,6 @@
  */
 public class WebInfLibFilter implements VirtualFileFilterWithAttributes
 {
-   /** The log */
-   private static final Logger log = Logger.getLogger(WebInfLibFilter.class);
-   
    /** The instance */
    public static final WebInfLibFilter INSTANCE = new WebInfLibFilter();
    

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,8 +21,6 @@
 */
 package org.jboss.deployers.spi.deployer;
 
-import java.util.Comparator;
-
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.OrderedDeployer;
 
@@ -31,6 +29,12 @@
  * 
  * TODO contract for redeployment
  * 
+ * TODO the contract should really be based on attachment flow
+ *      i.e. input/output of attachments
+ *      e.g. - parsing deployer (creates an attachment)
+ *           - component deployers splits one attachment into mulitple attachments
+ *           - real deployer produces the real work for the attachment
+ * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -22,9 +22,11 @@
 package org.jboss.deployers.spi.deployment;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.managed.api.ManagedObject;
 
 /**
  * MainDeployer.<p>
@@ -45,6 +47,15 @@
     * @return the context or null if not found
     */
    DeploymentContext getDeploymentContext(String name);
+
+   /**
+    * Get the managed object for a deployment context
+    *      
+    * @param context the context
+    * @return the managed object
+    * @throws DeploymentException for any error
+    */
+   Map<String, ManagedObject> getManagedObjects(DeploymentContext context) throws DeploymentException;
    
    /**
     * Get the top level deployments

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/managed/ManagedObjectBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/managed/ManagedObjectBuilder.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/managed/ManagedObjectBuilder.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -0,0 +1,58 @@
+/*
+* 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.managed;
+
+import java.util.Map;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.managed.api.ManagedObject;
+
+/**
+ * ManagedObjectBuilder.
+ * 
+ * TODO Critique
+ *      Rather having the contexts create the managed objects directly
+ *      they should provide the underlying metadata, e.g. the Fields + other information
+ *      from which we can create the managed object.
+ *      This is important because it is likely that multiple builders/deployers will
+ *      play populate an object, e.g. (possibly?)
+ *      - the parsing deployer will describe the properties/metadata
+ *      - there maybe transformation, augmentation by some other deployers
+ *      - the component deployers will want to link their component metadata back into
+ *            the parent by reference, e.g. an mbean as part of sar/-service.xml  
+ *      - the real deployer will describe any runtime support, e.g. managed operations and statistics
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectBuilder
+{
+   /**
+    * Build managed objects for this deployment context
+    * 
+    * @param unit the deployment unit
+    * @param managedObjects the managed objects
+    * @throws DeploymentException
+    */
+   void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException;
+}

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/ClassPathInfo.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -32,31 +32,45 @@
 public interface ClassPathInfo
 {
    /**
-    * path relative to the context virtual file.
+    * Get the path relative to the context virtual file
+    * 
+    * @return the path.
     */
-   public String getPath();
-   public void setPath(String path);
+   String getPath();
+   
    /**
+    * Set the path relative to the context virtual file
+    * 
+    * @param path the path
+    */
+   void setPath(String path);
+   
+   /**
     * Get the options associated with the classpath entry.
+    * 
     * @return A map of entry options.
     */
-   public Map getOptions();
+   Map<Object, Object> getOptions();
+   
    /**
     * Set the options associated with the classpath entry.
+    * 
     * @param options - A map of entry options.
     */
-   public void setOptions(Map options);
+   void setOptions(Map<Object, Object> options);
 
    /**
     * Get a classpath entry option
     * @param key - the option key
     * @return the option if it exists, null otherwise
     */
-   public Object getOption(Object key);
+   Object getOption(Object key);
+   
    /**
     * Set a classpath entry option
+    * 
     * @param key - the option key
     * @param value - the option value
     */
-   public void setOption(Object key, Object value);
+   void setOption(Object key, Object value);
 }

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructureBuilder.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -40,7 +40,7 @@
     * @param context - the root deployment context to populate
     * @param metaData - the metadata from a structural parse of the context
     *    root VirtualFile
-    * @throws Exception for any error
+    * @throws DeploymentException for any error
     */
    public void populateContext(DeploymentContext context, StructureMetaData metaData)
       throws DeploymentException;

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/vfs/StructuredDeployers.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -49,9 +49,10 @@
     * @return the ordered set of deployers.
     */
    public SortedSet<StructureDeployer> getDeployers();
+
    /**
     * Are there any deployers
-    * @return 
+    * @return true when empty
     */
    public boolean isEmpty();
 }

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/BaseDeployersTest.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -22,7 +22,6 @@
 package org.jboss.test.deployers;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.HashMap;
@@ -99,7 +98,7 @@
     * Get a vfs url string from a path
     * 
     * @param path
-    * @return
+    * @return the url
     * @throws Exception
     */
    protected String getVfsURL(String path) throws Exception
@@ -137,9 +136,11 @@
       deployers.addDeployer(getStrucutureDeployer());
       return deployers;
    }
+
    /**
     * Get the StructureVisitorFactory that translates the StructureMetaData into a DeploymentContext tree.
-    * @return
+    * 
+    * @return the builder
     */
    protected StructureBuilderFactory getStructureBuilderFactory()
    {
@@ -150,7 +151,9 @@
     * Determine the structure
     * 
     * @param context the context
+    * @param addTopLevelInfo whether to add top level info
     * @return the result
+    * @throws Exception for any error
     */
    protected boolean determineStructure(DeploymentContext context, boolean addTopLevelInfo)
       throws Exception
@@ -163,9 +166,10 @@
    /**
     * Determine the structure
     * 
-    * @param structure the structural deployer
+    * @param deployer the structural deployer
     * @param context the context
     * @return the result
+    * @throws Exception for any error
     */
    protected boolean determineStructure(StructureDeployer deployer,
          DeploymentContext context)
@@ -173,12 +177,15 @@
    {
       return determineStructure(deployer, getStrucuturedDeployers(), context, false);
    }
+
    /**
     * Determine the structure
     * 
-    * @param structure the structural deployer
+    * @param deployer the structural deployer
     * @param context the context
+    * @param addTopLevelInfo whether to add top level info
     * @return the result
+    * @throws Exception for any error
     */
    protected boolean determineStructure(StructureDeployer deployer,
          DeploymentContext context, boolean addTopLevelInfo)
@@ -187,14 +194,15 @@
       return determineStructure(deployer, getStrucuturedDeployers(), context, addTopLevelInfo);
    }
    /**
+    * Determine the structure
     * 
     * @param deployer
     * @param deployers
     * @param context
     * @param addTopLevelInfo - should a ContextInfo be created for the
     *    context root
-    * @return
-    * @throws Exception
+    * @return whether the structure was determined
+    * @throws Exception for any error
     */
    protected boolean determineStructure(StructureDeployer deployer,
          StructuredDeployers deployers, DeploymentContext context,
@@ -353,7 +361,8 @@
     * Translate a set of DeploymentContexts string paths relative to the root
     * URL.
     * 
-    * @param set
+    * @param set the deployment contexts
+    * @param root the root url
     * @return set of 
     * @throws URISyntaxException 
     * @throws IOException 
@@ -386,7 +395,9 @@
     * some.ear/child.jar
     * 
     * @param root ctx
-    * @return
+    * @return the map
+    * @throws IOException for an error accessing the vfs path
+    * @throws URISyntaxException for an error resolving the uri
     */
    protected Map<String, DeploymentContext> createDeploymentPathMap(DeploymentContext root)
       throws IOException, URISyntaxException

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-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/DeployerTestSuite.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -32,6 +32,7 @@
 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.managed.ManagedTestSuite;
 import org.jboss.test.deployers.metadata.test.MetaDataUnitTestCase;
 
 /**
@@ -57,6 +58,7 @@
       suite.addTest(DeployerClassLoaderUnitTestCase.suite());
       suite.addTest(MainDeployerDeployerUnitTestCase.suite());
       suite.addTest(MetaDataUnitTestCase.suite());
+      suite.addTest(ManagedTestSuite.suite());
       suite.addTest(BeanDeployerUnitTestCase.suite());
       suite.addTest(KernelDeployerUnitTestCase.suite());
 

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/ManagedTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/ManagedTestSuite.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/ManagedTestSuite.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -0,0 +1,51 @@
+/*
+* 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.managed;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.deployers.managed.test.DeployerManagedObjectUnitTestCase;
+
+/**
+ * Managed Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 37459 $
+ */
+public class ManagedTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Managed Tests");
+
+      suite.addTest(DeployerManagedObjectUnitTestCase.suite());
+
+      return suite;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestAttachment.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestAttachment.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestAttachment.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -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.managed.support;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * TestAttachment.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestAttachment implements Cloneable, Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private Map<String, Serializable> fields = new HashMap<String, Serializable>();
+
+   public Serializable getProperty(String name)
+   {
+      return fields.get(name);
+   }
+
+   public void setProperty(String name, Serializable value)
+   {
+      fields.put(name, value);
+   }
+   
+   public TestAttachment clone()
+   {
+      try
+      {
+         TestAttachment clone = (TestAttachment) super.clone();
+         clone.fields = new HashMap<String, Serializable>(clone.fields);
+         return clone;
+      }
+      catch (CloneNotSupportedException e)
+      {
+         throw new Error("Unexpected", e);
+      }
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestFields.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestFields.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestFields.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -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.managed.support;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.Fields;
+
+/**
+ * TestFields.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestFields implements Fields
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private TestAttachment attachment;
+   
+   private String property;
+   
+   public TestFields(TestAttachment attachment, String property)
+   {
+      this.attachment = attachment;
+      this.property = property;
+   }
+
+   public Serializable getField(String name)
+   {
+      if (name == Fields.NAME)
+         return property;
+      if (name == Fields.VALUE)
+         return attachment.getProperty(property);
+      return null;
+   }
+
+   public void setField(String name, Serializable value)
+   {
+      if (name == Fields.VALUE)
+      {
+         attachment.setProperty(property, value);
+         return;
+      }
+      throw new UnsupportedOperationException("setField: " + name);
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/support/TestManagedObjectDeployer.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -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.test.deployers.managed.support;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.managed.ManagedObjectBuilder;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+
+/**
+ * TestManagedObjectDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestManagedObjectDeployer extends AbstractSimpleDeployer implements ManagedObjectBuilder
+{
+   public static TestAttachment lastAttachment;
+   
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      lastAttachment = unit.getAttachment(TestAttachment.class);
+      if (lastAttachment == null)
+      {
+         lastAttachment = new TestAttachment();
+         lastAttachment.setProperty("string1", "initialString1");
+         lastAttachment.setProperty("string2", "initialString2");
+         unit.addAttachment(TestAttachment.class, lastAttachment);
+      }
+   }
+
+   public void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException
+   {
+      TestAttachment attachment = unit.getAttachment(TestAttachment.class);
+      if (attachment != null)
+      {
+         attachment = attachment.clone();
+         ManagedObjectImpl managedObject = new ManagedObjectImpl(TestAttachment.class.getName());
+         managedObject.setAttachment(attachment);
+         Set<ManagedProperty> properties = managedObject.getProperties();
+         properties.add(new ManagedPropertyImpl(managedObject, new TestFields(attachment, "string1")));
+         properties.add(new ManagedPropertyImpl(managedObject, new TestFields(attachment, "string2")));
+         managedObjects.put(TestAttachment.class.getName(), managedObject);
+      }
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -0,0 +1,125 @@
+/*
+* 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.managed.test;
+
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.managed.support.TestAttachment;
+import org.jboss.test.deployers.managed.support.TestManagedObjectDeployer;
+
+/**
+ * DeployerManagedObjectUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerManagedObjectUnitTestCase extends BaseDeployersTest
+{
+   private MainDeployer mainDeployer;
+   
+   private TestManagedObjectDeployer deployer = new TestManagedObjectDeployer();
+   
+   public static Test suite()
+   {
+      return new TestSuite(DeployerManagedObjectUnitTestCase.class);
+   }
+   
+   public DeployerManagedObjectUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testManagedObject() throws Exception
+   {
+      MainDeployer main = getMainDeployer();
+      
+      // Deploy a context
+      DeploymentContext context = createSimpleDeployment("deploy");
+      main.addDeploymentContext(context);
+      main.process();
+      
+      // Check the default settings
+      assertNotNull(deployer.lastAttachment);
+      assertEquals("initialString1", deployer.lastAttachment.getProperty("string1"));
+      assertEquals("initialString2", deployer.lastAttachment.getProperty("string2"));
+      
+      // Get the managed object
+      Map<String, ManagedObject> mos = main.getManagedObjects(context);
+      assertNotNull(mos);
+      ManagedObject mo = mos.get(TestAttachment.class.getName());
+      assertNotNull(mo);
+      
+      // TODO the attachment should NOT be the top level managed object
+      //      that should be describing the structure and deployment state
+      //      with the attachments as sub managed objects
+      
+      // Check the managed object has the default settings
+      assertEquals("initialString1", mo.getProperty("string1").getValue());
+      assertEquals("initialString2", mo.getProperty("string2").getValue());
+      
+      // Change a value
+      mo.getProperty("string1").setValue("changedString1");
+      
+      // Get the changed attachment
+      TestAttachment attachment = (TestAttachment) mo.getAttachment();
+
+      // Redeploy with our changed attachment
+      context.getPredeterminedManagedObjects().addAttachment(TestAttachment.class, attachment);
+      main.addDeploymentContext(context);
+      main.process();
+
+      // Check the changed settings as seen by the deployer
+      assertNotNull(deployer.lastAttachment);
+      assertEquals("changedString1", deployer.lastAttachment.getProperty("string1"));
+      assertEquals("initialString2", deployer.lastAttachment.getProperty("string2"));
+      
+      // TODO shouldn't have to reget the managed object handles across redeploys?
+      mos = main.getManagedObjects(context);
+      assertNotNull(mos);
+      mo = mos.get(TestAttachment.class.getName());
+      assertNotNull(mo);
+
+      // Check the changed settings as described by the managed object
+      assertEquals("changedString1", mo.getProperty("string1").getValue());
+      assertEquals("initialString2", mo.getProperty("string2").getValue());
+   }
+   
+   protected MainDeployer getMainDeployer()
+   {
+      if (mainDeployer != null)
+         return mainDeployer;
+      
+      MainDeployerImpl result = new MainDeployerImpl();
+      result.addDeployer(deployer);
+      
+      mainDeployer = result;
+      return result;
+   }
+}

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -26,6 +26,7 @@
 import junit.textui.TestRunner;
 
 import org.jboss.test.deployers.structure.ear.test.EARStructureUnitTestCase;
+import org.jboss.test.deployers.structure.explicit.test.DeclaredStructureUnitTestCase;
 import org.jboss.test.deployers.structure.file.test.FileStructureUnitTestCase;
 import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
 import org.jboss.test.deployers.structure.main.test.MainDeployerFileStructureUnitTestCase;
@@ -56,6 +57,7 @@
       suite.addTest(JARStructureUnitTestCase.suite());
       suite.addTest(WARStructureUnitTestCase.suite());
       suite.addTest(EARStructureUnitTestCase.suite());
+      suite.addTest(DeclaredStructureUnitTestCase.suite());
       suite.addTest(MainDeployerStructureUnitTestCase.suite());
       suite.addTest(MainDeployerStructureOrderingUnitTestCase.suite());
       suite.addTest(MainDeployerFileStructureUnitTestCase.suite());

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -26,7 +26,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
-import java.util.Set;
 
 import org.jboss.deployers.plugins.structure.ContextInfoImpl;
 import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -35,7 +35,6 @@
 import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
 import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
 import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
-import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
 import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/main/test/MainDeployerStructureUnitTestCase.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -23,10 +23,7 @@
 
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
 
 import junit.framework.AssertionFailedError;
 import junit.framework.Test;
@@ -34,10 +31,6 @@
 
 import org.jboss.deployers.plugins.deployment.MainDeployerImpl;
 import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
-import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
-import org.jboss.deployers.plugins.structure.vfs.StructureDeployerWrapper;
-import org.jboss.deployers.plugins.structure.vfs.explicit.DeclaredStructure;
-import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
 import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
 import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
 import org.jboss.deployers.spi.structure.DeploymentContext;

Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/api/ManagedObject.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -33,6 +33,20 @@
 public interface ManagedObject extends Serializable
 {
    /**
+    * Get the attachment name
+    * 
+    * @return the name
+    */
+   String getName();
+   
+   /**
+    * Get the underlying object
+    * 
+    * @return the underlying object
+    */
+   Serializable getAttachment();
+
+   /**
     * Get the property names
     * 
     * @return the property names

Modified: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/ManagedObjectImpl.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,7 +21,7 @@
 */
 package org.jboss.managed.plugins;
 
-import java.util.Collections;
+import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -39,21 +39,70 @@
    /** The serialVersionUID */
    private static final long serialVersionUID = -2588364350006686542L;
 
+   /** The attachment name */
+   private String name;
+   
+   /** The attachment */
+   private Serializable attachment;
+   
    /** The properties */
    private Set<ManagedProperty> properties;
    
    /**
     * Create a new ManagedObjectImpl
     * 
+    * @param name the attachment name
+    */
+   public ManagedObjectImpl(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      
+      this.name = name;
+      properties = new HashSet<ManagedProperty>();
+   }
+   
+   /**
+    * Create a new ManagedObjectImpl
+    * 
+    * @param name the attachment name
     * @param properties the properties 
     */
-   public ManagedObjectImpl(Set<ManagedProperty> properties)
+   public ManagedObjectImpl(String name, Set<ManagedProperty> properties)
    {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
       if (properties == null)
-         properties = Collections.emptySet();
+         throw new IllegalArgumentException("Null properties");
+      
+      this.name = name;
       this.properties = properties;
    }
    
+   /**
+    * Create a new ManagedObjectImpl
+    * 
+    * @param name the attachment name
+    * @param properties the properties 
+    * @param attachment the attachment
+    */
+   public ManagedObjectImpl(String name, Set<ManagedProperty> properties, Serializable attachment)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (properties == null)
+         throw new IllegalArgumentException("Null properties");
+      
+      this.name = name;
+      this.properties = properties;
+      setAttachment(attachment);
+   }
+   
+   public String getName()
+   {
+      return name;
+   }
+
    public Set<String> getPropertyNames()
    {
       Set<String> result = new HashSet<String>(properties.size());
@@ -79,4 +128,43 @@
    {
       return properties;
    }
+
+   public Serializable getAttachment()
+   {
+      return attachment;
+   }
+
+   /**
+    * Set the attachment.
+    * 
+    * @param attachment the attachment.
+    */
+   public void setAttachment(Serializable attachment)
+   {
+      this.attachment = attachment;
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      if (obj == null || obj instanceof ManagedObject == false)
+         return false;
+      
+      ManagedObject other = (ManagedObject) obj;
+      return getName().equals(other.getName()) && getProperties().equals(other.getProperties());
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return name.hashCode();
+   }
+   
+   @Override
+   public String toString()
+   {
+      return "ManagedObject{" + name + "}"; 
+   }
 }

Deleted: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/empty
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/empty	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/empty	2006-12-22 05:06:26 UTC (rev 59205)
@@ -1 +0,0 @@
-empty
\ No newline at end of file

Modified: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java	2006-12-21 22:09:38 UTC (rev 59204)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/mock/MockDataSourceManagedObject.java	2006-12-22 05:06:26 UTC (rev 59205)
@@ -21,7 +21,6 @@
 */
 package org.jboss.test.managed.mock;
 
-import java.util.HashSet;
 import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -54,7 +53,7 @@
     */
    public MockDataSourceManagedObject()
    {
-      super(new HashSet<ManagedProperty>());
+      super("Mock");
       Element element;
       try
       {




More information about the jboss-cvs-commits mailing list