public abstract class AbstractModule extends Object implements Module
Module
s which reduces repetition and results in
a more readable configuration. Simply extend this class, implement configure()
, and call the inherited methods which mirror those found in
Binder
. For example:
import static com.google.inject.Names.named; public class MyModule extends AbstractModule { protected void configure() { bind(Foo.class).to(FooImpl.class).in(Scopes.SINGLETON); bind(BarImpl.class); link(Bar.class).to(BarImpl.class); bindConstant(named("port")).to(8080); } }
Constructor and Description |
---|
AbstractModule() |
Modifier and Type | Method and Description |
---|---|
protected void |
addError(String message,
Object... arguments) |
protected void |
addError(Throwable t) |
protected <T> AnnotatedBindingBuilder<T> |
bind(Class<T> clazz) |
protected <T> LinkedBindingBuilder<T> |
bind(Key<T> key) |
protected <T> AnnotatedBindingBuilder<T> |
bind(TypeLiteral<T> typeLiteral) |
protected AnnotatedConstantBindingBuilder |
bindConstant() |
protected Binder |
binder()
Gets direct access to the underlying
Binder . |
protected void |
bindInterceptor(Matcher<? super Class<?>> classMatcher,
Matcher<? super Method> methodMatcher,
org.aopalliance.intercept.MethodInterceptor... interceptors) |
protected void |
bindScope(Class<? extends Annotation> scopeAnnotation,
Scope scope) |
protected abstract void |
configure()
Configures a
Binder via the exposed methods. |
void |
configure(Binder builder)
Contributes bindings and other configurations to a
Binder . |
protected void |
install(Module module) |
protected void |
requestStaticInjection(Class<?>... types) |
public final void configure(Binder builder)
Module
Binder
.protected abstract void configure()
Binder
via the exposed methods.protected Binder binder()
Binder
.protected void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
Binder.bindScope(Class, Scope)
protected <T> LinkedBindingBuilder<T> bind(Key<T> key)
Binder.bind(Key)
protected <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
Binder.bind(TypeLiteral)
protected <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz)
Binder.bind(Class)
protected AnnotatedConstantBindingBuilder bindConstant()
Binder.bindConstant()
protected void install(Module module)
Binder.install(Module)
protected void addError(String message, Object... arguments)
Binder.addError(String, Object[])
protected void addError(Throwable t)
Binder.addError(Throwable)
protected void requestStaticInjection(Class<?>... types)
Copyright © 2013. All Rights Reserved.