public class AdaptableTypeListener
extends java.lang.Object
implements com.google.inject.spi.TypeListener
TypeListener to support adapter map injection. It will
register an AdapterMapInjector for each IAdaptable it
encounters, which provides a method that:
InjectMap<AdapterKey<?>, Object>, which is annotated with
an AdapterMap annotation.AdapterMapInjector is in turn responsible of
performing the actual adapter map injection.
In order to function properly, an AdaptableTypeListener has to be
bound in a Guice Module as follows:
AdaptableTypeListener adaptableTypeListener = new AdaptableTypeListener(); requestInjection(adaptableTypeListener); bindListener(Matchers.any(), adaptableTypeListener);Here, the call to
requestInjection() is important to ensure that
setInjector(Injector) will get injected.
Without it, the AdaptableTypeListener will not function properly.AdapterMap| Constructor and Description |
|---|
AdaptableTypeListener() |
| Modifier and Type | Method and Description |
|---|---|
<I> void |
hear(com.google.inject.TypeLiteral<I> type,
com.google.inject.spi.TypeEncounter<I> encounter) |
void |
setInjector(com.google.inject.Injector injector)
In order to work, the
AdaptableTypeListener needs to obtain a
reference to an Injector, which is forwarded to the
AdapterMapInjector, which it registers for any IAdaptable
encounters, to obtain the AdapterMap bindings to be injected. |
@Inject public void setInjector(com.google.inject.Injector injector)
AdaptableTypeListener needs to obtain a
reference to an Injector, which is forwarded to the
AdapterMapInjector, which it registers for any IAdaptable
encounters, to obtain the AdapterMap bindings to be injected.injector - The injector that is forwarded (used to inject) the
AdapterMapInjector.public <I> void hear(com.google.inject.TypeLiteral<I> type,
com.google.inject.spi.TypeEncounter<I> encounter)
hear in interface com.google.inject.spi.TypeListenerCopyright (c) 2014 itemis AG and others. All rights reserved.