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
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:
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
protected void
protected <T> AnnotatedBindingBuilder<T>
protected <T> LinkedBindingBuilder<T>
protected <T> AnnotatedBindingBuilder<T>
bind
(TypeLiteral<T> typeLiteral) protected AnnotatedConstantBindingBuilder
protected Binder
binder()
Gets direct access to the underlyingBinder
.protected void
bindListener
(Matcher<? super TypeLiteral<?>> typeMatcher, TypeListener listener) protected void
bindScope
(Class<? extends Annotation> scopeAnnotation, Scope scope) protected abstract void
Configures aBinder
via the exposed methods.final void
Contributes bindings and other configurations for this module tobinder
.protected void
convertToTypes
(Matcher<? super TypeLiteral<?>> typeMatcher, TypeConverter converter) protected Stage
protected <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 void
protected void
requestInjection
(Object instance) protected void
requestStaticInjection
(Class<?>... types) protected void
requireBinding
(Class<?> type) Adds a dependency from this module totype
.protected void
requireBinding
(Key<?> key) Adds a dependency from this module tokey
.
-
Constructor Details
-
AbstractModule
public AbstractModule()
-
-
Method Details
-
configure
Description copied from interface:Module
Contributes 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 methods
are discovered. -
configure
protected abstract void configure()Configures aBinder
via the exposed methods. -
binder
Gets direct access to the underlyingBinder
. -
bindScope
- See Also:
-
bind
- See Also:
-
bind
- See Also:
-
bind
- See Also:
-
bindConstant
- See Also:
-
install
- See Also:
-
addError
- See Also:
-
addError
- See Also:
-
addError
- Since:
- 2.0
- See Also:
-
requestInjection
- Since:
- 2.0
- See Also:
-
requestStaticInjection
- See Also:
-
requireBinding
Adds a dependency from this module tokey
. When the injector is created, Guice will report an error ifkey
cannot 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 iftype
cannot 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:
-
getProvider
- Since:
- 2.0
- See Also:
-
convertToTypes
-
currentStage
- Since:
- 2.0
- See Also:
-
getMembersInjector
- Since:
- 2.0
- See Also:
-
getMembersInjector
- Since:
- 2.0
- See Also:
-
bindListener
-