public class LifecycleInjector
extends java.lang.Object
When using Governator, do NOT create a Guice injector manually. Instead, use a LifecycleInjector to create a Guice injector.
Governator uses a two pass binding. The bootstrap binding injects:
LifecycleManager
The bootstrap binding occurs when the LifecycleInjector is created. The main binding
occurs when createInjector() is called.
| Modifier and Type | Method and Description |
|---|---|
static com.google.inject.Injector |
bootstrap(java.lang.Class<?> main) |
static com.google.inject.Injector |
bootstrap(java.lang.Class<?> main,
BootstrapModule... externalBootstrapModules) |
static com.google.inject.Injector |
bootstrap(java.lang.Class<?> main,
com.google.inject.Module externalBindings,
BootstrapModule... externalBootstrapModules)
This is a shortcut to configuring the LifecycleInjectorBuilder using annotations.
|
static LifecycleInjectorBuilder |
builder()
Create a new LifecycleInjector builder
|
com.google.inject.Injector |
createChildInjector(java.util.Collection<com.google.inject.Module> modules)
Create an injector that is a child of the bootstrap bindings only
|
com.google.inject.Injector |
createChildInjector(com.google.inject.Module... modules)
Create an injector that is a child of the bootstrap bindings only
|
com.google.inject.Injector |
createInjector()
Create the main injector
|
com.google.inject.Injector |
createInjector(java.util.Collection<com.google.inject.Module> additionalModules)
Create the main injector
|
com.google.inject.Injector |
createInjector(com.google.inject.Module... modules)
Create the main injector
|
static ClasspathScanner |
createStandardClasspathScanner(java.util.Collection<java.lang.String> basePackages)
If you need early access to the CLASSPATH scanner.
|
static ClasspathScanner |
createStandardClasspathScanner(java.util.Collection<java.lang.String> basePackages,
java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> additionalAnnotations)
If you need early access to the CLASSPATH scanner.
|
LifecycleManager |
getLifecycleManager()
Return the internally created lifecycle manager
|
public static LifecycleInjectorBuilder builder()
public static com.google.inject.Injector bootstrap(java.lang.Class<?> main)
public static com.google.inject.Injector bootstrap(java.lang.Class<?> main,
BootstrapModule... externalBootstrapModules)
@Beta
public static com.google.inject.Injector bootstrap(java.lang.Class<?> main,
com.google.inject.Module externalBindings,
BootstrapModule... externalBootstrapModules)
BootstrapModules.
Each annotations can then map to a subsystem or feature that is enabled on
the main application class. BootstrapModules are installed in the order in which
they are defined.main - Main application bootstrap classexternalBindings - Bindings that are provided externally by the caller to bootstrap. These
bindings are injectable into the BootstrapModule instancesexternalBootstrapModules - Optional modules that are processed after all the main class bootstrap modulesBootstrap}public static ClasspathScanner createStandardClasspathScanner(java.util.Collection<java.lang.String> basePackages)
LifecycleInjectorBuilder.usingClasspathScanner(ClasspathScanner).basePackages - packages to recursively scanpublic static ClasspathScanner createStandardClasspathScanner(java.util.Collection<java.lang.String> basePackages, java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> additionalAnnotations)
LifecycleInjectorBuilder.usingClasspathScanner(ClasspathScanner).basePackages - packages to recursively scanadditionalAnnotations - any additional annotations to scan forpublic LifecycleManager getLifecycleManager()
public com.google.inject.Injector createChildInjector(com.google.inject.Module... modules)
modules - binding modulespublic com.google.inject.Injector createChildInjector(java.util.Collection<com.google.inject.Module> modules)
modules - binding modulespublic com.google.inject.Injector createInjector()
public com.google.inject.Injector createInjector(com.google.inject.Module... modules)
modules - any additional modulespublic com.google.inject.Injector createInjector(java.util.Collection<com.google.inject.Module> additionalModules)
additionalModules - any additional modules