@ProviderType public interface SlingScriptHelper
SlingScriptHelper
interface defines the API of a helper
class which is provided to the scripts called from sling through the global
sling
variable.Modifier and Type | Method and Description |
---|---|
void |
dispose()
Deprecated.
This method is deprecated since version 2.1 and will be removed.
It should never be called by clients.
|
void |
forward(@NotNull Resource resource)
Same as
forward(Resource,RequestDispatcherOptions) , but using
empty options. |
void |
forward(@NotNull Resource resource,
RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given
resource and options . |
void |
forward(@NotNull Resource resource,
java.lang.String requestDispatcherOptions)
Helper method to forward the request to a Servlet or script for the given
resource and requestDispatcherOptions . |
void |
forward(@NotNull java.lang.String path)
Same as
forward(String,RequestDispatcherOptions) , but using
empty options. |
void |
forward(@NotNull java.lang.String path,
RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given
path and options . |
void |
forward(@NotNull java.lang.String path,
java.lang.String requestDispatcherOptions)
Helper method to forward the request to a Servlet or script for the given
path and requestDispatcherOptions . |
@NotNull SlingHttpServletRequest |
getRequest()
Returns the
SlingHttpServletRequest representing the input of the
request. |
@NotNull SlingHttpServletResponse |
getResponse()
Returns the
SlingHttpServletResponse representing the output of
the request. |
@NotNull SlingScript |
getScript()
Returns the
SlingScript being called to handle the request. |
<ServiceType> |
getService(@NotNull java.lang.Class<ServiceType> serviceType)
Lookup a single service.
|
<ServiceType> |
getServices(@NotNull java.lang.Class<ServiceType> serviceType,
java.lang.String filter)
Lookup one or several services.
|
void |
include(@NotNull Resource resource)
Same as
include(Resource,RequestDispatcherOptions) , but using
empty options. |
void |
include(@NotNull Resource resource,
RequestDispatcherOptions options)
Helper method to include the result of processing the request for the
given
resource and options . |
void |
include(@NotNull Resource resource,
java.lang.String requestDispatcherOptions)
Helper method to include the result of processing the request for the
given
resource and requestDispatcherOptions . |
void |
include(@NotNull java.lang.String path)
Same as
include(String,RequestDispatcherOptions) , but using
empty options. |
void |
include(@NotNull java.lang.String path,
RequestDispatcherOptions options)
Helper method to include the result of processing the request for the
given
path and options . |
void |
include(@NotNull java.lang.String path,
java.lang.String requestDispatcherOptions)
Helper method to include the result of processing the request for the
given
path and requestDispatcherOptions . |
@NotNull @NotNull SlingHttpServletRequest getRequest()
SlingHttpServletRequest
representing the input of the
request.@NotNull @NotNull SlingHttpServletResponse getResponse()
SlingHttpServletResponse
representing the output of
the request.@NotNull @NotNull SlingScript getScript()
SlingScript
being called to handle the request.void include(@NotNull @NotNull java.lang.String path)
include(String,RequestDispatcherOptions)
, but using
empty options.path
- The path to includeSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.void include(@NotNull @NotNull java.lang.String path, java.lang.String requestDispatcherOptions)
path
and requestDispatcherOptions
.
This method is intended to be implemented as follows:
RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, "option:xyz"); if (dispatcher != null) { dispatcher.include(getRequest(), getResponse()); }
This method creates a RequestDispatcherOptions
object by
calling the
RequestDispatcherOptions.RequestDispatcherOptions(String)
constructor.
path
- The path to the resource to include.requestDispatcherOptions
- influence the rendering of the included
ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.RequestDispatcherOptions.RequestDispatcherOptions(String)
,
include(String, RequestDispatcherOptions)
void include(@NotNull @NotNull java.lang.String path, RequestDispatcherOptions options)
path
and options
. This method is
intended to be implemented as follows:
RequestDispatcherOptions opts = new RequestDispatcherOptions(); opts.put("option", "xyz"); RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, opts); if (dispatcher != null) { dispatcher.include(getRequest(), getResponse()); }
path
- The path to the resource to include.options
- influence the rendering of the included ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.RequestDispatcherOptions
,
include(String, String)
void include(@NotNull @NotNull Resource resource)
include(Resource,RequestDispatcherOptions)
, but using
empty options.resource
- The resource to includeSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.void include(@NotNull @NotNull Resource resource, java.lang.String requestDispatcherOptions)
resource
and requestDispatcherOptions
.
This method is intended to be implemented as follows:
RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, "option:xyz"); if (dispatcher != null) { dispatcher.include(getRequest(), getResponse()); }
This method creates a RequestDispatcherOptions
object by
calling the
RequestDispatcherOptions.RequestDispatcherOptions(String)
constructor.
resource
- The resource to include.requestDispatcherOptions
- influence the rendering of the included
ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.RequestDispatcherOptions.RequestDispatcherOptions(String)
,
include(String, RequestDispatcherOptions)
void include(@NotNull @NotNull Resource resource, RequestDispatcherOptions options)
resource
and options
. This method is
intended to be implemented as follows:
RequestDispatcherOptions opts = new RequestDispatcherOptions(); opts.put("option", "xyz"); RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, opts); if (dispatcher != null) { dispatcher.include(getRequest(), getResponse()); }
resource
- The resource to include.options
- influence the rendering of the included ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the include.SlingServletException
- Wrapping a ServletException
thrown while handling the include.RequestDispatcherOptions
,
include(String, String)
void forward(@NotNull @NotNull java.lang.String path)
forward(String,RequestDispatcherOptions)
, but using
empty options.path
- The path to forward toSlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.void forward(@NotNull @NotNull java.lang.String path, java.lang.String requestDispatcherOptions)
path
and requestDispatcherOptions
. This method
is intended to be implemented as follows:
RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, "option:xyz"); if (dispatcher != null) { dispatcher.forward(getRequest(), getResponse()); }
This method creates a RequestDispatcherOptions
object by
calling the
RequestDispatcherOptions.RequestDispatcherOptions(String)
constructor.
path
- The path to the resource to forward to.requestDispatcherOptions
- influence the rendering of the forwarded
ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.RequestDispatcherOptions.RequestDispatcherOptions(String)
,
forward(String, RequestDispatcherOptions)
void forward(@NotNull @NotNull java.lang.String path, RequestDispatcherOptions options)
path
and options
. This method is intended
to be implemented as follows:
RequestDispatcherOptions opts = new RequestDispatcherOptions(); opts.put("option", "xyz"); RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, opts); if (dispatcher != null) { dispatcher.forward(getRequest(), getResponse()); }
path
- The path to the resource to forward the request to.options
- influence the rendering of the forwarded ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.java.lang.IllegalStateException
- If the respoonse has already been committedRequestDispatcherOptions
void forward(@NotNull @NotNull Resource resource)
forward(Resource,RequestDispatcherOptions)
, but using
empty options.resource
- The resource to forward to.SlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.void forward(@NotNull @NotNull Resource resource, java.lang.String requestDispatcherOptions)
resource
and requestDispatcherOptions
. This method
is intended to be implemented as follows:
RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, "option:xyz"); if (dispatcher != null) { dispatcher.forward(getRequest(), getResponse()); }
This method creates a RequestDispatcherOptions
object by
calling the
RequestDispatcherOptions.RequestDispatcherOptions(String)
constructor.
resource
- The resource to forward to.requestDispatcherOptions
- influence the rendering of the forwarded
ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.RequestDispatcherOptions.RequestDispatcherOptions(String)
,
forward(String, RequestDispatcherOptions)
void forward(@NotNull @NotNull Resource resource, RequestDispatcherOptions options)
resource
and options
. This method is intended
to be implemented as follows:
RequestDispatcherOptions opts = new RequestDispatcherOptions(); opts.put("option", "xyz"); RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, opts); if (dispatcher != null) { dispatcher.forward(getRequest(), getResponse()); }
resource
- The resource to forward the request to.options
- influence the rendering of the forwarded ResourceSlingIOException
- Wrapping a IOException
thrown
while handling the forward.SlingServletException
- Wrapping a ServletException
thrown while handling the forward.java.lang.IllegalStateException
- If the respoonse has already been committedRequestDispatcherOptions
@Nullable <ServiceType> ServiceType getService(@NotNull @NotNull java.lang.Class<ServiceType> serviceType)
If multiple such services exist, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned. If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.
This is equal to the semantics from BundleContext.getServiceReference(Class).
ServiceType
- The type (interface) of the service.serviceType
- The type (interface) of the service.null
if no services are registered which implement the specified class.@Nullable <ServiceType> ServiceType[] getServices(@NotNull @NotNull java.lang.Class<ServiceType> serviceType, java.lang.String filter)
The returned array is sorted descending by service ranking (i.e. the service with the highest ranking is returned first). If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned first.
ServiceType
- The type (interface) of the service.serviceType
- The type (interface) of the service.filter
- An optional filter (LDAP-like, see OSGi spec)null
.InvalidServiceFilterSyntaxException
- If the filter
string is not a valid OSGi service filter string.@Deprecated void dispose()
Copyright © 2010 - 2020 Adobe. All Rights Reserved