Class AdapterInjector
- java.lang.Object
-
- org.eclipse.gef.common.adapt.inject.AdapterInjector
-
- All Implemented Interfaces:
MembersInjector<IAdaptable>
public class AdapterInjector extends java.lang.Object implements MembersInjector<IAdaptable>
A specificMembersInjector
that supports injection of adapters into anIAdaptable
implementation class'IAdaptable.setAdapter(TypeToken, Object, String)
method, that is marked as being eligible for adapter injection (seeInjectAdapters
).Being registered for a specific
IAdaptable
anAdapterInjector
will inject all instances of that type or any sub-type, evaluating allAdapterMap
bindings that can be obtained from theInjector
, which was forwarded to it viasetInjector(Injector)
. It will inject all adapters, for which adapter (map) bindings with a matchingAdapterMap
annotation exist. Here, matching means, that the type provided in theAdapterMap
annotation of theIAdaptable
#s method (AdapterMap.adaptableType()
) is either the same or a sub-type of the type used with theAdapterMap
annotation of the related binding.The
AdapterInjector
supports that type information about the actual adapter type may be omitted from the adapter map binding (i.e. the usedAdapterKey
only provides a role but no type key). It will try to infer the actual adapter type from respective bindings, or fall back to the type inferred from the adapter instance (which will not be adequate for generic types because of type erasure) in such a case.
-
-
Constructor Summary
Constructors Constructor Description AdapterInjector(java.lang.reflect.Method method, AdapterInjectionSupport.LoggingMode loggingMode)
Creates a newAdapterInjector
to inject the givenMethod
, annotated with the givenAdapterMap
method annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
injectAdapters(IAdaptable adaptable)
Performs the adapter map injection for the given adaptable instance.void
injectMembers(IAdaptable instance)
void
setInjector(Injector injector)
Sets theInjector
, being used for adapter map injection.
-
-
-
Constructor Detail
-
AdapterInjector
public AdapterInjector(java.lang.reflect.Method method, AdapterInjectionSupport.LoggingMode loggingMode)
Creates a newAdapterInjector
to inject the givenMethod
, annotated with the givenAdapterMap
method annotation.If in
AdapterInjectionSupport.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:
method
- TheMethod
to be injected.loggingMode
- TheAdapterInjectionSupport.LoggingMode
to use.
-
-
Method Detail
-
injectAdapters
protected void injectAdapters(IAdaptable adaptable)
Performs the adapter map injection for the given adaptable instance.- Parameters:
adaptable
- The adaptable to inject adapters into.
-
injectMembers
public void injectMembers(IAdaptable instance)
- Specified by:
injectMembers
in interfaceMembersInjector<IAdaptable>
-
-