Class InjectorHelper


  • public final class InjectorHelper
    extends Object
    Guice static injector helper. This class is handy when it comes to get reference to Guice's Injector for a class that is not managed or instantiated by Guice (eg. legacy code or Guice module type listener classes). Please do not overuse it as its a kind of trick rather then good approach to codding style.
     public class MyModule extends AbstractModule {
       protected void configure() {
         // (...)
         requestStaticInjection(InjectorHelper.class);
         // (...)
       }
     }
     
    Since:
    2.1.0-SNAPSHOT
    Author:
    Robert Bala, Piotr Dyraga
    See Also:
    Injector
    • Method Detail

      • getInjector

        public static com.google.inject.Injector getInjector()
        Gets reference to the current Injector.
        Returns:
        reference to Guice's or null if the helper has not been installed properly.