Class AdaptableTypeListener
java.lang.Object
org.eclipse.gef.common.adapt.inject.AdaptableTypeListener
- All Implemented Interfaces:
TypeListener
A specific
TypeListener to support adapter injection. It will
register an AdapterInjector, which will perform the adapter
injection, for each IAdaptable that is eligible (see
InjectAdapters.
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);The call to
requestInjection() is important to ensure that
setInjector(Injector) will get injected.
Without it, the AdaptableTypeListener will not function properly.
Clients should not register an AdaptableTypeListener themselves but
rather install AdapterInjectionSupport in one of the Modules
that are used by the Injector.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAdaptableTypeListener(AdapterInjectionSupport.LoggingMode loggingMode) Constructs a newAdaptableTypeListenerand specifies theAdapterInjectionSupport.LoggingModeto use. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleaneligibleForAdapterInjection(Method method) Checks that the given method complies to the signature ofIAdaptable.setAdapter(TypeToken, Object, String).<I> voidhear(TypeLiteral<I> type, TypeEncounter<I> encounter) voidsetInjector(Injector injector) In order to work, theAdaptableTypeListenerneeds to obtain a reference to anInjector, which is forwarded to theAdapterInjector, which it registers for anyIAdaptableencounters, to obtain theAdapterMapbindings to be injected.
-
Constructor Details
-
AdaptableTypeListener
Constructs a newAdaptableTypeListenerand specifies theAdapterInjectionSupport.LoggingModeto use. If inAdapterInjectionSupport.LoggingMode.DEVELOPMENTmode, binding-related information, warning, and error messages will be printed. If inAdapterInjectionSupport.LoggingMode.PRODUCTIONmode, only error messages will be printed, and information and warning messages will be suppressed.- Parameters:
loggingMode- TheAdapterInjectionSupport.LoggingModeto use.
-
-
Method Details
-
eligibleForAdapterInjection
Checks that the given method complies to the signature ofIAdaptable.setAdapter(TypeToken, Object, String).- Parameters:
method- TheMethodto test.- Returns:
trueif the method has a compatible signature,falseotherwise.
-
hear
- Specified by:
hearin interfaceTypeListener
-
setInjector
In order to work, theAdaptableTypeListenerneeds to obtain a reference to anInjector, which is forwarded to theAdapterInjector, which it registers for anyIAdaptableencounters, to obtain theAdapterMapbindings to be injected.- Parameters:
injector- The injector that is forwarded (used to inject) theAdapterInjector.
-