Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <AdapterType>
      AdapterType
      adaptTo​(Class<AdapterType> type)
      Overriding `adaptTo` to avoid using the original request as the adaptable.
      Object getAttribute​(String name)  
      org.apache.sling.api.resource.Resource getResource()  
      • 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 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 Detail

      • OverridePathSlingRequestWrapper

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

      • 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