[jboss-cvs] system2/src/main/org/jboss/deployers/plugins ...
Scott Stark
scott.stark at jboss.com
Sat Jul 15 10:10:57 EDT 2006
User: starksm
Date: 06/07/15 10:10:57
Added: src/main/org/jboss/deployers/plugins
DefaultGraphBuilder.java
Log:
A default DeploymentGraphBuilder implementation that creates a graph by performing a depth first traversal of the root DeploymentContext.
Revision Changes Path
1.1 date: 2006/07/15 14:10:57; author: starksm; state: Exp;system2/src/main/org/jboss/deployers/plugins/DefaultGraphBuilder.java
Index: DefaultGraphBuilder.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.deployers.plugins;
import java.util.List;
import org.jboss.deployers.spi.Deployment;
import org.jboss.deployers.spi.DeploymentContext;
import org.jboss.deployers.spi.DeploymentGraphBuilder;
import org.jboss.util.graph.Graph;
import org.jboss.util.graph.Vertex;
/**
* A default DeploymentGraphBuilder implementation that creates a graph
* by performing a depth first traversal of the root DeploymentContext.
*
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
public class DefaultGraphBuilder implements DeploymentGraphBuilder
{
public Graph<DeploymentContext> build(Deployment deployment)
{
Graph<DeploymentContext> graph = new Graph<DeploymentContext>();
DeploymentContext dc = deployment.getRootContext();
Vertex<DeploymentContext> v = new Vertex<DeploymentContext>(dc.getFile().getName(), dc);
depthFirst(graph, v, dc.getSubDeployments());
return graph;
}
private void depthFirst(Graph<DeploymentContext> graph,
Vertex<DeploymentContext> parent, List<DeploymentContext> children)
{
for(int n = 0; n < children.size(); n ++)
{
DeploymentContext dc = children.get(n);
Vertex<DeploymentContext> v = new Vertex<DeploymentContext>(dc.getFile().getName(), dc);
graph.addEdge(parent, v, 0);
}
// If there were
if( children.size() == 0 )
graph.addVertex(parent);
}
}
More information about the jboss-cvs-commits
mailing list