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 classAbstractInjectorGrapher.GrapherParametersParameters used to override default settings of the grapher.
-
Field Summary
Fields Modifier and Type Field Description private AliasCreatoraliasCreatorprivate EdgeCreatoredgeCreatorprivate NodeCreatornodeCreatorprivate RootKeySetCreatorrootKeySetCreator
-
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 voidcreateEdges(java.lang.Iterable<Edge> edges, java.util.Map<NodeId,NodeId> aliases)private voidcreateNodes(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.voidgraph(Injector injector)Graphs the guice dependency graph for the given injector using default starting keys.voidgraph(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 voidnewBindingEdge(BindingEdge edge)Adds a new binding edge to the graph.protected abstract voidnewDependencyEdge(DependencyEdge edge)Adds a new dependency edge to the graph.protected abstract voidnewImplementationNode(ImplementationNode node)Adds a new implementation node to the graph.protected abstract voidnewInstanceNode(InstanceNode node)Adds a new instance node to the graph.protected abstract voidnewInterfaceNode(InterfaceNode node)Adds a new interface node to the graph.protected abstract voidpostProcess()Performs any post processing required after all nodes and edges have been added.protected abstract voidreset()Resets the state of the grapher before rendering a new graph.private NodeIdresolveAlias(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:InjectorGrapherGraphs the guice dependency graph for the given injector using default starting keys.- Specified by:
graphin 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:InjectorGrapherGraphs the guice dependency graph for the given injector using the given starting keys and their transitive dependencies.- Specified by:
graphin interfaceInjectorGrapher- Throws:
java.io.IOException
-
reset
protected abstract void reset() throws java.io.IOExceptionResets 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.IOExceptionPerforms 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).
-
-