com.google.inject
Interface Container


public interface Container

Injects dependencies into constructors, methods and fields annotated with @Inject. Provides access to Bindings.

Automatically converts constants as needed from String to any primitive type as well as enum and Class<?>. Automatically boxes and unboxes primitives. For example, in the absence of a binding to int, the container will look for a binding to Integer.

Author:
crazybob@google.com (Bob Lee)
See Also:
ContainerBuilder

Method Summary
<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 bindings.
<T> Factory<T>
getFactory(Class<T> type)
          Gets the factory bound to the given type.
<T> Factory<T>
getFactory(Class<T> type, Annotation annotation)
          Gets the factory bound to the given type and annotation.
<T> Factory<T>
getFactory(Class<T> type, Class<? extends Annotation> annotationType)
          Gets the factory bound to the given type and annotation.
<T> Factory<T>
getFactory(Key<T> key)
          Gets the factory bound to the given key.
<T> Factory<T>
getFactory(TypeLiteral<T> type)
          Gets the factory bound to the given type.
<T> Factory<T>
getFactory(TypeLiteral<T> type, Annotation annotation)
          Gets the factory bound to the given type and annotation.
<T> Factory<T>
getFactory(TypeLiteral<T> type, Class<? extends Annotation> annotationType)
          Gets the factory bound to the given type and annotation.
<T> T
getInstance(Class<T> type)
          Gets an instance from the factory bound to the given type.
<T> T
getInstance(Class<T> type, Annotation annotation)
          Gets an instance from the factory bound to the given type and annotation.
<T> T
getInstance(Class<T> type, Class<? extends Annotation> annotationType)
          Gets an instance from the factory bound to the given type and annotation.
<T> T
getInstance(Key<T> key)
          Gets an instance from the factory bound to the given key.
<T> T
getInstance(TypeLiteral<T> type)
          Gets an instance from the factory bound to the given type.
<T> T
getInstance(TypeLiteral<T> type, Annotation annotation)
          Gets an instance from the factory bound to the given type and annotation.
<T> T
getInstance(TypeLiteral<T> type, Class<? extends Annotation> annotationType)
          Gets an instance from the factory bound to the given type and annotation.
 void injectMembers(Object o)
          Injects dependencies into the fields and methods of an existing object.
 

Method Detail

injectMembers

void injectMembers(Object o)
Injects dependencies into the fields and methods of an existing object.


getFactory

<T> Factory<T> getFactory(Key<T> key)
Gets the factory bound to the given key.


getBindings

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


getBinding

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


findBindingsByType

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


getFactory

<T> Factory<T> getFactory(Class<T> type)
Gets the factory bound to the given type.


getFactory

<T> Factory<T> getFactory(TypeLiteral<T> type)
Gets the factory bound to the given type.


getInstance

<T> T getInstance(TypeLiteral<T> type)
Gets an instance from the factory bound to the given type.


getInstance

<T> T getInstance(Class<T> type)
Gets an instance from the factory bound to the given type.


getInstance

<T> T getInstance(Key<T> key)
Gets an instance from the factory bound to the given key.


getInstance

<T> T getInstance(TypeLiteral<T> type,
                  Annotation annotation)
Gets an instance from the factory bound to the given type and annotation.


getInstance

<T> T getInstance(Class<T> type,
                  Annotation annotation)
Gets an instance from the factory bound to the given type and annotation.


getFactory

<T> Factory<T> getFactory(Class<T> type,
                          Annotation annotation)
Gets the factory bound to the given type and annotation.


getFactory

<T> Factory<T> getFactory(TypeLiteral<T> type,
                          Annotation annotation)
Gets the factory bound to the given type and annotation.


getInstance

<T> T getInstance(TypeLiteral<T> type,
                  Class<? extends Annotation> annotationType)
Gets an instance from the factory bound to the given type and annotation.


getInstance

<T> T getInstance(Class<T> type,
                  Class<? extends Annotation> annotationType)
Gets an instance from the factory bound to the given type and annotation.


getFactory

<T> Factory<T> getFactory(Class<T> type,
                          Class<? extends Annotation> annotationType)
Gets the factory bound to the given type and annotation.


getFactory

<T> Factory<T> getFactory(TypeLiteral<T> type,
                          Class<? extends Annotation> annotationType)
Gets the factory bound to the given type and annotation.