Package org.elasticsearch.common.inject
Class Guice
- java.lang.Object
-
- org.elasticsearch.common.inject.Guice
-
public final class Guice extends java.lang.Object
The entry point to the Guice framework. CreatesInjector
s fromModule
s.Guice supports a model of development that draws clear boundaries between APIs, Implementations of these APIs, Modules which configure these implementations, and finally Applications which consist of a collection of Modules. It is the Application, which typically defines your
main()
method, that bootstraps the Guice Injector using theGuice
class, as in this example:public class FooApplication { public static void main(String[] args) { Injector injector = Guice.createInjector( new ModuleA(), new ModuleB(), . . . new FooApplicationFlagsModule(args) ); // Now just bootstrap the application and you're done FooStarter starter = injector.getInstance(FooStarter.class); starter.runApplication(); } }
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Injector
createInjector(java.lang.Iterable<? extends Module> modules)
Creates an injector for the given set of modules.static Injector
createInjector(Module... modules)
Creates an injector for the given set of modules.static Injector
createInjector(Stage stage, java.lang.Iterable<? extends Module> modules)
Creates an injector for the given set of modules, in a given development stage.static Injector
createInjector(Stage stage, Module... modules)
Creates an injector for the given set of modules, in a given development stage.
-
-
-
Method Detail
-
createInjector
public static Injector createInjector(Module... modules)
Creates an injector for the given set of modules.- Throws:
CreationException
- if one or more errors occur during Injector construction
-
createInjector
public static Injector createInjector(java.lang.Iterable<? extends Module> modules)
Creates an injector for the given set of modules.- Throws:
CreationException
- if one or more errors occur during Injector creation
-
createInjector
public static Injector createInjector(Stage stage, Module... modules)
Creates an injector for the given set of modules, in a given development stage.- Throws:
CreationException
- if one or more errors occur during Injector creation
-
createInjector
public static Injector createInjector(Stage stage, java.lang.Iterable<? extends Module> modules)
Creates an injector for the given set of modules, in a given development stage.- Throws:
CreationException
- if one or more errors occur during Injector construction
-
-