Added Classes and Interfaces |
ConfigurationException
|
Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported
scope is found. |
Exposed
|
Acccompanies a {@literal @}Provides method annotation in a
private module to indicate that the provided binding is exposed. |
InjectorBuilder
|
The advanced entry point to the Guice framework. Creates Injectors from
Modules, allowing many options to be configured for the Injector.
|
MembersInjector
|
Injects dependencies into the fields and methods on instances of type {@code T}. |
OutOfScopeException
|
Thrown from Provider.get when an attempt is made to access a scoped
object while the scope in question is not currently active. |
PrivateBinder
|
Returns a binder whose configuration information is hidden from its environment by default. |
PrivateModule
|
A module whose configuration information is hidden from its environment by default. |
Provides
|
Annotates methods of a Module to create a provider method binding. |
ProvisionException
|
Indicates that there was a runtime failure while providing an instance. |
Changed Classes and Interfaces |
AbstractModule
|
A support class for Modules which reduces repetition and results in
a more readable configuration. |
Binder
|
Collects configuration information (primarily bindings) which will be
used to create an Injector. Guice provides this object to your
application's Module implementors so they may each contribute
their own bindings and other registrations.
The Guice Binding EDSL
Guice uses an embedded domain-specific language, or EDSL, to help you
create bindings simply and readably. This approach is great for overall
usability, but it does come with a small cost: it is difficult to
learn how to use the Binding EDSL by reading
method-level javadocs. Instead, you should consult the series of
examples below. To save space, these examples omit the opening
{@code binder}, just as you will if your module extends
AbstractModule.
bind(ServiceImpl.class);
This statement does essentially nothing; it "binds the {@code ServiceImpl}
class to itself" and does not change Guice's default behavior. You may still
want to use this if you prefer your Module class to serve as an
explicit manifest for the services it provides. Also, in rare cases,
Guice may be unable to validate a binding at injector creation time unless it
is given explicitly.
bind(Service.class).to(ServiceImpl.class);
Specifies that a request for a {@code Service} instance with no binding
annotations should be treated as if it were a request for a
{@code ServiceImpl} instance. This overrides the function of any
@ImplementedBy or @ProvidedBy
annotations found on {@code Service}, since Guice will have already
"moved on" to {@code ServiceImpl} before it reaches the point when it starts
looking for these annotations.
bind(Service.class).toProvider(ServiceProvider.class);
In this example, {@code ServiceProvider} must extend or implement
{@code Provider}. This binding specifies that Guice should resolve
an unannotated injection request for {@code Service} by first resolving an
instance of {@code ServiceProvider} in the regular way, then calling
get() on the resulting Provider instance to obtain the
{@code Service} instance.
|
Binding
|
A mapping from a key (type and optional annotation) to the strategy for getting instances of the
type. |
BindingAnnotation
|
Annotates annotations which are used for binding. |
CreationException
|
Thrown when errors occur while creating a Injector. |
Guice
|
The entry point to the Guice framework. Creates Injectors from
Modules. For advanced usage, see InjectorBuilder.
|
Injector
|
Builds the graphs of objects that make up your application. |
Key
|
Binding key consisting of an injection type and an optional annotation. |
Module
|
A module contributes configuration information, typically interface
bindings, which will be used to create an Injector. |
Provider
|
An object capable of providing instances of type {@code T}. |
Scope
|
A scope is a level of visibility that instances provided by Guice may have. |
ScopeAnnotation
|
Annotates annotations which are used for scoping. |
Scopes
|
Built-in scope implementations. |
TypeLiteral
|
Represents a generic type {@code T}. |