| com.google.inject.Binder
All known Subclasses: com.google.inject.BinderImpl,
Binder | public interface Binder (Code) | | 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:
- Another binding, which this binding's key is now "aliased to"
- Another binding, which references a
Provider for this key
- A preconstructed instance
- A preconstructed instance which should be used as the
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.
|
addError | void addError(String message, Object... arguments)(Code) | | Records an error message which will be presented to the user at a later
time. Unlike throwing an exception, this enable us to continue
configuring the Injector and discover more errors. Uses
String.format(StringObject[]) to insert the arguments into the
message.
|
addError | void addError(Throwable t)(Code) | | 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. If your Module calls something that you worry may fail, you should
catch the exception and pass it into this.
|
bindInterceptor | void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)(Code) | | Binds a method interceptor to methods matched by class and method
matchers.
Parameters: classMatcher - matches classes the interceptor should apply to. Forexample: only(Runnable.class) . Parameters: methodMatcher - matches methods the interceptor should apply to. Forexample: annotatedWith(Transactional.class) . Parameters: interceptors - to bind |
currentStage | Stage currentStage()(Code) | | Gets the current stage.
|
install | void install(Module module)(Code) | | Uses the given module to configure more bindings.
|
requestStaticInjection | void requestStaticInjection(Class>... types)(Code) | | Upon successful creation, the
Injector will inject static fields
and methods in the given classes.
Parameters: types - for which static members will be injected |
|
|