public class ScriptHelper extends java.lang.Object implements SlingScriptHelper
sling
variable.
Client code using this object should take care to call cleanup()
when the object is not used anymore!| Constructor and Description |
|---|
ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script) |
ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script,
SlingHttpServletRequest request,
SlingHttpServletResponse response) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Clean up this instance.
|
void |
dispose()
Deprecated.
|
void |
forward(Resource resource)
Same as
SlingScriptHelper.forward(Resource,RequestDispatcherOptions), but using
empty options. |
void |
forward(Resource resource,
RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given
resource and options. |
void |
forward(Resource resource,
java.lang.String options)
Helper method to forward the request to a Servlet or script for the given
resource and requestDispatcherOptions. |
void |
forward(java.lang.String path)
Same as
SlingScriptHelper.forward(String,RequestDispatcherOptions), but using
empty options. |
void |
forward(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(java.lang.String path,
java.lang.String options)
Helper method to forward the request to a Servlet or script for the given
path and requestDispatcherOptions. |
SlingHttpServletRequest |
getRequest()
Returns the
SlingHttpServletRequest representing the input of the
request. |
SlingHttpServletResponse |
getResponse()
Returns the
SlingHttpServletResponse representing the output of
the request. |
SlingScript |
getScript()
Returns the
SlingScript being called to handle the request. |
<ServiceType> |
getService(java.lang.Class<ServiceType> type)
Lookup a single service.
|
<ServiceType> |
getServices(java.lang.Class<ServiceType> serviceType,
java.lang.String filter)
Lookup one or several services.
|
void |
include(Resource resource)
Same as
SlingScriptHelper.include(Resource,RequestDispatcherOptions), but using
empty options. |
void |
include(Resource resource,
RequestDispatcherOptions options)
Helper method to include the result of processing the request for the
given
resource and options. |
void |
include(Resource resource,
java.lang.String options)
Helper method to include the result of processing the request for the
given
resource and requestDispatcherOptions. |
void |
include(java.lang.String path)
Same as
SlingScriptHelper.include(String,RequestDispatcherOptions), but using
empty options. |
void |
include(java.lang.String path,
RequestDispatcherOptions options)
Helper method to include the result of processing the request for the
given
path and options. |
void |
include(java.lang.String path,
java.lang.String options)
Helper method to include the result of processing the request for the
given
path and requestDispatcherOptions. |
public ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script)
public ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script,
SlingHttpServletRequest request,
SlingHttpServletResponse response)
public SlingScript getScript()
SlingScriptHelperSlingScript being called to handle the request.getScript in interface SlingScriptHelperSlingScriptHelper.getScript()public SlingHttpServletRequest getRequest()
SlingScriptHelperSlingHttpServletRequest representing the input of the
request.getRequest in interface SlingScriptHelperSlingScriptHelper.getRequest()public SlingHttpServletResponse getResponse()
SlingScriptHelperSlingHttpServletResponse representing the output of
the request.getResponse in interface SlingScriptHelperSlingScriptHelper.getResponse()public void include(java.lang.String path)
SlingScriptHelperSlingScriptHelper.include(String,RequestDispatcherOptions), but using
empty options.include in interface SlingScriptHelperpath - The path to includeSlingScriptHelper.include(java.lang.String)public void include(java.lang.String path,
java.lang.String options)
SlingScriptHelperpath 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(String)
constructor.
include in interface SlingScriptHelperpath - The path to the resource to include.options - influence the rendering of the included
ResourceSlingScriptHelper.include(java.lang.String, java.lang.String)public void include(java.lang.String path,
RequestDispatcherOptions options)
SlingScriptHelperpath 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());
}
include in interface SlingScriptHelperpath - The path to the resource to include.options - influence the rendering of the included ResourceSlingScriptHelper.include(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)public void forward(java.lang.String path)
SlingScriptHelperSlingScriptHelper.forward(String,RequestDispatcherOptions), but using
empty options.forward in interface SlingScriptHelperpath - The path to forward toSlingScriptHelper.forward(java.lang.String)public void forward(java.lang.String path,
java.lang.String options)
SlingScriptHelperpath 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(String)
constructor.
forward in interface SlingScriptHelperpath - The path to the resource to forward to.options - influence the rendering of the forwarded
ResourceSlingScriptHelper.forward(java.lang.String, java.lang.String)public void forward(java.lang.String path,
RequestDispatcherOptions options)
SlingScriptHelperpath 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());
}
forward in interface SlingScriptHelperpath - The path to the resource to forward the request to.options - influence the rendering of the forwarded ResourceSlingScriptHelper.forward(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)@Deprecated public void dispose()
SlingScriptHelperdispose in interface SlingScriptHelperSlingScriptHelper.dispose()public <ServiceType> ServiceType getService(java.lang.Class<ServiceType> type)
SlingScriptHelperIf 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).
getService in interface SlingScriptHelperServiceType - The type (interface) of the service.type - The type (interface) of the service.null if no services are registered which implement the specified class.SlingScriptHelper.getService(java.lang.Class)public <ServiceType> ServiceType[] getServices(java.lang.Class<ServiceType> serviceType,
java.lang.String filter)
throws InvalidServiceFilterSyntaxException
SlingScriptHelperThe 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.
getServices in interface SlingScriptHelperServiceType - 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.SlingScriptHelper.getServices(java.lang.Class, java.lang.String)public void cleanup()
public void forward(Resource resource)
SlingScriptHelperSlingScriptHelper.forward(Resource,RequestDispatcherOptions), but using
empty options.forward in interface SlingScriptHelperresource - The resource to forward to.SlingScriptHelper.forward(org.apache.sling.api.resource.Resource)public void forward(Resource resource, java.lang.String options)
SlingScriptHelperresource 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(String)
constructor.
forward in interface SlingScriptHelperresource - The resource to forward to.options - influence the rendering of the forwarded
ResourceSlingScriptHelper.forward(org.apache.sling.api.resource.Resource, java.lang.String)public void forward(Resource resource, RequestDispatcherOptions options)
SlingScriptHelperresource 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());
}
forward in interface SlingScriptHelperresource - The resource to forward the request to.options - influence the rendering of the forwarded ResourceSlingScriptHelper.forward(org.apache.sling.api.resource.Resource, org.apache.sling.api.request.RequestDispatcherOptions)public void include(Resource resource)
SlingScriptHelperSlingScriptHelper.include(Resource,RequestDispatcherOptions), but using
empty options.include in interface SlingScriptHelperresource - The resource to includeSlingScriptHelper.forward(org.apache.sling.api.resource.Resource)public void include(Resource resource, java.lang.String options)
SlingScriptHelperresource 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(String)
constructor.
include in interface SlingScriptHelperresource - The resource to include.options - influence the rendering of the included
ResourceSlingScriptHelper.include(org.apache.sling.api.resource.Resource, java.lang.String)public void include(Resource resource, RequestDispatcherOptions options)
SlingScriptHelperresource 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());
}
include in interface SlingScriptHelperresource - The resource to include.options - influence the rendering of the included ResourceSlingScriptHelper.include(org.apache.sling.api.resource.Resource, org.apache.sling.api.request.RequestDispatcherOptions)Copyright © 2010 - 2023 Adobe. All Rights Reserved