Class AdapterInjector
- All Implemented Interfaces:
MembersInjector<IAdaptable>
MembersInjector that supports injection of adapters into
an IAdaptable implementation class'
IAdaptable.setAdapter(TypeToken, Object, String) method, that is
marked as being eligible for adapter injection (see InjectAdapters).
Being registered for a specific IAdaptable an AdapterInjector
will inject all instances of that type or any sub-type, evaluating all
AdapterMap bindings that can be obtained from the Injector,
which was forwarded to it via setInjector(Injector). It will inject
all adapters, for which adapter (map) bindings with a matching
AdapterMap annotation exist. Here, matching means, that the type
provided in the AdapterMap annotation of the IAdaptable#s
method ( AdapterMap.adaptableType()) is either the same or a sub-type
of the type used with the AdapterMap 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 used
AdapterKey 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
ConstructorsConstructorDescriptionAdapterInjector(Method method, AdapterInjectionSupport.LoggingMode loggingMode) Creates a newAdapterInjectorto inject the givenMethod, annotated with the givenAdapterMapmethod annotation. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinjectAdapters(IAdaptable adaptable) Performs the adapter map injection for the given adaptable instance.voidinjectMembers(IAdaptable instance) voidsetInjector(Injector injector) Sets theInjector, being used for adapter map injection.
-
Constructor Details
-
AdapterInjector
Creates a newAdapterInjectorto inject the givenMethod, annotated with the givenAdapterMapmethod annotation.If in
AdapterInjectionSupport.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:
method- TheMethodto be injected.loggingMode- TheAdapterInjectionSupport.LoggingModeto use.
-
-
Method Details
-
injectAdapters
Performs the adapter map injection for the given adaptable instance.- Parameters:
adaptable- The adaptable to inject adapters into.
-
injectMembers
- Specified by:
injectMembersin interfaceMembersInjector<IAdaptable>
-
setInjector
Sets theInjector, being used for adapter map injection.- Parameters:
injector- TheInjectorto use.
-