Skip to content

Instantly share code, notes, and snippets.

@bchetty
Last active March 25, 2016 22:55
Show Gist options
  • Save bchetty/52e0835158d70dd58e74 to your computer and use it in GitHub Desktop.
Save bchetty/52e0835158d70dd58e74 to your computer and use it in GitHub Desktop.
Guice Grapher Class
package com.chetty.client;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import com.chetty.module.MathModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.grapher.GrapherModule;
import com.google.inject.grapher.InjectorGrapher;
import com.google.inject.grapher.graphviz.GraphvizModule;
import com.google.inject.grapher.graphviz.GraphvizRenderer;
public class MathApp {
public static void main(String[] args) throws IOException {
Injector injector = Guice.createInjector(new MathModule());
MathClient mathClient = injector.getInstance(MathClient.class);
mathClient.sumOfAllConsecutiveNumbers(1000);
PrintWriter out = new PrintWriter(new File("c://MathAppGraph.dot"), "UTF-8");
Injector graphInjector = Guice.createInjector(new GrapherModule(), new GraphvizModule());
GraphvizRenderer renderer = graphInjector.getInstance(GraphvizRenderer.class);
renderer.setOut(out).setRankdir("TB");
graphInjector.getInstance(InjectorGrapher.class)
.of(injector)
.graph();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment