|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.sling.scripting.core.ScriptHelper
public class ScriptHelper
Simple script helper providing access to the (wrapped) response, the
on-demand writer and a simple API for request inclusion. Instances of this
class are made available to the scripts as the global sling
variable.
Client code using this object should take care to call cleanup()
when the object is not used anymore!
| Field Summary | |
|---|---|
protected org.osgi.framework.BundleContext |
bundleContext
The bundle context. |
protected List<org.osgi.framework.ServiceReference> |
references
The list of references - we don't need to synchronize this as we are running in one single request. |
protected Map<String,Object> |
services
A map of found services. |
| Constructor Summary | |
|---|---|
ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script)
|
|
ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script,
SlingHttpServletRequest request,
SlingHttpServletResponse response)
|
|
| Method Summary | ||
|---|---|---|
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,
String options)
Helper method to forward the request to a Servlet or script for the given resource and requestDispatcherOptions. |
|
void |
forward(String path)
Same as SlingScriptHelper.forward(String,RequestDispatcherOptions), but using
empty options. |
|
void |
forward(String path,
RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given path and options. |
|
void |
forward(String path,
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. |
|
|
getService(Class<ServiceType> type)
Lookup a single service |
|
|
getServices(Class<ServiceType> serviceType,
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,
String options)
Helper method to include the result of processing the request for the given resource and requestDispatcherOptions. |
|
void |
include(String path)
Same as SlingScriptHelper.include(String,RequestDispatcherOptions), but using
empty options. |
|
void |
include(String path,
RequestDispatcherOptions options)
Helper method to include the result of processing the request for the given path and options. |
|
void |
include(String path,
String options)
Helper method to include the result of processing the request for the given path and requestDispatcherOptions. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.osgi.framework.BundleContext bundleContext
protected List<org.osgi.framework.ServiceReference> references
protected Map<String,Object> services
| Constructor Detail |
|---|
public ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script)
public ScriptHelper(org.osgi.framework.BundleContext ctx,
SlingScript script,
SlingHttpServletRequest request,
SlingHttpServletResponse response)
| Method Detail |
|---|
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(String path)
SlingScriptHelperSlingScriptHelper.include(String,RequestDispatcherOptions), but using
empty options.
include in interface SlingScriptHelperSlingScriptHelper.include(java.lang.String)
public void include(String path,
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.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(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(String path)
SlingScriptHelperSlingScriptHelper.forward(String,RequestDispatcherOptions), but using
empty options.
forward in interface SlingScriptHelperSlingScriptHelper.forward(java.lang.String)
public void forward(String path,
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.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(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()
SlingScriptHelper
dispose in interface SlingScriptHelperSlingScriptHelper.dispose()public <ServiceType> ServiceType getService(Class<ServiceType> type)
SlingScriptHelper
getService in interface SlingScriptHelpertype - The type (interface) of the service.
SlingScriptHelper.getService(java.lang.Class)
public <ServiceType> ServiceType[] getServices(Class<ServiceType> serviceType,
String filter)
throws InvalidServiceFilterSyntaxException
SlingScriptHelper
getServices in interface SlingScriptHelperserviceType - The type (interface) of the service.filter - An optional filter (LDAP-like, see OSGi spec)
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 SlingScriptHelperSlingScriptHelper.forward(org.apache.sling.api.resource.Resource)
public void forward(Resource resource,
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.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 SlingScriptHelperSlingScriptHelper.forward(org.apache.sling.api.resource.Resource)
public void include(Resource resource,
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.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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||