Class ResourcePathInjector
java.lang.Object
org.apache.sling.models.impl.injectors.ResourcePathInjector
- All Implemented Interfaces:
AcceptsNullName
,Injector
,StaticInjectAnnotationProcessorFactory
public class ResourcePathInjector
extends Object
implements Injector, AcceptsNullName, StaticInjectAnnotationProcessorFactory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull String
getName()
Return a logical name for the injector.protected ResourceResolver
getResourceResolver
(Object adaptable) getValue
(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element, @NotNull DisposalCallbackRegistry callbackRegistry) Produce a value for an injection point.protected @Nullable ValueMap
getValueMap
(Object adaptable) Retrieve the ValueMap from the given adaptable.protected boolean
isDeclaredTypeCollection
(Type declaredType)
-
Constructor Details
-
ResourcePathInjector
public ResourcePathInjector()
-
-
Method Details
-
getName
Description copied from interface:Injector
Return a logical name for the injector. Used in resolving@Source
annotations. -
getValue
public Object getValue(@NotNull @NotNull Object adaptable, String name, @NotNull @NotNull Type declaredType, @NotNull @NotNull AnnotatedElement element, @NotNull @NotNull DisposalCallbackRegistry callbackRegistry) Description copied from interface:Injector
Produce a value for an injection point.- Specified by:
getValue
in interfaceInjector
- Parameters:
adaptable
- the object which should be used as the basis for value resolution.name
- the injection point name (may be onlynull
if injector implements theAcceptsNullName
interface, otherwise nevernull
)declaredType
- the declared type of the injection pointelement
- the injection point itselfcallbackRegistry
- a registry object to register a callback object which will be invoked when the adapted object is disposed.- Returns:
- the value to be injected or null if no value could be resolved
-
createAnnotationProcessor
- Specified by:
createAnnotationProcessor
in interfaceStaticInjectAnnotationProcessorFactory
- Parameters:
element
- the field or method which is annotated- Returns:
- a ModelAnnotationProcessor in case there is a known injector-specific annotation on the given element found otherwise null
-
getResourceResolver
-
getValueMap
Retrieve the ValueMap from the given adaptable. This succeeds, if the adaptable is either- a
ValueMap
, - a
SlingHttpServletRequest
, in which case the returnedValueMap
is the one derived from the request's resource or - adaptable to a
ValueMap
.
null
is returned.- Parameters:
adaptable
- Adaptable- Returns:
- a ValueMap or
null
.
- a
-
isDeclaredTypeCollection
-