|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Binder
Collects configuration information (primarily bindings) which will be
used to create an Injector
. Guice provides this object to your
application's Module
s so they may each contribute
their own bindings.
The bindings contributed by Module
s define how the Injector
resolves dependencies. A Key
consisting of a type
and optional annotation uniquely identifies a binding within an Injector
.
You may bind from a key to:
Provider
for this key
Provider
for this binding
In addition, a binding may have an associated scope, such as
Scopes.SINGLETON
, and singleton bindings may specify eager or lazy
initialization.
See the users' guide appendix, "How the Injector resolves injection requests," to better understand binding resolution.
After an Injector
has been created, its bindings may be
examined using methods like Injector.getBinding(Key)
, but this
read-only Binding
type is not used when creating the
bindings.
Method Summary | ||
---|---|---|
void |
addError(String message,
Object... arguments)
Records an error message which will be presented to the user at a later time. |
|
void |
addError(Throwable t)
Records an exception, the full details of which will be logged, and the message of which will be presented to the user at a later time. |
|
|
bind(Class<T> type)
Creates a binding to a type. |
|
|
bind(Key<T> key)
Creates a binding to a key. |
|
|
bind(TypeLiteral<T> typeLiteral)
Creates a binding to a type. |
|
AnnotatedConstantBindingBuilder |
bindConstant()
Binds a constant value to an annotation. |
|
void |
bindInterceptor(Matcher<? super Class<?>> classMatcher,
Matcher<? super Method> methodMatcher,
MethodInterceptor... interceptors)
Binds a method interceptor to methods matched by class and method matchers. |
|
void |
bindScope(Class<? extends Annotation> annotationType,
Scope scope)
Binds a scope to an annotation. |
|
Stage |
currentStage()
Gets the current stage. |
|
void |
install(Module module)
Uses the given module to configure more bindings. |
|
void |
requestStaticInjection(Class<?>... types)
Upon successful creation, the Injector will inject static fields
and methods in the given classes. |
Method Detail |
---|
void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
classMatcher
- matches classes the interceptor should apply to. For
example: only(Runnable.class)
.methodMatcher
- matches methods the interceptor should apply to. For
example: annotatedWith(Transactional.class)
.interceptors
- to bindvoid bindScope(Class<? extends Annotation> annotationType, Scope scope)
<T> LinkedBindingBuilder<T> bind(Key<T> key)
<T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
<T> AnnotatedBindingBuilder<T> bind(Class<T> type)
AnnotatedConstantBindingBuilder bindConstant()
void requestStaticInjection(Class<?>... types)
Injector
will inject static fields
and methods in the given classes.
types
- for which static members will be injectedvoid install(Module module)
Stage currentStage()
void addError(String message, Object... arguments)
String.format(String, Object[])
to insert the arguments into the
message.
void addError(Throwable t)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |