[jboss-cvs] JBossAS SVN: r91919 - in projects/mc-tools/grapher/trunk/src: main/java/org/jboss/mctools/grapher/graph and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 3 06:17:52 EDT 2009
Author: alesj
Date: 2009-08-03 06:17:51 -0400 (Mon, 03 Aug 2009)
New Revision: 91919
Added:
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DefaultDependencyTypeMapper.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyType.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyTypes.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependsOnMeDependencyType.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/IDependOnDependencyType.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TypedDependencyType.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/UnresolvedDependencyType.java
Modified:
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherConstants.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AbstractGraphCreator.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AllGraphCreator.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/BeanGraphCreator.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/GraphCreator.java
projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TreeGraphCreator.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java
projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java
Log:
Add DependencyType.
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherConstants.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherConstants.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherConstants.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -21,6 +21,8 @@
*/
package org.jboss.mctools.grapher;
+import org.jboss.mctools.grapher.graph.DefaultDependencyTypeMapper;
+import org.jboss.mctools.grapher.graph.DependencyType;
import org.jboss.mctools.grapher.graph.GraphCreator;
import org.jboss.mctools.grapher.layout.GraphLayout;
import org.jboss.mctools.grapher.map.DefaultGraphCreatorMapper;
@@ -46,6 +48,9 @@
/** The default creator mapper */
public static final GraphComponentMapper<GraphCreator> CREATOR_MAPPER = new DefaultGraphCreatorMapper();
+ /** The default dependency type mapper */
+ public static final GraphComponentMapper<DependencyType> DEPENDENCY_TYPE_MAPPER = new DefaultDependencyTypeMapper();
+
/** The default layout mapper */
public static final GraphComponentMapper<GraphLayout> LAYOUT_MAPPER = new DefaultGraphLayoutMapper();
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -35,6 +35,7 @@
import org.jboss.logging.Logger;
import org.jboss.mc.servlet.vdf.api.KernelControllerVDFConnector;
import org.jboss.mctools.grapher.graph.GraphCreator;
+import org.jboss.mctools.grapher.graph.DependencyType;
import org.jboss.mctools.grapher.layout.GraphLayout;
import org.jboss.mctools.grapher.map.ComponentTypes;
import org.jboss.mctools.grapher.map.GraphComponentMapper;
@@ -63,6 +64,7 @@
private KernelController controller;
private GraphComponentMapper<GraphCreator> creatorMapper;
+ private GraphComponentMapper<DependencyType> dependencyTypeMapper;
private GraphComponentMapper<GraphLayout> layoutMapper;
private GraphComponentMapper<Renderer> rendererMapper;
@@ -78,6 +80,7 @@
controller = connector.getUtility();
creatorMapper = createMapper(config.getInitParameter("creator"), GrapherConstants.CREATOR_MAPPER, GraphCreator.class);
+ dependencyTypeMapper = createMapper(config.getInitParameter("dependency"), GrapherConstants.DEPENDENCY_TYPE_MAPPER, DependencyType.class);
layoutMapper = createMapper(config.getInitParameter("layout"), GrapherConstants.LAYOUT_MAPPER, GraphLayout.class);
rendererMapper = createMapper(config.getInitParameter("renderer"), GrapherConstants.RENDERER_MAPPER, Renderer.class);
@@ -115,8 +118,13 @@
if (log.isTraceEnabled())
log.trace("Invoking creator: " + creator);
- JGraph graph = creator.createGraph(controller, ComponentTypes.createExcludedTypes(request));
+ DependencyType dtype = dependencyTypeMapper.mapComponent(request);
+ if (log.isTraceEnabled())
+ log.trace("Using dependency type: " + dtype);
+
+ JGraph graph = creator.createGraph(controller, dtype, ComponentTypes.createExcludedTypes(request));
+
// apply layout
GraphLayout currentLayout = layoutMapper.mapComponent(request);
currentLayout.applyLayout(graph);
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AbstractGraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AbstractGraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AbstractGraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -55,11 +55,11 @@
/** The graph component factory */
private static GraphComponentFactory factory = new DefaultGraphComponentFactory();
- public JGraph createGraph(KernelController controller, Class<? extends ControllerContext>... excludedTypes)
+ public JGraph createGraph(KernelController controller, DependencyType dtype, Class<? extends ControllerContext>... excludedTypes)
{
Map attributes = new HashMap();
ConnectionSet cs = new ConnectionSet();
- Object[] cells = createCells(controller, attributes, cs, excludedTypes);
+ Object[] cells = createCells(controller, dtype, attributes, cs, excludedTypes);
return createGraph(cells, attributes, cs);
}
@@ -67,16 +67,17 @@
* Create cells.
*
* @param controller the controller
+ * @param dtype dependency type
* @param attributes the attributes
* @param cs the connection set
* @param excludedTypes the excluded component types
* @return graph cells
*/
- protected Object[] createCells(KernelController controller, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ protected Object[] createCells(KernelController controller, DependencyType dtype, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
Map<Object, GraphCell> cells = new HashMap<Object, GraphCell>();
Set<Object> objects = new HashSet<Object>();
- createCells(controller, cells, objects, attributes, cs, excludedTypes);
+ createCells(controller, dtype, cells, objects, attributes, cs, excludedTypes);
// change to array
Object[] graph = new Object[objects.size()];
@@ -91,13 +92,14 @@
* Do create cells.
*
* @param controller the controller
+ * @param dtype dependency type
* @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 abstract void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes);
+ protected abstract void createCells(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes);
/**
* Do we recurse into context.
@@ -114,6 +116,7 @@
* Handle single context.
*
* @param controller the controller
+ * @param dtype dependency type
* @param cells the cells
* @param objects the graph's objects
* @param attributes the graph attributes
@@ -122,7 +125,7 @@
* @param excludedTypes the excluded component types
*/
@SuppressWarnings({"UnusedDeclaration"})
- protected void handleContext(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, ControllerContext context, Class<? extends ControllerContext>... excludedTypes)
+ protected void handleContext(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, ControllerContext context, Class<? extends ControllerContext>... excludedTypes)
{
if (isComponentExcluded(context, excludedTypes))
{
@@ -138,17 +141,17 @@
GraphCell owner = getCell(cells, objects, context);
- Set<DependencyItem> items = info.getIDependOn(null);
+ Set<DependencyItem> items = dtype.getDependencies(info);
if (items != null && items.isEmpty() == false)
{
for(DependencyItem item : items)
{
- Object iDependOn = item.getIDependOn();
- GraphCell dependency = cells.get(iDependOn);
+ Object dependencyId = dtype.getDependency(item);
+ GraphCell dependency = cells.get(dependencyId);
ControllerContext dependant = null;
if (dependency == null || (excludedTypes != null && excludedTypes.length > 0))
{
- dependant = controller.getContext(iDependOn, null);
+ dependant = controller.getContext(dependencyId, null);
if (dependant != null)
{
if (isComponentExcluded(dependant, excludedTypes))
@@ -163,18 +166,19 @@
}
else
{
- dependency = createCell(iDependOn);
- cells.put(iDependOn, dependency);
+ dependency = createCell(dependencyId);
+ cells.put(dependencyId, dependency);
objects.add(dependency);
}
}
ControllerState state = item.getWhenRequired();
- Edge edge = factory.createEdge(state != null ? state.getStateString() : "UNKNOWN", owner, dependency, cs);
+ Object[] order = dtype.getEdgeOrder(owner, dependency);
+ Edge edge = factory.createEdge(state != null ? state.getStateString() : "UNKNOWN", (GraphCell)order[0], (GraphCell)order[1], cs);
objects.add(edge);
if (dependant != null && doRecurse(dependant))
- handleContext(controller, cells, objects, attributes, cs, dependant);
+ handleContext(controller, dtype, cells, objects, attributes, cs, dependant);
}
}
}
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AllGraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AllGraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/AllGraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -38,7 +38,7 @@
*/
public class AllGraphCreator extends AbstractGraphCreator
{
- protected void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ protected void createCells(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
ControllerStateModel model = controller.getStates();
for (ControllerState state : model)
@@ -46,7 +46,7 @@
Set<ControllerContext> contexts = controller.getContextsByState(state);
for (ControllerContext context : contexts)
{
- handleContext(controller, cells, objects, attributes, cs, context, excludedTypes);
+ handleContext(controller, dtype, cells, objects, attributes, cs, context, excludedTypes);
}
}
}
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/BeanGraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/BeanGraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/BeanGraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -46,13 +46,13 @@
this.bean = bean;
}
- protected void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ protected void createCells(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
ControllerContext context = controller.getContext(bean, null);
if (context == null)
throw new IllegalArgumentException("No such context: " + bean);
- handleContext(controller, cells, objects, attributes, cs, context, excludedTypes);
+ handleContext(controller, dtype, cells, objects, attributes, cs, context, excludedTypes);
}
@Override
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DefaultDependencyTypeMapper.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DefaultDependencyTypeMapper.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DefaultDependencyTypeMapper.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,56 @@
+/*
+ * 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.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.mctools.grapher.map.GraphComponentMapper;
+
+/**
+ * Dependency type mapper.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class DefaultDependencyTypeMapper implements GraphComponentMapper<DependencyType>
+{
+ public void init(Map<String, String> config)
+ {
+ }
+
+ public DependencyType mapComponent(HttpServletRequest request)
+ {
+ String key = "dependency";
+ return mapComponent(key, request.getParameter(key));
+ }
+
+ public DependencyType mapComponent(String key, String value)
+ {
+ if ("DependsOnMe".equalsIgnoreCase(value))
+ return DependencyTypes.DependsOnMe;
+ else if ("Unresolved".equalsIgnoreCase(value))
+ return DependencyTypes.Unresolved;
+ else
+ return DependencyTypes.IDependOn;
+ }
+}
\ No newline at end of file
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyType.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyType.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyType.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,63 @@
+/*
+ * 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.Set;
+
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+
+/**
+ * Dependency type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface DependencyType
+{
+ /**
+ * Get dependencies.
+ *
+ * @param info the dependency info
+ * @return dependency items
+ */
+ Set<DependencyItem> getDependencies(DependencyInfo info);
+
+ /**
+ * Get dependency id.
+ *
+ * @param item the dependency item
+ * @return dependency id
+ */
+ Object getDependency(DependencyItem item);
+
+ /**
+ * Get edge order.
+ *
+ * This should return array with 2 elements,
+ * first element is the start, second is the end of the edge.
+ *
+ * @param owner the owner
+ * @param dependency the dependency
+ * @return edge order array
+ */
+ Object[] getEdgeOrder(Object owner, Object dependency);
+}
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyTypes.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyTypes.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependencyTypes.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Dependency types.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class DependencyTypes
+{
+ public static final DependencyType IDependOn = new IDependOnDependencyType();
+
+ public static final DependencyType DependsOnMe = new DependsOnMeDependencyType();
+
+ public static final DependencyType Unresolved = new UnresolvedDependencyType();
+}
\ No newline at end of file
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependsOnMeDependencyType.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependsOnMeDependencyType.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DependsOnMeDependencyType.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,59 @@
+/*
+ * 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.Set;
+
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+
+/**
+ * DependsOnMe dependency type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DependsOnMeDependencyType extends TypedDependencyType
+{
+ public DependsOnMeDependencyType()
+ {
+ }
+
+ public DependsOnMeDependencyType(Class<?> type)
+ {
+ super(type);
+ }
+
+ public Set<DependencyItem> getDependencies(DependencyInfo info)
+ {
+ return info.getDependsOnMe(getType());
+ }
+
+ public Object getDependency(DependencyItem item)
+ {
+ return item.getName();
+ }
+
+ public Object[] getEdgeOrder(Object owner, Object dependency)
+ {
+ return new Object[]{dependency, owner};
+ }
+}
\ No newline at end of file
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/DeploymentGraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -70,7 +70,7 @@
visited = new HashSet<Object>();
}
- protected void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ protected void createCells(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
ControllerContext structureCC = controller.getInstalledContext("MainDeployer");
if (structureCC == null)
@@ -80,7 +80,7 @@
{
MainDeployerStructure structure = MainDeployerStructure.class.cast(structureCC.getTarget());
DeploymentUnit unit = structure.getDeploymentUnit(generateName());
- handleDeploymentUnit(unit, controller, cells, objects, attributes, cs, excludedTypes);
+ handleDeploymentUnit(unit, controller, dtype, cells, objects, attributes, cs, excludedTypes);
}
catch (Exception e)
{
@@ -108,13 +108,14 @@
*
* @param unit the deployment unit
* @param controller the controller
+ * @param dtype dependency type
* @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)
+ protected void handleDeploymentUnit(DeploymentUnit unit, KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
if (unit == null)
return;
@@ -126,14 +127,14 @@
{
ControllerContext context = controller.getContext(name, null);
if (context != null)
- handleContext(controller, cells, objects, attributes, cs, context, excludedTypes);
+ handleContext(controller, dtype, cells, objects, attributes, cs, context, excludedTypes);
}
}
// handle children
- handleDeploymentUnits(unit.getChildren(), controller, cells, objects, attributes, cs, excludedTypes);
+ handleDeploymentUnits(unit.getChildren(), controller, dtype, cells, objects, attributes, cs, excludedTypes);
// handle components
- handleDeploymentUnits(unit.getComponents(), controller, cells, objects, attributes, cs, excludedTypes);
+ handleDeploymentUnits(unit.getComponents(), controller, dtype, cells, objects, attributes, cs, excludedTypes);
}
/**
@@ -141,19 +142,20 @@
*
* @param units the deployment units
* @param controller the controller
+ * @param dtype dependency type
* @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)
+ protected void handleDeploymentUnits(List<DeploymentUnit> units, KernelController controller, DependencyType dtype, 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);
+ handleDeploymentUnit(unit, controller, dtype, cells, objects, attributes, cs, excludedTypes);
}
@Override
Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/GraphCreator.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/GraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/GraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -38,8 +38,9 @@
* Create graph.
*
* @param controller the controller
+ * @param dtype dependency type
* @param excludedTypes the excluded component types
* @return new jgraph instance
*/
- JGraph createGraph(KernelController controller, Class<? extends ControllerContext>... excludedTypes);
+ JGraph createGraph(KernelController controller, DependencyType dtype, Class<? extends ControllerContext>... excludedTypes);
}
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/IDependOnDependencyType.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/IDependOnDependencyType.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/IDependOnDependencyType.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,59 @@
+/*
+ * 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.Set;
+
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+
+/**
+ * IDependOn dependency type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IDependOnDependencyType extends TypedDependencyType
+{
+ public IDependOnDependencyType()
+ {
+ }
+
+ public IDependOnDependencyType(Class<?> type)
+ {
+ super(type);
+ }
+
+ public Set<DependencyItem> getDependencies(DependencyInfo info)
+ {
+ return info.getIDependOn(getType());
+ }
+
+ public Object getDependency(DependencyItem item)
+ {
+ return item.getIDependOn();
+ }
+
+ public Object[] getEdgeOrder(Object owner, Object dependency)
+ {
+ return new Object[]{owner, dependency};
+ }
+}
\ No newline at end of file
Modified: 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/TreeGraphCreator.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TreeGraphCreator.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -49,13 +49,13 @@
visited = new HashSet<Object>();
}
- protected void createCells(KernelController controller, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
+ protected void createCells(KernelController controller, DependencyType dtype, Map<Object, GraphCell> cells, Set<Object> objects, Map attributes, ConnectionSet cs, Class<? extends ControllerContext>... excludedTypes)
{
ControllerContext context = controller.getContext(root, null);
if (context == null)
throw new IllegalArgumentException("No such context: " + root);
- handleContext(controller, cells, objects, attributes, cs, context, excludedTypes);
+ handleContext(controller, dtype, cells, objects, attributes, cs, context, excludedTypes);
}
@Override
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TypedDependencyType.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TypedDependencyType.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/TypedDependencyType.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+/**
+ * IDependOn dependency type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class TypedDependencyType implements DependencyType
+{
+ private Class<?> type;
+
+ protected TypedDependencyType()
+ {
+ }
+
+ protected TypedDependencyType(Class<?> type)
+ {
+ this.type = type;
+ }
+
+ /**
+ * Get dependency type.
+ *
+ * @return the dependency type
+ */
+ protected Class<?> getType()
+ {
+ return type;
+ }
+}
\ No newline at end of file
Added: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/UnresolvedDependencyType.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/UnresolvedDependencyType.java (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/graph/UnresolvedDependencyType.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -0,0 +1,62 @@
+/*
+ * 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.Set;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+
+/**
+ * Unresolved dependency type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class UnresolvedDependencyType implements DependencyType
+{
+ private ControllerState state;
+
+ public UnresolvedDependencyType()
+ {
+ }
+
+ public UnresolvedDependencyType(ControllerState state)
+ {
+ this.state = state;
+ }
+
+ public Set<DependencyItem> getDependencies(DependencyInfo info)
+ {
+ return info.getUnresolvedDependencies(state);
+ }
+
+ public Object getDependency(DependencyItem item)
+ {
+ return item.getIDependOn();
+ }
+
+ public Object[] getEdgeOrder(Object owner, Object dependency)
+ {
+ return new Object[]{owner, dependency};
+ }
+}
\ No newline at end of file
Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/graph/test/GraphCreatorTestCase.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -28,6 +28,8 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.mctools.grapher.graph.AllGraphCreator;
import org.jboss.mctools.grapher.graph.BeanGraphCreator;
+import org.jboss.mctools.grapher.graph.DependencyType;
+import org.jboss.mctools.grapher.graph.DependencyTypes;
import org.jboss.mctools.grapher.graph.GEdge;
import org.jboss.mctools.grapher.graph.GVertex;
import org.jboss.mctools.grapher.graph.GraphCreator;
@@ -58,14 +60,14 @@
return "Owner";
}
- protected void assertGraphCreator(GraphCreator creator, int vertices, int edges, String... excludes)
+ protected void assertGraphCreator(GraphCreator creator, DependencyType dtype, int vertices, int edges, String... excludes)
{
Class<? extends ControllerContext>[] excluded = ComponentTypes.createExcludedTypes(false, excludes);
- JGraph graph = creator.createGraph(getKernelController(), excluded);
+ JGraph graph = creator.createGraph(getKernelController(), dtype, excluded);
Object[] roots = graph.getRoots();
assertNotNull(roots);
// make sure we just have vertices and edges
- assertEquals(roots.length, vertices + edges);
+ assertEquals(vertices + edges, roots.length);
for (Object cell : roots)
{
if (cell instanceof GEdge)
@@ -79,18 +81,35 @@
public void testAll()
{
- assertGraphCreator(new AllGraphCreator(), 5, 4);
+ assertGraphCreator(new AllGraphCreator(), DependencyTypes.IDependOn, 5, 4);
+ assertGraphCreator(new AllGraphCreator(), DependencyTypes.DependsOnMe, 5, 4);
+ assertGraphCreator(new AllGraphCreator(), DependencyTypes.Unresolved, 5, 0);
}
public void testBean()
{
- assertGraphCreator(new BeanGraphCreator("Dep2"), 2, 2);
+ assertGraphCreator(new BeanGraphCreator("Dep2"), DependencyTypes.IDependOn, 2, 2);
+ assertGraphCreator(new BeanGraphCreator("Dep2"), DependencyTypes.DependsOnMe, 1, 0);
+ assertGraphCreator(new BeanGraphCreator("Dep2"), DependencyTypes.Unresolved, 1, 0);
+
+ assertGraphCreator(new BeanGraphCreator("Owner"), DependencyTypes.IDependOn, 1, 0);
+ assertGraphCreator(new BeanGraphCreator("Owner"), DependencyTypes.DependsOnMe, 2, 1);
+ assertGraphCreator(new BeanGraphCreator("Owner"), DependencyTypes.Unresolved, 1, 0);
}
public void testTree()
{
- assertGraphCreator(new TreeGraphCreator("Dep2"), 3, 3);
- assertGraphCreator(new TreeGraphCreator("BF2"), 2, 1);
+ assertGraphCreator(new TreeGraphCreator("Dep2"), DependencyTypes.IDependOn, 3, 3);
+ assertGraphCreator(new TreeGraphCreator("Dep2"), DependencyTypes.DependsOnMe, 1, 0);
+ assertGraphCreator(new TreeGraphCreator("Dep2"), DependencyTypes.Unresolved, 1, 0);
+
+ assertGraphCreator(new TreeGraphCreator("BF2"), DependencyTypes.IDependOn, 2, 1);
+ assertGraphCreator(new TreeGraphCreator("BF2"), DependencyTypes.DependsOnMe, 1, 0);
+ assertGraphCreator(new TreeGraphCreator("BF2"), DependencyTypes.Unresolved, 1, 0);
+
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.IDependOn, 1, 0);
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.DependsOnMe, 3, 3);
+ assertGraphCreator(new TreeGraphCreator("Owner"), DependencyTypes.Unresolved, 1, 0);
}
public void testExcludePojos() throws Throwable
@@ -99,7 +118,7 @@
controller.addAlias("ExtAlias", "Owner");
try
{
- assertGraphCreator(new AllGraphCreator(), 1, 0, "pojo");
+ assertGraphCreator(new AllGraphCreator(), DependencyTypes.IDependOn, 1, 0, "pojo");
}
finally
{
@@ -113,7 +132,7 @@
controller.addAlias("ExtAlias", "Owner");
try
{
- assertGraphCreator(new AllGraphCreator(), 5, 4, "alias");
+ assertGraphCreator(new AllGraphCreator(), DependencyTypes.IDependOn, 5, 4, "alias");
}
finally
{
Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/RendererTestCase.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -24,6 +24,7 @@
import java.io.ByteArrayOutputStream;
import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.DependencyTypes;
import org.jboss.mctools.grapher.graph.GraphCreator;
import org.jboss.mctools.grapher.map.DefaultGraphCreatorMapper;
import org.jgraph.JGraph;
@@ -64,6 +65,6 @@
public JGraph createGraph()
{
GraphCreator creator = DefaultGraphCreatorMapper.ALL;
- return creator.createGraph(getKernelController());
+ return creator.createGraph(getKernelController(), DependencyTypes.IDependOn);
}
}
\ No newline at end of file
Modified: projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java 2009-08-03 07:08:08 UTC (rev 91918)
+++ projects/mc-tools/grapher/trunk/src/test/java/org/jboss/test/mctools/grapher/render/test/Write2FileTestCase.java 2009-08-03 10:17:51 UTC (rev 91919)
@@ -28,6 +28,7 @@
import java.security.ProtectionDomain;
import junit.framework.Test;
+import org.jboss.mctools.grapher.graph.DependencyTypes;
import org.jboss.mctools.grapher.graph.GraphCreator;
import org.jboss.mctools.grapher.map.DefaultGraphCreatorMapper;
import org.jgraph.JGraph;
@@ -83,7 +84,7 @@
public JGraph createGraph()
{
GraphCreator creator = DefaultGraphCreatorMapper.ALL;
- return creator.createGraph(getKernelController());
+ return creator.createGraph(getKernelController(), DependencyTypes.IDependOn);
}
public void setDeleteFile(boolean deleteFile)
More information about the jboss-cvs-commits
mailing list