public class RequestData extends Object
RequestData
class provides access to objects which are set
on a Servlet Request wide basis such as the repository session, the
persistence manager, etc.
The setup order is:
ContentData
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_CALL_COUNTER
The default value for the number of calls to the
service(SlingHttpServletRequest, SlingHttpServletResponse)
method for a single instance of this class (value is 1000). |
static int |
DEFAULT_MAX_INCLUSION_COUNTER
The default value for the number of recursive inclusions for a single
instance of this class (value is 50).
|
static String |
REQUEST_RESOURCE_PATH_ATTR
The name of the request attribute providing the resource addressed by the
request URL.
|
Constructor and Description |
---|
RequestData(SlingRequestProcessorImpl slingRequestProcessor,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
Modifier and Type | Method and Description |
---|---|
<Type> Type |
adaptTo(Object object,
Class<Type> type) |
String |
getActiveServletName()
Returns the name of the currently active servlet.
|
static ArrayList<StaticResponseHeader> |
getAdditionalResponseHeaders() |
ContentData |
getContentData() |
long |
getElapsedTimeMsec() |
javax.servlet.ServletInputStream |
getInputStream() |
static int |
getMaxCallCounter() |
static int |
getMaxIncludeCounter() |
String |
getMimeType(String fileName) |
ParameterSupport |
getParameterSupport() |
int |
getPeakRecusionDepth() |
BufferedReader |
getReader() |
static RequestData |
getRequestData(javax.servlet.ServletRequest request) |
static RequestData |
getRequestData(org.apache.sling.api.SlingHttpServletRequest request) |
org.apache.sling.api.request.RequestProgressTracker |
getRequestProgressTracker() |
org.apache.sling.api.resource.ResourceResolver |
getResourceResolver() |
int |
getServletCallCount() |
javax.servlet.http.HttpServletRequest |
getServletRequest() |
javax.servlet.http.HttpServletResponse |
getServletResponse() |
org.apache.sling.api.SlingHttpServletRequest |
getSlingRequest() |
SlingRequestProcessorImpl |
getSlingRequestProcessor() |
org.apache.sling.api.SlingHttpServletResponse |
getSlingResponse() |
org.apache.sling.api.resource.Resource |
initResource(org.apache.sling.api.resource.ResourceResolver resourceResolver) |
void |
initServlet(org.apache.sling.api.resource.Resource resource,
org.apache.sling.api.servlets.ServletResolver sr) |
void |
resetContent(ContentData data) |
static void |
service(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response)
Helper method to call the servlet for the current content data.
|
String |
setActiveServletName(String servletName)
Sets the name of the currently active servlet and returns the name of the
previously active servlet.
|
static void |
setAdditionalResponseHeaders(ArrayList<StaticResponseHeader> mappings) |
ContentData |
setContent(org.apache.sling.api.resource.Resource resource,
org.apache.sling.api.request.RequestPathInfo requestPathInfo) |
static void |
setMaxCallCounter(int maxCallCounter) |
static void |
setMaxIncludeCounter(int maxInclusionCounter) |
static void |
setSlingMainServlet(SlingMainServlet slingMainServlet) |
static org.apache.sling.api.SlingHttpServletRequest |
toSlingHttpServletRequest(javax.servlet.ServletRequest request) |
static org.apache.sling.api.SlingHttpServletResponse |
toSlingHttpServletResponse(javax.servlet.ServletResponse response) |
static org.apache.sling.api.SlingHttpServletRequest |
unwrap(javax.servlet.ServletRequest request)
Unwraps the ServletRequest to a SlingHttpServletRequest.
|
static org.apache.sling.api.SlingHttpServletResponse |
unwrap(javax.servlet.ServletResponse response)
Unwraps the ServletRequest to a SlingHttpServletRequest.
|
static SlingHttpServletRequestImpl |
unwrap(org.apache.sling.api.SlingHttpServletRequest request)
Unwraps the SlingHttpServletRequest to a SlingHttpServletRequestImpl
|
static SlingHttpServletResponseImpl |
unwrap(org.apache.sling.api.SlingHttpServletResponse response)
Unwraps a SlingHttpServletResponse to a SlingHttpServletResponseImpl
|
public static final int DEFAULT_MAX_INCLUSION_COUNTER
public static final int DEFAULT_MAX_CALL_COUNTER
service(SlingHttpServletRequest, SlingHttpServletResponse)
method for a single instance of this class (value is 1000).public static final String REQUEST_RESOURCE_PATH_ATTR
public RequestData(SlingRequestProcessorImpl slingRequestProcessor, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public static void setMaxCallCounter(int maxCallCounter)
public static int getMaxCallCounter()
public static void setMaxIncludeCounter(int maxInclusionCounter)
public static int getMaxIncludeCounter()
public static void setSlingMainServlet(SlingMainServlet slingMainServlet)
public static void setAdditionalResponseHeaders(ArrayList<StaticResponseHeader> mappings)
public static ArrayList<StaticResponseHeader> getAdditionalResponseHeaders()
public org.apache.sling.api.resource.Resource initResource(org.apache.sling.api.resource.ResourceResolver resourceResolver)
public void initServlet(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.servlets.ServletResolver sr)
public SlingRequestProcessorImpl getSlingRequestProcessor()
public javax.servlet.http.HttpServletRequest getServletRequest()
public javax.servlet.http.HttpServletResponse getServletResponse()
public org.apache.sling.api.SlingHttpServletRequest getSlingRequest()
public org.apache.sling.api.SlingHttpServletResponse getSlingResponse()
public static org.apache.sling.api.SlingHttpServletRequest unwrap(javax.servlet.ServletRequest request)
IllegalArgumentException
- If the request
is not a
SlingHttpServletRequest
and not a
ServletRequestWrapper
wrapping a
SlingHttpServletRequest
.public static SlingHttpServletRequestImpl unwrap(org.apache.sling.api.SlingHttpServletRequest request)
request
- IllegalArgumentException
- If request
is not a
SlingHttpServletRequestImpl
and not
SlingHttpServletRequestWrapper
wrapping a
SlingHttpServletRequestImpl
.public static org.apache.sling.api.SlingHttpServletResponse unwrap(javax.servlet.ServletResponse response)
IllegalArgumentException
- If the response
is not a
SlingHttpServletResponse
and not a
ServletResponseWrapper
wrapping a
SlingHttpServletResponse
.public static SlingHttpServletResponseImpl unwrap(org.apache.sling.api.SlingHttpServletResponse response)
response
- IllegalArgumentException
- If response
is not a
SlingHttpServletResponseImpl
and not
SlingHttpServletResponseWrapper
wrapping a
SlingHttpServletResponseImpl
.public static RequestData getRequestData(javax.servlet.ServletRequest request)
request
- IllegalArgumentException
- If the request
is not a
SlingHttpServletRequest
and not a
ServletRequestWrapper
wrapping a
SlingHttpServletRequest
.public static RequestData getRequestData(org.apache.sling.api.SlingHttpServletRequest request)
request
- IllegalArgumentException
- If request
is not a
SlingHttpServletRequestImpl
and not
SlingHttpServletRequestWrapper
wrapping a
SlingHttpServletRequestImpl
.public static org.apache.sling.api.SlingHttpServletRequest toSlingHttpServletRequest(javax.servlet.ServletRequest request)
request
- IllegalArgumentException
- if request
is not a
HttpServletRequest
of if request
is not backed by SlingHttpServletRequestImpl
.public static org.apache.sling.api.SlingHttpServletResponse toSlingHttpServletResponse(javax.servlet.ServletResponse response)
response
- IllegalArgumentException
- if response
is not a
HttpServletResponse
of if
response
is not backed by
SlingHttpServletResponseImpl
.public static void service(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response) throws IOException, javax.servlet.ServletException
If the the servlet exists, the
SlingConstants.SLING_CURRENT_SERVLET_NAME
request attribute is set
to the name of that servlet and that servlet name is also set as the
currently active servlet
. After
the termination of the servlet (normal or throwing a Throwable) the
request attribute is reset to the previous value. The name of the
currently active servlet is only reset to the previous value if the
servlet terminates normally. In case of a Throwable, the active servlet
name is not reset and indicates which servlet caused the potential abort
of the request.
request
- The request object for the service methodresponse
- The response object for the service methodIOException
- May be thrown by the servlet's service methodjavax.servlet.ServletException
- May be thrown by the servlet's service methodpublic ContentData setContent(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.request.RequestPathInfo requestPathInfo)
public void resetContent(ContentData data)
public ContentData getContentData()
public org.apache.sling.api.resource.ResourceResolver getResourceResolver()
public org.apache.sling.api.request.RequestProgressTracker getRequestProgressTracker()
public int getPeakRecusionDepth()
public int getServletCallCount()
public long getElapsedTimeMsec()
public String setActiveServletName(String servletName)
public String getActiveServletName()
null
at the end of request processing, more precisly in
the case of an uncaught Throwable
at the end of request
processing, this is the name of the servlet causing the uncaught
Throwable
.public javax.servlet.ServletInputStream getInputStream() throws IOException
IOException
public BufferedReader getReader() throws UnsupportedEncodingException, IOException
public ParameterSupport getParameterSupport()
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.