[jboss-cvs] JBossAS SVN: r59298 - in projects/microcontainer/trunk/deployers: . src/main/org/jboss/deployers/plugins/deployment src/main/org/jboss/deployers/spi/deployment src/tests/org/jboss/test/deployers/managed/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 3 02:58:35 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-03 02:58:31 -0500 (Wed, 03 Jan 2007)
New Revision: 59298

Modified:
   projects/microcontainer/trunk/deployers/.classpath
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java
Log:
Add support for obtaining a graph of the managed objects in a deployment.

Modified: projects/microcontainer/trunk/deployers/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers/.classpath	2007-01-03 04:48:48 UTC (rev 59297)
+++ projects/microcontainer/trunk/deployers/.classpath	2007-01-03 07:58:31 UTC (rev 59298)
@@ -1,20 +1,20 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<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="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>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<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="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/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-01-03 04:48:48 UTC (rev 59297)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java	2007-01-03 07:58:31 UTC (rev 59298)
@@ -59,6 +59,8 @@
 import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.util.graph.Graph;
+import org.jboss.util.graph.Vertex;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -243,6 +245,36 @@
       
       return managedObjects;
    }
+   /**
+    * 
+    */
+   public Graph<Map<String, ManagedObject>> getManagedObjects(String name) throws DeploymentException
+   {
+      DeploymentContext context = getDeploymentContext(name);
+      Graph<Map<String, ManagedObject>> managedObjectsGraph = new Graph<Map<String, ManagedObject>>();
+      Vertex<Map<String, ManagedObject>> parent = new Vertex<Map<String, ManagedObject>>(context.getName());
+      managedObjectsGraph.setRootVertex(parent);
+      Map<String, ManagedObject> managedObjects = getManagedObjects(context);
+      parent.setData(managedObjects);
+      processContext(context, managedObjectsGraph, parent);
+      
+      return managedObjectsGraph;
+   }
+   protected void processContext(DeploymentContext context,
+         Graph<Map<String, ManagedObject>> graph,
+         Vertex<Map<String, ManagedObject>> parent)
+      throws DeploymentException
+   {
+      Set<DeploymentContext> children = context.getChildren();
+      for(DeploymentContext child : children)
+      {
+         Vertex<Map<String, ManagedObject>> vertex = new Vertex<Map<String, ManagedObject>>(child.getName());
+         Map<String, ManagedObject> managedObjects = getManagedObjects(context);
+         vertex.setData(managedObjects);
+         graph.addEdge(parent, vertex, 0);
+         processContext(child, graph, vertex);
+      }
+   }
 
    public StructureBuilder getStructureBuilder()
    {

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	2007-01-03 04:48:48 UTC (rev 59297)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java	2007-01-03 07:58:31 UTC (rev 59298)
@@ -27,7 +27,9 @@
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.util.graph.Graph;
 
+
 /**
  * MainDeployer.<p>
  * 
@@ -55,9 +57,16 @@
     * @return the managed object
     * @throws DeploymentException for any error
     */
-   Map<String, ManagedObject> getManagedObjects(DeploymentContext context) throws DeploymentException;
-   
+   public Map<String, ManagedObject> getManagedObjects(DeploymentContext context) throws DeploymentException;
    /**
+    * Get the graph of managed objects starting with the top-level deployment associated with name.
+    * @param name - the name of the top-level DeploymentContext to process.
+    * @return the graph of managed objects for the top-level DeploymentContex and its children.
+    * @throws DeploymentException
+    */
+   public Graph<Map<String, ManagedObject>> getManagedObjects(String name) throws DeploymentException;
+
+   /**
     * Get the top level deployments
     * 
     * @return the top level deployments

Modified: 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	2007-01-03 04:48:48 UTC (rev 59297)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/managed/test/DeployerManagedObjectUnitTestCase.java	2007-01-03 07:58:31 UTC (rev 59298)
@@ -33,6 +33,7 @@
 import org.jboss.test.deployers.BaseDeployersTest;
 import org.jboss.test.deployers.managed.support.TestAttachment;
 import org.jboss.test.deployers.managed.support.TestManagedObjectDeployer;
+import org.jboss.util.graph.Graph;
 
 /**
  * DeployerManagedObjectUnitTestCase.
@@ -75,7 +76,14 @@
       assertNotNull(mos);
       ManagedObject mo = mos.get(TestAttachment.class.getName());
       assertNotNull(mo);
-      
+      //
+      Graph<Map<String, ManagedObject>> mosg = main.getManagedObjects(context.getName());
+      assertEquals("MO Graph", mosg.size(), 1);
+      mos = mosg.getRootVertex().getData();
+      assertNotNull(mos);
+      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




More information about the jboss-cvs-commits mailing list