Class AdaptableTypeListener
- java.lang.Object
-
- org.eclipse.gef.common.adapt.inject.AdaptableTypeListener
-
- All Implemented Interfaces:
TypeListener
public class AdaptableTypeListener extends java.lang.Object implements TypeListener
A specificTypeListener
to support adapter injection. It will register anAdapterInjector
, which will perform the adapter injection, for eachIAdaptable
that is eligible (seeInjectAdapters
.In order to function properly, an
AdaptableTypeListener
has to be bound in a GuiceModule
as follows:AdaptableTypeListener adaptableTypeListener = new AdaptableTypeListener(); requestInjection(adaptableTypeListener); bindListener(Matchers.any(), adaptableTypeListener);
The call torequestInjection()
is important to ensure thatsetInjector(Injector)
will get injected. Without it, theAdaptableTypeListener
will not function properly.Clients should not register an
AdaptableTypeListener
themselves but rather installAdapterInjectionSupport
in one of theModule
s that are used by theInjector
.- See Also:
AdapterInjectionSupport
-
-
Constructor Summary
Constructors Constructor Description AdaptableTypeListener(AdapterInjectionSupport.LoggingMode loggingMode)
Constructs a newAdaptableTypeListener
and specifies theAdapterInjectionSupport.LoggingMode
to use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
eligibleForAdapterInjection(java.lang.reflect.Method method)
Checks that the given method complies to the signature ofIAdaptable.setAdapter(TypeToken, Object, String)
.<I> void
hear(TypeLiteral<I> type, TypeEncounter<I> encounter)
void
setInjector(Injector injector)
In order to work, theAdaptableTypeListener
needs to obtain a reference to anInjector
, which is forwarded to theAdapterInjector
, which it registers for anyIAdaptable
encounters, to obtain theAdapterMap
bindings to be injected.
-
-
-
Constructor Detail
-
AdaptableTypeListener
public AdaptableTypeListener(AdapterInjectionSupport.LoggingMode loggingMode)
Constructs a newAdaptableTypeListener
and specifies theAdapterInjectionSupport.LoggingMode
to use. If inAdapterInjectionSupport.LoggingMode.DEVELOPMENT
mode, binding-related information, warning, and error messages will be printed. If inAdapterInjectionSupport.LoggingMode.PRODUCTION
mode, only error messages will be printed, and information and warning messages will be suppressed.- Parameters:
loggingMode
- TheAdapterInjectionSupport.LoggingMode
to use.
-
-
Method Detail
-
eligibleForAdapterInjection
protected boolean eligibleForAdapterInjection(java.lang.reflect.Method method)
Checks that the given method complies to the signature ofIAdaptable.setAdapter(TypeToken, Object, String)
.- Parameters:
method
- TheMethod
to test.- Returns:
true
if the method has a compatible signature,false
otherwise.
-
hear
public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter)
- Specified by:
hear
in interfaceTypeListener
-
setInjector
@Inject public void setInjector(Injector injector)
In order to work, theAdaptableTypeListener
needs to obtain a reference to anInjector
, which is forwarded to theAdapterInjector
, which it registers for anyIAdaptable
encounters, to obtain theAdapterMap
bindings to be injected.- Parameters:
injector
- The injector that is forwarded (used to inject) theAdapterInjector
.
-
-