Class OverridePathSlingRequestWrapper

java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
com.adobe.acs.commons.util.OverridePathSlingRequestWrapper
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest, org.apache.sling.api.adapter.Adaptable, org.apache.sling.api.SlingHttpServletRequest

public class OverridePathSlingRequestWrapper extends org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
Request wrapper to get the Resource and SlingBindings objects for a request scoped to a specified path. Among other things, this enables injection of sling models from a SlingHttpServletRequest object rather than simply a Resource, which is required by some sling models for full functionality.
  • Field Summary

    Fields inherited from interface javax.servlet.http.HttpServletRequest

    BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
  • Constructor Summary

    Constructors
    Constructor
    Description
    OverridePathSlingRequestWrapper(org.apache.sling.api.SlingHttpServletRequest request, String path)
    Constructor for generic request wrapper.
    OverridePathSlingRequestWrapper(org.apache.sling.api.SlingHttpServletRequest request, String path, org.apache.sling.scripting.api.BindingsValuesProvidersByContext bindingsValuesProvidersByContext)
    Constructor for request wrapper to be used for sling model injection.
  • Method Summary

    Modifier and Type
    Method
    Description
    <AdapterType>
    AdapterType
    adaptTo(Class<AdapterType> type)
    Overriding `adaptTo` to avoid using the original request as the adaptable.
     
    org.apache.sling.api.resource.Resource
     

    Methods inherited from class org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper

    getCookie, getRequestDispatcher, getRequestDispatcher, getRequestDispatcher, getRequestParameter, getRequestParameterList, getRequestParameterMap, getRequestParameters, getRequestPathInfo, getRequestProgressTracker, getResourceBundle, getResourceBundle, getResourceResolver, getResponseContentType, getResponseContentTypes, getSlingRequest

    Methods inherited from class javax.servlet.http.HttpServletRequestWrapper

    authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade

    Methods inherited from class javax.servlet.ServletRequestWrapper

    getAsyncContext, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface javax.servlet.http.HttpServletRequest

    authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade

    Methods inherited from interface javax.servlet.ServletRequest

    getAsyncContext, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
  • Constructor Details

    • OverridePathSlingRequestWrapper

      public OverridePathSlingRequestWrapper(org.apache.sling.api.SlingHttpServletRequest request, String path)
      Constructor for generic request wrapper.
      Parameters:
      request - A valid sling request.
      path - Path to represent by this request wrapper.
    • OverridePathSlingRequestWrapper

      public OverridePathSlingRequestWrapper(org.apache.sling.api.SlingHttpServletRequest request, String path, org.apache.sling.scripting.api.BindingsValuesProvidersByContext bindingsValuesProvidersByContext)
      Constructor for request wrapper to be used for sling model injection. Ensures the wrapped request is created with all standard sling model bindings.
      Parameters:
      request - A valid sling request.
      path - Path to represent by this request wrapper.
      bindingsValuesProvidersByContext - Service reference to list of bindings providers.
  • Method Details

    • getAttribute

      public Object getAttribute(String name)
      Specified by:
      getAttribute in interface javax.servlet.ServletRequest
      Overrides:
      getAttribute in class javax.servlet.ServletRequestWrapper
    • getResource

      public org.apache.sling.api.resource.Resource getResource()
      Specified by:
      getResource in interface org.apache.sling.api.SlingHttpServletRequest
      Overrides:
      getResource in class org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
    • adaptTo

      public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
      Overriding `adaptTo` to avoid using the original request as the adaptable.
      Specified by:
      adaptTo in interface org.apache.sling.api.adapter.Adaptable
      Overrides:
      adaptTo in class org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper