Created
July 7, 2014 18:24
Migrated attachment for Guice issue 472, comment 0
This file contains 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
public class A { | |
public static void main(String[] args) { | |
Injector injector = Guice.createInjector(); | |
Injector childInjector = injector.createChildInjector(); | |
System.out.println("Parent: " + injector.hashCode()); | |
System.out.println("Child: " + childInjector.hashCode()); | |
A a = childInjector.getInstance(A.class); | |
a.doStuff(); | |
} | |
private final Injector injector; | |
@Inject | |
A(Injector injector) { | |
this.injector = injector; | |
} | |
public void doStuff() { | |
System.out.println("Injected: " + injector.hashCode()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment