Last active
March 25, 2016 22:55
-
-
Save bchetty/52e0835158d70dd58e74 to your computer and use it in GitHub Desktop.
Guice Grapher Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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