|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.inject.ContainerBuilder
public final class ContainerBuilder
Builds a dependency injection Container
. Binds Key
s to
implementations. For example, a binding implementation could be anything
from a constant value to an object in the HTTP session.
Not safe for concurrent use.
Default bindings include:
Container
iself
Logger
for the class being injected
Converts constants as needed from String
to any primitive type
in addition to enum
and Class<?>
.
Nested Class Summary | |
---|---|
class |
ContainerBuilder.BindingBuilder<T>
Binds a Key to an implementation in a given scope. |
static interface |
ContainerBuilder.Command
Implemented by classes which participate in building a container. |
class |
ContainerBuilder.ConstantBindingBuilder
Builds a constant binding. |
class |
ContainerBuilder.LinkedBindingBuilder<T>
Links one binding to another. |
Constructor Summary | |
---|---|
ContainerBuilder()
Constructs a new builder. |
Method Summary | ||
---|---|---|
|
bind(java.lang.Class<T> clazz)
Binds the given type. |
|
|
bind(Key<T> key)
Binds the given key. |
|
ContainerBuilder.ConstantBindingBuilder |
bind(java.lang.String name)
Binds a constant to the given name. |
|
|
bind(TypeToken<T> typeToken)
Binds the given type. |
|
ContainerBuilder |
bindProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Binds string constants based on the given properties. |
|
ContainerBuilder |
bindProperties(java.util.Properties properties)
Binds string constants based on the given properties. |
|
Container |
create(boolean loadSingletons)
Creates a Container instance. |
|
ContainerBuilder |
injectStatics(java.lang.Class<?>... types)
Upon creation, the Container will inject static fields and methods
in the given classes. |
|
|
link(Key<T> key)
Links the given key to another key effectively creating an alias for a binding. |
|
protected java.lang.Object |
source()
Creates a source object to be associated with a binding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ContainerBuilder()
Method Detail |
---|
protected java.lang.Object source()
ContainerBuilder
's caller's StackTraceElement
.
If you plan on manually setting the source (say for example you've
implemented an XML configuration), you might override this method and
return null
to avoid unnecessary overhead.
public <T> ContainerBuilder.BindingBuilder<T> bind(Key<T> key)
public <T> ContainerBuilder.BindingBuilder<T> bind(TypeToken<T> typeToken)
public <T> ContainerBuilder.BindingBuilder<T> bind(java.lang.Class<T> clazz)
public <T> ContainerBuilder.LinkedBindingBuilder<T> link(Key<T> key)
public ContainerBuilder.ConstantBindingBuilder bind(java.lang.String name)
public ContainerBuilder bindProperties(java.util.Map<java.lang.String,java.lang.String> properties)
public ContainerBuilder bindProperties(java.util.Properties properties)
public ContainerBuilder injectStatics(java.lang.Class<?>... types)
Container
will inject static fields and methods
in the given classes.
types
- for which static members will be injectedpublic Container create(boolean loadSingletons)
Container
instance. Injects static members for classes
which were registered using injectStatics(Class...)
.
loadSingletons
- If true, the container will load all singletons
now. If false, the container will lazily load singletons. Eager loading
is appropriate for production use while lazy loading can speed
development.
java.lang.IllegalStateException
- if called more than once
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |