[jboss-cvs] JBossAS SVN: r91378 - in projects/mc-tools/grapher/trunk: src/main/java/org/jboss/mctools/grapher/graph and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 17 11:49:19 EDT 2009
Author: alesj
Date: 2009-07-17 11:49:19 -0400 (Fri, 17 Jul 2009)
New Revision: 91378
Added:
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java
Modified:
projects/mc-tools/grapher/trunk/pom.xml
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/DefaultGraphCreatorMapper.java
Log:
Allow for deployment inspection.
Modified: projects/mc-tools/grapher/trunk/pom.xml
===================================================================
--- projects/mc-tools/grapher/trunk/pom.xml 2009-07-17 15:48:30 UTC (rev 91377)
+++ projects/mc-tools/grapher/trunk/pom.xml 2009-07-17 15:49:19 UTC (rev 91378)
@@ -163,21 +163,35 @@
-->
<dependency>
+ <groupId>jboss.web</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.1.2.GA</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<version>2.2.14.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.0.5.GA</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-kernel</artifactId>
<version>2.0.7.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>jboss.web</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.1.2.GA</version>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-structure-spi</artifactId>
+ <version>2.0.8.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -239,12 +253,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>2.0.5.GA</version>
- <scope>provided</scope>
- </dependency>
<!-- test dependencies -->
<dependency>
Copied: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java (from rev 91344, projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TreeGraphCreator.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java 2009-07-17 15:49:19 UTC (rev 91378)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.mctools.grapher.graph;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jgraph.graph.ConnectionSet;
+import org.jgraph.graph.GraphCell;
+
+/**
+ * Render single bean.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DeploymentGraphCreator extends AbstractGraphCreator
+{
+ private String deploymentName;
+ private Set<Object> visited;
+
+ public DeploymentGraphCreator(String deploymentName)
+ {
+ if (deploymentName == null)
+ throw new IllegalArgumentException("Null deployment name");
+
+ this.deploymentName = deploymentName;
+ visited = new HashSet<Object>();
+ }
+
+ protected void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ {
+ ControllerContext structureCC = controller.getInstalledContext("MainDeployer");
+ if (structureCC == null)
+ throw new IllegalArgumentException("No MainDeployerStructure found.");
+
+ MainDeployerStructure structure = MainDeployerStructure.class.cast(structureCC.getTarget());
+ DeploymentUnit unit = structure.getDeploymentUnit(deploymentName);
+ handleDeploymentUnit(unit, controller, cells, objects, attributes, cs, excludedTypes);
+ }
+
+ /**
+ * Handle deployment unit.
+ *
+ * @param unit the deployment unit
+ * @param controller the controller
+ * @param cells the cells
+ * @param objects the graph's objects
+ * @param attributes the graph attributes
+ * @param cs the connection set
+ * @param excludedTypes the excluded component types
+ */
+ protected void handleDeploymentUnit(DeploymentUnit unit, KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ {
+ if (unit == null)
+ return;
+
+ Set<Object> names = unit.getControllerContextNames();
+ if (names != null && names.isEmpty() == false)
+ {
+ for (Object name : names)
+ {
+ ControllerContext context = controller.getContext(name, null);
+ if (context != null)
+ handleContext(controller, cells, objects, attributes, cs, context, excludedTypes);
+ }
+ }
+
+ // handle children
+ handleDeploymentUnits(unit.getChildren(), controller, cells, objects, attributes, cs, excludedTypes);
+ // handle components
+ handleDeploymentUnits(unit.getComponents(), controller, cells, objects, attributes, cs, excludedTypes);
+ }
+
+ /**
+ * Handle deployment unit.
+ *
+ * @param units the deployment units
+ * @param controller the controller
+ * @param cells the cells
+ * @param objects the graph's objects
+ * @param attributes the graph attributes
+ * @param cs the connection set
+ * @param excludedTypes the excluded component types
+ */
+ protected void handleDeploymentUnits(List<DeploymentUnit> units, KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ {
+ if (units == null || units.isEmpty())
+ return;
+
+ for (DeploymentUnit unit : units)
+ handleDeploymentUnit(unit, controller, cells, objects, attributes, cs, excludedTypes);
+ }
+
+ @Override
+ protected boolean doRecurse(ControllerContext context)
+ {
+ Object name = context.getName();
+ return visited.add(name);
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "[deployment=" + deploymentName + "]";
+ }
+}
\ No newline at end of file
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/DefaultGraphCreatorMapper.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/DefaultGraphCreatorMapper.java 2009-07-17 15:48:30 UTC (rev 91377)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/DefaultGraphCreatorMapper.java 2009-07-17 15:49:19 UTC (rev 91378)
@@ -26,6 +26,7 @@
import org.jboss.mctools.grapher.graph.BeanGraphCreator;
import org.jboss.mctools.grapher.graph.GraphCreator;
import org.jboss.mctools.grapher.graph.TreeGraphCreator;
+import org.jboss.mctools.grapher.graph.DeploymentGraphCreator;
/**
* Default graph creator mapper.
@@ -44,6 +45,10 @@
if (root != null)
return new TreeGraphCreator(bean);
+ String deployment = request.getParameter("deployment");
+ if (deployment != null)
+ return new DeploymentGraphCreator(deployment);
+
return ALL;
}
}
More information about the jboss-cvs-commits
mailing list