Changed Classes and Interfaces |
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.
|
Guice
|
The entry point to the Guice framework. Creates Injectors from
Modules.
|
Injector
|
Builds the graphs of objects that make up your application. |
Key
|
Binding key consisting of an injection type and an optional annotation. |
Provider
|
An object capable of providing instances of type {@code T}. |
ProvisionException
|
Indicates that there was a runtime failure while providing an instance. |
ScopeAnnotation
|
Annotates annotations which are used for scoping. |
Scopes
|
Built-in scope implementations. |
TypeLiteral
|
Represents a generic type {@code T}. |