public interface ResourceResolverHelper
ResourceResolverHelper
service provides access to a
ResourceResolver
previously provided for the current thread.
The implementation provides two contexts:
ResourceResolver
provided is the one provided by the Sling
Engine through the SlingHttpServletRequest
callWith(ResourceResolver, Callable)
methodModifier and Type | Method and Description |
---|---|
<Type> Type |
callWith(ResourceResolver resolver,
java.util.concurrent.Callable<Type> callable)
Calls the given
callable under the provides
ResourceResolver . |
ResourceResolver |
getResourceResolver()
Returns the current
ResourceResolver for the current thread
or null if this method is called on a thread which is not
handling a request or which is not in a call stack started with a call to
the callWith(ResourceResolver, Callable) method. |
<Type> Type |
getResourceResolverAs(java.lang.Class<Type> type)
Returns the current
ResourceResolver adapted to the selected
type. |
ResourceResolver getResourceResolver()
ResourceResolver
for the current thread
or null
if this method is called on a thread which is not
handling a request or which is not in a call stack started with a call to
the callWith(ResourceResolver, Callable)
method.
ResourceResolver
instances must not be shared accross
threads because they are not thread safe.
<Type> Type getResourceResolverAs(java.lang.Class<Type> type)
ResourceResolver
adapted to the selected
type. If there is no curren ResourceResolver
or if the
ResourceResolver
does not adapt to the desired type
null
is returned.
This method is equivalent to calling
getResourceResolver().adaptTo(type)
.
type
- The type to which the current ResourceResolver
should be adapted.ResourceResolver
adapted to the desired
type
or null
<Type> Type callWith(ResourceResolver resolver, java.util.concurrent.Callable<Type> callable) throws java.lang.Exception
callable
under the provides
ResourceResolver
. Before calling the callable
the resolver
is set as the current
ResourceResolver
such that the
getResourceResolver()
method returns the given
ResourceResolver
.resolver
- The ResourceResolver
to set as the current
ResourceResolver
before calling the
callable
.callable
- The code to execute under the resolver
.callable
java.lang.NullPointerException
- if callable
is
null
.java.lang.Exception
- The exception thrown by the callable
is
returned."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"