Class InjectorLookup
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.injector.lookup.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.core.Application application)
static java.util.Optional<com.google.inject.Injector>
getInjector(io.dropwizard.core.setup.Environment environment)
static <T> java.util.Optional<T>
getInstance(io.dropwizard.core.Application application, java.lang.Class<T> bean)
Shortcut to directly obtain bean instance.static <T> java.util.Optional<T>
getInstance(io.dropwizard.core.setup.Environment environment, java.lang.Class<T> bean)
Shortcut to directly obtain bean instance.static void
registerInjector(io.dropwizard.core.Application application, com.google.inject.Injector injector)
Used internally to register application specific injector.
-
-
-
Method Detail
-
getInjector
public static java.util.Optional<com.google.inject.Injector> getInjector(io.dropwizard.core.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.core.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.core.Application application, java.lang.Class<T> bean)
Shortcut to directly obtain bean instance.- Type Parameters:
T
- bean type- Parameters:
application
- application instancebean
- bean type- Returns:
- bean instance, obtained from guice injector
-
getInstance
public static <T> java.util.Optional<T> getInstance(io.dropwizard.core.setup.Environment environment, java.lang.Class<T> bean)
Shortcut to directly obtain bean instance.- Type Parameters:
T
- bean type- Parameters:
environment
- environment instancebean
- bean type- Returns:
- bean instance, obtained from guice injector
-
registerInjector
public static void registerInjector(io.dropwizard.core.Application application, com.google.inject.Injector injector)
Used internally to register application specific injector.- Parameters:
application
- application instanceinjector
- injector instance
-
-