Simply extend this class, then you can add bindings by either defining @Provides methods (see
https://github.com/google/guice/wiki/ProvidesMethods) or implementing configure(), and
calling the inherited methods which mirror those found in Binder. For example:
public class MyModule extends AbstractModule {
protected void configure() {
bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
bind(CreditCardPaymentService.class);
bind(PaymentService.class).to(CreditCardPaymentService.class);
bindConstant().annotatedWith(Names.named("port")).to(8080);
}
}
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| protected void | |
| protected void | |
| protected <T> LinkedBindingBuilder | |
| protected <T> AnnotatedBindingBuilder | |
| protected <T> AnnotatedBindingBuilder | |
| protected AnnotatedConstantBindingBuilder | |
| protected Binder | |
| protected void | bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
|
| protected void | |
| protected void | |
| protected void | |
| public final synchronized void | configure(Binder builder)
Implements com. binder.
|
| protected void | |
| protected void | |
| protected Stage | |
| protected <T> MembersInjector | |
| protected <T> MembersInjector | |
| protected <T> Provider | |
| protected <T> Provider | |
| protected void | |
| protected void | |
| protected <T> void | |
| protected void | |
| protected void | |
| protected void |
| binder | back to summary |
|---|---|
| pack-priv Binder binder | |
| AbstractModule | back to summary |
|---|---|
| public AbstractModule() | |
| addError | back to summary |
|---|---|
protected void addError(String message, Object... arguments)
| |
| addError | back to summary |
|---|---|
protected void addError(Throwable t)
| |
| addError | back to summary |
|---|---|
protected void addError(Message message)
| |
| bind | back to summary |
|---|---|
protected <T> LinkedBindingBuilder
| |
| bind | back to summary |
|---|---|
| protected <T> AnnotatedBindingBuilder | |
| bind | back to summary |
|---|---|
| protected <T> AnnotatedBindingBuilder See | |
| bindConstant | back to summary |
|---|---|
protected AnnotatedConstantBindingBuilder bindConstant()
| |
| binder | back to summary |
|---|---|
| protected Binder binder() Gets direct access to the underlying | |
| bindInterceptor | back to summary |
|---|---|
protected void bindInterceptor(Matcher<? super Class<?>> classMatcher, Matcher<? super Method> methodMatcher, MethodInterceptor... interceptors)
| |
| bindListener | back to summary |
|---|---|
| protected void bindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener) | |
| bindListener | back to summary |
|---|---|
protected void bindListener(Matcher<? super Binding<?>> bindingMatcher, ProvisionListener... listener)
| |
| bindScope | back to summary |
|---|---|
protected void bindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)
| |
| configure | back to summary |
|---|---|
| public final synchronized void configure(Binder builder) Implements com. Doc from com. Contributes bindings and other configurations for this module to Do not invoke this method directly to install submodules. Instead use
| |
| configure | back to summary |
|---|---|
| protected void configure() Configures a | |
| convertToTypes | back to summary |
|---|---|
protected void convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)
| |
| currentStage | back to summary |
|---|---|
protected Stage currentStage()
| |
| getMembersInjector | back to summary |
|---|---|
protected <T> MembersInjector
| |
| getMembersInjector | back to summary |
|---|---|
protected <T> MembersInjector
| |
| getProvider | back to summary |
|---|---|
protected <T> Provider
| |
| getProvider | back to summary |
|---|---|
protected <T> Provider
| |
| install | back to summary |
|---|---|
protected void install(Module module)
| |
| requestInjection | back to summary |
|---|---|
protected void requestInjection(Object instance)
| |
| requestInjection | back to summary |
|---|---|
protected <T> void requestInjection(TypeLiteral<T> type, T instance)
| |
| requestStaticInjection | back to summary |
|---|---|
| protected void requestStaticInjection(Class<?>... types) | |
| requireBinding | back to summary |
|---|---|
| protected void requireBinding(Key<?> key) Adds a dependency from this module to
| |
| requireBinding | back to summary |
|---|---|
| protected void requireBinding(Class<?> type) Adds a dependency from this module to
| |