Package com.adobe.acs.commons.util
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
ConstructorsConstructorDescriptionOverridePathSlingRequestWrapper(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 TypeMethodDescription<AdapterType>
AdapterTypeOverriding `adaptTo` to avoid using the original request as the adaptable.getAttribute(String name) org.apache.sling.api.resource.ResourceMethods inherited from class org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
getCookie, getRequestDispatcher, getRequestDispatcher, getRequestDispatcher, getRequestParameter, getRequestParameterList, getRequestParameterMap, getRequestParameters, getRequestPathInfo, getRequestProgressTracker, getResourceBundle, getResourceBundle, getResourceResolver, getResponseContentType, getResponseContentTypes, getSlingRequestMethods 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, upgradeMethods 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, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, upgradeMethods 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
- Specified by:
getAttributein interfacejavax.servlet.ServletRequest- Overrides:
getAttributein classjavax.servlet.ServletRequestWrapper
-
getResource
public org.apache.sling.api.resource.Resource getResource()- Specified by:
getResourcein interfaceorg.apache.sling.api.SlingHttpServletRequest- Overrides:
getResourcein classorg.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
-
adaptTo
Overriding `adaptTo` to avoid using the original request as the adaptable.- Specified by:
adaptToin interfaceorg.apache.sling.api.adapter.Adaptable- Overrides:
adaptToin classorg.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
-