Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework. Please refer to the Guice User's Guide for a gentle introduction.
The principal public APIs in this package are:
- The annotation you will use in your implementation classes to tell Guice where and how it should send in ("inject") the objects you depend on (your "dependencies").
- The interface you will implement in order to specify "bindings" -- instructions for how Guice should handle injection -- for a particular set of interfaces.
- The object that Guice passes into your
Moduleto collect these bindings.
- The interface you will implement when you need to customize exactly how Guice creates instances for a particular binding.
Interface Summary Interface Description BinderCollects configuration information (primarily bindings) which will be used to create an
Binding<T>A mapping from a
Keyto the strategy for getting instances of the type.
InjectorBuilds the graphs of objects that make up your application. MembersInjector<T>Injects dependencies into the fields and methods on instances of type
ModuleA module contributes configuration information, typically interface bindings, which will be used to create an
PrivateBinderReturns a binder whose configuration information is hidden from its environment by default. Provider<T>An object capable of providing instances of type
ScopeA scope is a level of visibility that instances provided by Guice may have.
Class Summary Class Description AbstractModuleAbstractModule is a helper class used to add bindings to the Guice injector. GuiceThe entry point to the Guice framework. Key<T>Guice uses Key objects to identify a dependency that can be resolved by the Guice
PrivateModuleA module whose configuration information is hidden from its environment by default. ScopesBuilt-in scope implementations. TypeLiteral<T>Represents a generic type
Enum Summary Enum Description RestrictedBindingSource.RestrictionLevelLevel of restriction. StageThe stage we're running in.
Exception Summary Exception Description ConfigurationExceptionThrown when a programming error such as a misplaced annotation, illegal binding, or unsupported scope is found. CreationExceptionThrown when errors occur while creating a
Provider.get()when an attempt is made to access a scoped object while the scope in question is not currently active.
ProvisionExceptionIndicates that there was a runtime failure while providing an instance.
Annotation Types Summary Annotation Type Description BindingAnnotationAnnotates annotations which are used for binding. ExposedAcccompanies a @
Providesmethod annotation in a private module to indicate that the provided binding is exposed.
ImplementedByA pointer to the default implementation of a type. InjectAnnotates members of your implementation class (constructors, methods and fields) into which the
Injectorshould inject values.
ProvidedByA pointer to the default provider type for a type. ProvidesAnnotates methods of a
Moduleto create a provider method binding.
RestrictedBindingSourceAnnotation restricting the binding of the target type to permitted sources. RestrictedBindingSource.PermitMeta-annotation indicating that the target annotation is a permit for binding restricted bindings. ScopeAnnotationAnnotates annotations which are used for scoping. SingletonApply this to implementation classes when you want only one instance (per
Injector) to be reused for all injections for that binding.