com.google.inject
Interface Injector


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:

Injectors are created using the facade class Guice.

Author:
crazybob@google.com (Bob Lee)

Method Summary
<T> java.util.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.
 java.util.Map<Key<?>,Binding<?>> getBindings()
          Gets all explicit bindings.
<T> T
getInstance(java.lang.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(java.lang.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(java.lang.Object o)
          Injects dependencies into the fields and methods of an existing object.
 

Method Detail

injectMembers

void injectMembers(java.lang.Object o)
Injects dependencies into the fields and methods of an existing object. Does not inject the constructor.


getBindings

java.util.Map<Key<?>,Binding<?>> getBindings()
Gets all explicit bindings.


getBinding

<T> Binding<T> getBinding(Key<T> key)
Gets a binding for the given key.


findBindingsByType

<T> java.util.List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
Finds all bindings to the given type.


getProvider

<T> Provider<T> getProvider(Key<T> key)
Gets the provider bound to the given key.


getProvider

<T> Provider<T> getProvider(java.lang.Class<T> type)
Gets the provider bound to the given type.


getInstance

<T> T getInstance(Key<T> key)
Gets an instance bound to the given key; equivalent to getProvider(key).get().


getInstance

<T> T getInstance(java.lang.Class<T> type)
Gets an instance bound to the given type; equivalent to getProvider(type).get().



Copyright © {inceptionYear}-2008 null. All Rights Reserved.