ResourceResolver
defines the service API which may be used to resolve {@link Resource} objects. The resource resolver is available tothe request processing servlet through the {@link org.apache.sling.api.SlingHttpServletRequest#getResourceResolver()}method. A resource resolver can also be created through the {@link ResourceResolverFactory}. The ResourceResolver
is also an {@link Adaptable} to getadapters to other types. A JCR based resource resolver might support adapting to the JCR Session used by the resolver to access the JCR Repository.
A ResourceResolver
is generally not thread safe! As a consequence, an application which uses the resolver, its returned resources and/or objects resulting from adapting either the resolver or a resource, must provide proper synchronization to ensure no more than one thread concurrently operates against a single resolver, resource or resulting objects.
Accessing Resources
This interface defines two kinds of methods to access resources: The resolve
methods and the getResource
methods. The difference lies in the algorithm applied to find the requested resource and in the behavior in case a resource cannot be found:
Method Kind | Access Algorithm | Missing Resource |
---|---|---|
resolve | Path is always assumed to be absolute. Uses elaborate resource resolution algorithm. This kind of method is intended to resolve request URLs to resources. | Returns {@link NonExistingResource} |
getResource | Directly access resources with absolute path. For relative paths, the {@link #getSearchPath() search path} is applied. This method is intended tobe used by request processing scripts to access further resources as required. | Returns null |
Lifecycle
A Resource Resolver has a life cycle which begins with the creation of the Resource Resolver using any of the factory methods and ends with calling the {@link #close()} method. It is very important to call the {@link #close()}method once the resource resolver is not used any more to ensure any system resources are properly cleaned up.
To check whether a Resource Resolver can still be used, the {@link #isLive()}method can be called.
Resource Resolver Attributes
The authentication info properties provided to the {@link ResourceResolverFactory#getResourceResolver(Map)}, {@link ResourceResolverFactory#getAdministrativeResourceResolver(Map)}, or {@link #clone(Map)} are available through the {@link #getAttributeNames()}and {@link #getAttribute(String)} methods with the exception of securitysensitive properties like {@link ResourceResolverFactory#PASSWORD} which isnot exposed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|