Top Description Constructors Methods
com.google.inject

public final Class Guice

extends Object
Class Inheritance
Imports
com.google.inject.internal.InternalInjectorCreator, java.util.Arrays

The entry point to the Guice framework. Creates Injectors from Modules.

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 the Guice 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();
      }
    }

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Injector
createInjector(Module... modules)

Creates an injector for the given set of modules.

public static Injector
createInjector(Iterable<? extends Module> modules)

Creates an injector for the given set of modules.

public static Injector
createInjector(Stage stage, Module... modules)

Creates an injector for the given set of modules, in a given development stage.

public static Injector
createInjector(Stage stage, Iterable<? extends Module> modules)

Creates an injector for the given set of modules, in a given development stage.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Guiceback to summary
private Guice()

Method Detail

createInjectorback to summary
public static Injector createInjector(Module... modules)

Creates an injector for the given set of modules. This is equivalent to calling createInjector(Stage, Module...) with Stage.DEVELOPMENT.

Exceptions
CreationException:
if one or more errors occur during injector construction
createInjectorback to summary
public static Injector createInjector(Iterable<? extends Module> modules)

Creates an injector for the given set of modules. This is equivalent to calling createInjector(Stage, Iterable) with Stage.DEVELOPMENT.

Exceptions
CreationException:
if one or more errors occur during injector creation
createInjectorback to summary
public static Injector createInjector(Stage stage, Module... modules)

Creates an injector for the given set of modules, in a given development stage.

Exceptions
CreationException:
if one or more errors occur during injector creation.
createInjectorback to summary
public static Injector createInjector(Stage stage, Iterable<? extends Module> modules)

Creates an injector for the given set of modules, in a given development stage.

Exceptions
CreationException:
if one or more errors occur during injector construction