Klasse ScriptHelper

java.lang.Object
org.apache.sling.scripting.core.ScriptHelper
Alle implementierten Schnittstellen:
org.apache.sling.api.scripting.SlingScriptHelper

public class ScriptHelper extends Object implements org.apache.sling.api.scripting.SlingScriptHelper
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!
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    protected final org.osgi.framework.BundleContext
    The bundle context.
    protected List<org.osgi.framework.ServiceReference<?>>
    The list of references - we don't need to synchronize this as we are running in one single request.
    protected Map<String,Object>
    A map of found services.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script)
     
    ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
    ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script, org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.api.SlingJakartaHttpServletResponse response)
    Creates a new script helper instance.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    Clean up this instance.
    void
    Veraltet.
    This method is deprecated and should never be called by clients!
    void
     
    void
    forward(String path, String options)
     
    void
    forward(String path, org.apache.sling.api.request.RequestDispatcherOptions options)
     
    void
    forward(org.apache.sling.api.resource.Resource resource)
     
    void
    forward(org.apache.sling.api.resource.Resource resource, String options)
     
    void
    forward(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options)
     
    org.apache.sling.api.SlingJakartaHttpServletRequest
     
    org.apache.sling.api.SlingJakartaHttpServletResponse
     
    org.apache.sling.api.SlingHttpServletRequest
     
    org.apache.sling.api.SlingHttpServletResponse
     
    org.apache.sling.api.scripting.SlingScript
     
    <T> T
    getService(Class<T> type)
     
    <T> T[]
    getServices(Class<T> serviceType, String filter)
     
    void
     
    void
    include(String path, String options)
     
    void
    include(String path, org.apache.sling.api.request.RequestDispatcherOptions options)
     
    void
    include(org.apache.sling.api.resource.Resource resource)
     
    void
    include(org.apache.sling.api.resource.Resource resource, String options)
     
    void
    include(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options)
     

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • bundleContext

      protected final org.osgi.framework.BundleContext bundleContext
      The bundle context.
    • references

      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.
    • services

      protected Map<String,Object> services
      A map of found services.
  • Konstruktordetails

    • ScriptHelper

      public ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script)
    • ScriptHelper

      public ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script, org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.api.SlingJakartaHttpServletResponse response)
      Creates a new script helper instance.
      Parameter:
      ctx - The bundle context, must not be null.
      script - The script, must not be null.
      request - The request, may be null.
      response - The response, may be null.
      Seit:
      2.2.0
    • ScriptHelper

      @Deprecated public ScriptHelper(org.osgi.framework.BundleContext ctx, org.apache.sling.api.scripting.SlingScript script, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
      Creates a new script helper instance.
      Parameter:
      ctx - The bundle context, must not be null.
      script - The script, must not be null.
      request - The request, may be null.
      response - The response, may be null.
  • Methodendetails

    • getScript

      public org.apache.sling.api.scripting.SlingScript getScript()
      Angegeben von:
      getScript in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getScript()
    • getJakartaRequest

      public org.apache.sling.api.SlingJakartaHttpServletRequest getJakartaRequest()
      Angegeben von:
      getJakartaRequest in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getJakartaRequest()
    • getJakartaResponse

      public org.apache.sling.api.SlingJakartaHttpServletResponse getJakartaResponse()
      Angegeben von:
      getJakartaResponse in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getJakartaResponse()
    • getRequest

      public org.apache.sling.api.SlingHttpServletRequest getRequest()
      Angegeben von:
      getRequest in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getRequest()
    • getResponse

      public org.apache.sling.api.SlingHttpServletResponse getResponse()
      Angegeben von:
      getResponse in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getResponse()
    • include

      public void include(String path)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.include(java.lang.String)
    • include

      public void include(String path, String options)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.include(java.lang.String, java.lang.String)
    • include

      public void include(String path, org.apache.sling.api.request.RequestDispatcherOptions options)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.include(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)
    • forward

      public void forward(String path)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(java.lang.String)
    • forward

      public void forward(String path, String options)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(java.lang.String, java.lang.String)
    • forward

      public void forward(String path, org.apache.sling.api.request.RequestDispatcherOptions options)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)
    • dispose

      @Deprecated public void dispose()
      Veraltet.
      This method is deprecated and should never be called by clients!
      Angegeben von:
      dispose in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.dispose()
    • getService

      public <T> T getService(Class<T> type)
      Angegeben von:
      getService in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.getService(java.lang.Class)
    • getServices

      public <T> T[] getServices(Class<T> serviceType, String filter) throws org.apache.sling.api.scripting.InvalidServiceFilterSyntaxException
      Angegeben von:
      getServices in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Löst aus:
      org.apache.sling.api.scripting.InvalidServiceFilterSyntaxException
      Siehe auch:
      • SlingScriptHelper.getServices(java.lang.Class, java.lang.String)
    • cleanup

      public void cleanup()
      Clean up this instance.
    • forward

      public void forward(org.apache.sling.api.resource.Resource resource)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(org.apache.sling.api.resource.Resource)
    • forward

      public void forward(org.apache.sling.api.resource.Resource resource, String options)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(org.apache.sling.api.resource.Resource, java.lang.String)
    • forward

      public void forward(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options)
      Angegeben von:
      forward in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(org.apache.sling.api.resource.Resource, org.apache.sling.api.request.RequestDispatcherOptions)
    • include

      public void include(org.apache.sling.api.resource.Resource resource)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.forward(org.apache.sling.api.resource.Resource)
    • include

      public void include(org.apache.sling.api.resource.Resource resource, String options)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.include(org.apache.sling.api.resource.Resource, java.lang.String)
    • include

      public void include(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestDispatcherOptions options)
      Angegeben von:
      include in Schnittstelle org.apache.sling.api.scripting.SlingScriptHelper
      Siehe auch:
      • SlingScriptHelper.include(org.apache.sling.api.resource.Resource, org.apache.sling.api.request.RequestDispatcherOptions)