Class AbstractResourceCollector
java.lang.Object
org.apache.sling.servlets.resolver.internal.helper.AbstractResourceCollector
- Direct Known Subclasses:
NamedScriptResourceCollector
,ResourceCollector
The
ResourceCollector
class provides a single public method -
getServlets(ResourceResolver,List<String>)
- which is used to find an ordered collection
of Resource
instances which may be used to find a servlet or
script to handle a request to the given resource.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addWeightedResource
(Set<org.apache.sling.servlets.resolver.internal.helper.WeightedResource> resources, Resource resource, int numSelectors, int methodPrefixWeight) Creates aWeightedResource
and adds it to the set of resources.static void
clearCache
(@NotNull ResourceResolver resolver) boolean
protected final @NotNull Resource
getResource
(@NotNull ResourceResolver resolver, @NotNull String path, boolean useCaching) Returns a resource for the givenpath
.static @Nullable Resource
getResourceOrNull
(@NotNull ResourceResolver resolver, @NotNull String path, boolean useCaching) Resolvers a resource or null if there is no resource resolved from the given path.final Collection<Resource>
getServlets
(ResourceResolver resolver, List<String> scriptExtensions) protected abstract void
getWeightedResources
(Set<org.apache.sling.servlets.resolver.internal.helper.WeightedResource> resources, Resource location) int
hashCode()
protected boolean
stringEquals
(String s1, String s2) Helper method to compare two strings which can possibly benull
-
Field Details
-
CACHE_KEY_CHILDREN_LIST
-
CACHE_KEY_RESOURCES
-
baseResourceType
-
extension
-
hashCode
protected int hashCode -
resourceType
-
resourceSuperType
-
executionPaths
-
useResourceCaching
protected boolean useResourceCaching
-
-
Constructor Details
-
AbstractResourceCollector
-
-
Method Details
-
getServlets
public final Collection<Resource> getServlets(ResourceResolver resolver, List<String> scriptExtensions) -
getWeightedResources
-
addWeightedResource
protected final void addWeightedResource(Set<org.apache.sling.servlets.resolver.internal.helper.WeightedResource> resources, Resource resource, int numSelectors, int methodPrefixWeight) Creates aWeightedResource
and adds it to the set of resources. The number of resources already present in the set is used as the ordinal number for the newly created resource.- Parameters:
resources
- The set of resource to which theWeightedResource
is added.resource
- TheResource
on which theWeightedResource
is based.numSelectors
- The number of request selectors which are matched by the name of the resource.methodPrefixWeight
- The method/prefix weight assigned to the resource according to the resource name.
-
getResource
@NotNull protected final @NotNull Resource getResource(@NotNull @NotNull ResourceResolver resolver, @NotNull @NotNull String path, boolean useCaching) Returns a resource for the givenpath
. If no resource exists at the given path aSyntheticResource
is returned.- Parameters:
resolver
- TheResourceResolver
used to access the resource.path
- The absolute path of the resource to return.- Returns:
- The actual resource at the given
path
or a synthetic resource representing the path location.
-
equals
-
hashCode
public int hashCode() -
stringEquals
Helper method to compare two strings which can possibly benull
-
clearCache
-
getResourceOrNull
@Nullable public static @Nullable Resource getResourceOrNull(@NotNull @NotNull ResourceResolver resolver, @NotNull @NotNull String path, boolean useCaching) Resolvers a resource or null if there is no resource resolved from the given path.- Parameters:
resolver
- the resourceResolver to usepath
- the path to the resourceuseCaching
- indicates if caching should be used- Returns:
- a resource or null if no resource can be resolved
-