Class InjectorLookup


  • public final class InjectorLookup
    extends java.lang.Object
    Application injector static lookup utility.
    Since:
    19.04.2015
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<com.google.inject.Injector> getInjector​(io.dropwizard.Application application)  
      static java.util.Optional<com.google.inject.Injector> getInjector​(io.dropwizard.setup.Environment environment)  
      static <T> java.util.Optional<T> getInstance​(io.dropwizard.Application application, java.lang.Class<T> bean)
      Shortcut to directly obtain bean instance.
      static <T> java.util.Optional<T> getInstance​(io.dropwizard.setup.Environment environment, java.lang.Class<T> bean)
      Shortcut to directly obtain bean instance.
      static void registerInjector​(io.dropwizard.Application application, com.google.inject.Injector injector)
      Used internally to register application specific injector.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInjector

        public static java.util.Optional<com.google.inject.Injector> getInjector​(io.dropwizard.Application application)
        Parameters:
        application - application instance
        Returns:
        optional with or without application-bound injector
      • getInjector

        public static java.util.Optional<com.google.inject.Injector> getInjector​(io.dropwizard.setup.Environment environment)
        Parameters:
        environment - environment instance
        Returns:
        optional with or without application-bound injector
      • getInstance

        public static <T> java.util.Optional<T> getInstance​(io.dropwizard.Application application,
                                                            java.lang.Class<T> bean)
        Shortcut to directly obtain bean instance.
        Type Parameters:
        T - bean type
        Parameters:
        application - application instance
        bean - bean type
        Returns:
        bean instance, obtained from guice injector
      • getInstance

        public static <T> java.util.Optional<T> getInstance​(io.dropwizard.setup.Environment environment,
                                                            java.lang.Class<T> bean)
        Shortcut to directly obtain bean instance.
        Type Parameters:
        T - bean type
        Parameters:
        environment - environment instance
        bean - bean type
        Returns:
        bean instance, obtained from guice injector
      • registerInjector

        public static void registerInjector​(io.dropwizard.Application application,
                                            com.google.inject.Injector injector)
        Used internally to register application specific injector.
        Parameters:
        application - application instance
        injector - injector instance