public interface Injector
Injector is the heart of the Guice framework,
although you don't typically interact with it directly very often. This
"behind-the-scenes" operation is what distinguishes the dependency
injection pattern from its cousin, service locator.
The Injector API has a few additional features: it allows
pre-constructed instances to have their fields and methods injected and
offers programmatic introspection to support tool development.
Contains several default bindings:
Injector instance itself
Provider<T> for each binding of type T
Logger for the class being injected
Stage in which the Injector was created
Guice.| Modifier and Type | Method and Description |
|---|---|
<T> List<Binding<T>> |
findBindingsByType(TypeLiteral<T> type)
Finds all bindings to the given type.
|
<T> Binding<T> |
getBinding(Key<T> key)
Gets a binding for the given key.
|
Map<Key<?>,Binding<?>> |
getBindings()
Gets all explicit bindings.
|
<T> T |
getInstance(Class<T> type)
Gets an instance bound to the given type; equivalent to
getProvider(type).get(). |
<T> T |
getInstance(Key<T> key)
Gets an instance bound to the given key; equivalent to
getProvider(key).get(). |
<T> Provider<T> |
getProvider(Class<T> type)
Gets the provider bound to the given type.
|
<T> Provider<T> |
getProvider(Key<T> key)
Gets the provider bound to the given key.
|
void |
injectMembers(Object o)
Injects dependencies into the fields and methods of an existing object.
|
void injectMembers(Object o)
<T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
<T> T getInstance(Key<T> key)
getProvider(key).get().<T> T getInstance(Class<T> type)
getProvider(type).get().Copyright © 2013. All Rights Reserved.