Skip to content

Grapher Integration

Randgalt edited this page Dec 3, 2012 · 1 revision

Governator integrates the Guice Grapher that enables visualizing your injection hierarchy. See here for more details about Grapher.

To create the graph, either allocate or inject an instance of Governator’s Grapher class and then call one of its generation methods. E.g.

@AutoBindSingleton
public class GraphFileCreator
{
    private final Grapher grapher;

    @Inject
    public GraphFileCreator(Grapher grapher)
    {
        this.grapher = grapher;
    }

    @PostConstruct
    public void createGraphFile() throws Exception
    {
        grapher.toFile(new File("mygraph.dot"));
    }
}

This will create a file named “mygraph.dot” in the working directory that can be viewed with XDot.