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 'com.google.inject.grapher', 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: