Guice Grapher - Example

Posted on February 20, 2010

Guice provides a 'Grapher' module, as an extension to its framework, to visualize the bindings and the application structure. This module is not yet available in the guice-2.0 version (and is not packed in any of the jar files of this version), but you can download the source code from the Guice's SVN repository and build it for use.

Guice's Grapher module finds all the bindings used for a particular injector and generates a DOT file (plain text graph description language). If you have already installed 'GraphViz', you can use the GVEdit.exe to run these DOT files and generate the schematic of an application using Guice's bindings.

For the example from my other post, I just copied all the sources under '', built my project and ran the main java class, which looks as below:

Running this class, generated a DOT file, which when opened with GraphViz's Editor, looks like:

The above pic, generated from my example project doesn't show much. So, lets use the example bundled with the Guice Source code (under 'extensions'). Using this example, the grapher modules, generates the DOT file, for the following pic:

Blog Categories
The views expressed on this blog are my personal views and do not reflect the views of my employer or campaigns I am supporting.

All sample code is provided for illustrative purposes only. These examples have not been thoroughly tested under all conditions. The writer therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.