|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Injector
Fulfills requests for the object instances that make up your application,
always ensuring that these instances are properly injected before they are
returned. The 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
.
Method Summary | ||
---|---|---|
|
findBindingsByType(TypeLiteral<T> type)
Finds all bindings to the given type. |
|
|
getBinding(Key<T> key)
Gets a binding for the given key. |
|
java.util.Map<Key<?>,Binding<?>> |
getBindings()
Gets all explicit bindings. |
|
|
getInstance(java.lang.Class<T> type)
Gets an instance bound to the given type; equivalent to getProvider(type).get() . |
|
|
getInstance(Key<T> key)
Gets an instance bound to the given key; equivalent to getProvider(key).get() . |
|
|
getProvider(java.lang.Class<T> type)
Gets the provider bound to the given type. |
|
|
getProvider(Key<T> key)
Gets the provider bound to the given key. |
|
void |
injectMembers(java.lang.Object o)
Injects dependencies into the fields and methods of an existing object. |
Method Detail |
---|
void injectMembers(java.lang.Object o)
java.util.Map<Key<?>,Binding<?>> getBindings()
<T> Binding<T> getBinding(Key<T> key)
<T> java.util.List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
<T> Provider<T> getProvider(Key<T> key)
<T> Provider<T> getProvider(java.lang.Class<T> type)
<T> T getInstance(Key<T> key)
getProvider(key).get()
.
<T> T getInstance(java.lang.Class<T> type)
getProvider(type).get()
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |