Package com.google.inject.grapher
Class AbstractInjectorGrapher
- java.lang.Object
-
- com.google.inject.grapher.AbstractInjectorGrapher
-
- All Implemented Interfaces:
InjectorGrapher
- Direct Known Subclasses:
GraphvizGrapher
public abstract class AbstractInjectorGrapher extends java.lang.Object implements InjectorGrapher
Abstract injector grapher that builds the dependency graph but doesn't render it.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractInjectorGrapher.GrapherParameters
Parameters used to override default settings of the grapher.
-
Field Summary
Fields Modifier and Type Field Description private AliasCreator
aliasCreator
private EdgeCreator
edgeCreator
private NodeCreator
nodeCreator
private RootKeySetCreator
rootKeySetCreator
-
Constructor Summary
Constructors Constructor Description AbstractInjectorGrapher()
AbstractInjectorGrapher(AbstractInjectorGrapher.GrapherParameters options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
createEdges(java.lang.Iterable<Edge> edges, java.util.Map<NodeId,NodeId> aliases)
private void
createNodes(java.lang.Iterable<Node> nodes, java.util.Map<NodeId,NodeId> aliases)
private java.lang.Iterable<Binding<?>>
getBindings(Injector injector, java.util.Set<Key<?>> root)
Returns the bindings for the root keys and their transitive dependencies.void
graph(Injector injector)
Graphs the guice dependency graph for the given injector using default starting keys.void
graph(Injector injector, java.util.Set<Key<?>> root)
Graphs the guice dependency graph for the given injector using the given starting keys and their transitive dependencies.protected abstract void
newBindingEdge(BindingEdge edge)
Adds a new binding edge to the graph.protected abstract void
newDependencyEdge(DependencyEdge edge)
Adds a new dependency edge to the graph.protected abstract void
newImplementationNode(ImplementationNode node)
Adds a new implementation node to the graph.protected abstract void
newInstanceNode(InstanceNode node)
Adds a new instance node to the graph.protected abstract void
newInterfaceNode(InterfaceNode node)
Adds a new interface node to the graph.protected abstract void
postProcess()
Performs any post processing required after all nodes and edges have been added.protected abstract void
reset()
Resets the state of the grapher before rendering a new graph.private NodeId
resolveAlias(java.util.Map<NodeId,NodeId> aliases, NodeId nodeId)
private java.util.Map<NodeId,NodeId>
resolveAliases(java.lang.Iterable<Alias> aliases)
Transitively resolves aliases.
-
-
-
Field Detail
-
rootKeySetCreator
private final RootKeySetCreator rootKeySetCreator
-
aliasCreator
private final AliasCreator aliasCreator
-
nodeCreator
private final NodeCreator nodeCreator
-
edgeCreator
private final EdgeCreator edgeCreator
-
-
Constructor Detail
-
AbstractInjectorGrapher
public AbstractInjectorGrapher()
-
AbstractInjectorGrapher
public AbstractInjectorGrapher(AbstractInjectorGrapher.GrapherParameters options)
-
-
Method Detail
-
graph
public final void graph(Injector injector) throws java.io.IOException
Description copied from interface:InjectorGrapher
Graphs the guice dependency graph for the given injector using default starting keys.- Specified by:
graph
in interfaceInjectorGrapher
- Throws:
java.io.IOException
-
graph
public final void graph(Injector injector, java.util.Set<Key<?>> root) throws java.io.IOException
Description copied from interface:InjectorGrapher
Graphs the guice dependency graph for the given injector using the given starting keys and their transitive dependencies.- Specified by:
graph
in interfaceInjectorGrapher
- Throws:
java.io.IOException
-
reset
protected abstract void reset() throws java.io.IOException
Resets the state of the grapher before rendering a new graph.- Throws:
java.io.IOException
-
newInterfaceNode
protected abstract void newInterfaceNode(InterfaceNode node) throws java.io.IOException
Adds a new interface node to the graph.- Throws:
java.io.IOException
-
newImplementationNode
protected abstract void newImplementationNode(ImplementationNode node) throws java.io.IOException
Adds a new implementation node to the graph.- Throws:
java.io.IOException
-
newInstanceNode
protected abstract void newInstanceNode(InstanceNode node) throws java.io.IOException
Adds a new instance node to the graph.- Throws:
java.io.IOException
-
newDependencyEdge
protected abstract void newDependencyEdge(DependencyEdge edge) throws java.io.IOException
Adds a new dependency edge to the graph.- Throws:
java.io.IOException
-
newBindingEdge
protected abstract void newBindingEdge(BindingEdge edge) throws java.io.IOException
Adds a new binding edge to the graph.- Throws:
java.io.IOException
-
postProcess
protected abstract void postProcess() throws java.io.IOException
Performs any post processing required after all nodes and edges have been added.- Throws:
java.io.IOException
-
createNodes
private void createNodes(java.lang.Iterable<Node> nodes, java.util.Map<NodeId,NodeId> aliases) throws java.io.IOException
- Throws:
java.io.IOException
-
createEdges
private void createEdges(java.lang.Iterable<Edge> edges, java.util.Map<NodeId,NodeId> aliases) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveAliases
private java.util.Map<NodeId,NodeId> resolveAliases(java.lang.Iterable<Alias> aliases)
Transitively resolves aliases. Given aliases (X to Y) and (Y to Z), it will return mappings (X to Z) and (Y to Z).
-
-