Package org.elasticsearch.common.inject
Class AbstractModule
java.lang.Object
org.elasticsearch.common.inject.AbstractModule
- All Implemented Interfaces:
Module
- Direct Known Subclasses:
ActionModule,ClusterModule,GatewayModule,IndicesModule
A support class for
Modules 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:
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);
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidprotected <T> AnnotatedBindingBuilder<T>protected <T> LinkedBindingBuilder<T>protected <T> AnnotatedBindingBuilder<T>bind(TypeLiteral<T> typeLiteral)protected AnnotatedConstantBindingBuilderprotected Binderbinder()Gets direct access to the underlyingBinder.protected voidbindListener(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener)protected voidbindScope(Class<? extends Annotation> scopeAnnotation, Scope scope)protected abstract voidConfigures aBindervia the exposed methods.voidContributes bindings and other configurations for this module tobinder.protected voidconvertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter)protected Stageprotected <T> MembersInjector<T>getMembersInjector(Class<T> type)protected <T> MembersInjector<T>getMembersInjector(TypeLiteral<T> type)protected <T> Provider<T>getProvider(Class<T> type)protected <T> Provider<T>getProvider(Key<T> key)protected voidprotected voidrequestInjection(Object instance)protected voidrequestStaticInjection(Class<?>... types)protected voidrequireBinding(Class<?> type)Adds a dependency from this module totype.protected voidrequireBinding(Key<?> key)Adds a dependency from this module tokey.
-
Constructor Details
-
AbstractModule
public AbstractModule()
-
-
Method Details
-
configure
Description copied from interface:ModuleContributes bindings and other configurations for this module tobinder.Do not invoke this method directly to install submodules. Instead use
Binder.install(Module), which ensures thatprovider methodsare discovered. -
configure
protected abstract void configure()Configures aBindervia the exposed methods. -
binder
Gets direct access to the underlyingBinder. -
bindScope
- See Also:
Binder.bindScope(Class, Scope)
-
bind
- See Also:
Binder.bind(Key)
-
bind
- See Also:
Binder.bind(TypeLiteral)
-
bind
- See Also:
Binder.bind(Class)
-
bindConstant
- See Also:
Binder.bindConstant()
-
install
- See Also:
Binder.install(Module)
-
addError
- See Also:
Binder.addError(String, Object[])
-
addError
- See Also:
Binder.addError(Throwable)
-
addError
- Since:
- 2.0
- See Also:
Binder.addError(Message)
-
requestInjection
- Since:
- 2.0
- See Also:
Binder.requestInjection(Object)
-
requestStaticInjection
- See Also:
Binder.requestStaticInjection(Class[])
-
requireBinding
Adds a dependency from this module tokey. When the injector is created, Guice will report an error ifkeycannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.- Since:
- 2.0
-
requireBinding
Adds a dependency from this module totype. When the injector is created, Guice will report an error iftypecannot be injected. Note that this requirement may be satisfied by implicit binding, such as a public no-arguments constructor.- Since:
- 2.0
-
getProvider
- Since:
- 2.0
- See Also:
Binder.getProvider(Key)
-
getProvider
- Since:
- 2.0
- See Also:
Binder.getProvider(Class)
-
convertToTypes
-
currentStage
- Since:
- 2.0
- See Also:
Binder.currentStage()
-
getMembersInjector
- Since:
- 2.0
- See Also:
Binder.getMembersInjector(Class)
-
getMembersInjector
- Since:
- 2.0
- See Also:
Binder.getMembersInjector(TypeLiteral)
-
bindListener
-