org.springframework.web.context.request.async
Class StandardServletAsyncWebRequest
java.lang.Object
org.springframework.web.context.request.AbstractRequestAttributes
org.springframework.web.context.request.ServletRequestAttributes
org.springframework.web.context.request.ServletWebRequest
org.springframework.web.context.request.async.StandardServletAsyncWebRequest
- All Implemented Interfaces:
- java.util.EventListener, javax.servlet.AsyncListener, AsyncWebRequest, NativeWebRequest, RequestAttributes, WebRequest
public class StandardServletAsyncWebRequest
- extends ServletWebRequest
- implements AsyncWebRequest, javax.servlet.AsyncListener
A Servlet 3.0 implementation of AsyncWebRequest
.
The servlet and all filters involved in an async request must have async
support enabled using the Servlet API or by adding an
<async-support>true</async-support>
element to servlet and filter
declarations in web.xml
- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Method Summary |
void |
complete()
Complete async request processing making a best effort but without any
effect if async request processing has already completed for any reason
including a timeout. |
boolean |
isAsyncCompleted()
Whether async processing has completed either normally via calls to
AsyncWebRequest.complete() or for other reasons such as a timeout likely
detected in a separate thread during async request processing. |
boolean |
isAsyncStarted()
Whether async processing is in progress and has not yet completed. |
void |
onComplete(javax.servlet.AsyncEvent event)
|
void |
onError(javax.servlet.AsyncEvent event)
|
void |
onStartAsync(javax.servlet.AsyncEvent event)
|
void |
onTimeout(javax.servlet.AsyncEvent event)
|
void |
sendError(HttpStatus status,
java.lang.String message)
Send an error to the client making a best effort to do so but without any
effect if async request processing has already completed, for example due
to a timeout. |
void |
setTimeout(java.lang.Long timeout)
Set the timeout for asynchronous request processing in milliseconds. |
void |
setTimeoutHandler(java.lang.Runnable timeoutHandler)
Invoked on a timeout to complete the response instead of the default
behavior that sets the status to 503 (SERVICE_UNAVAILABLE). |
void |
startAsync()
Mark the start of async request processing for example ensuring the
request remains open in order to be completed in a separate thread. |
Methods inherited from class org.springframework.web.context.request.ServletWebRequest |
checkNotModified, checkNotModified, getContextPath, getDescription, getHeader, getHeaderNames, getHeaderValues, getLocale, getNativeRequest, getNativeRequest, getNativeResponse, getNativeResponse, getParameter, getParameterMap, getParameterNames, getParameterValues, getRemoteUser, getResponse, getUserPrincipal, isNotModified, isSecure, isUserInRole, toString |
Methods inherited from class org.springframework.web.context.request.ServletRequestAttributes |
getAttribute, getAttributeNames, getRequest, getSession, getSessionId, getSessionMutex, registerDestructionCallback, registerSessionDestructionCallback, removeAttribute, resolveReference, setAttribute, updateAccessedSessionAttributes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.web.context.request.WebRequest |
checkNotModified, checkNotModified, getContextPath, getDescription, getHeader, getHeaderNames, getHeaderValues, getLocale, getParameter, getParameterMap, getParameterNames, getParameterValues, getRemoteUser, getUserPrincipal, isSecure, isUserInRole |
StandardServletAsyncWebRequest
public StandardServletAsyncWebRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
setTimeout
public void setTimeout(java.lang.Long timeout)
- Description copied from interface:
AsyncWebRequest
- Set the timeout for asynchronous request processing in milliseconds.
In Servlet 3 async request processing, the timeout begins when the
main processing thread has exited.
- Specified by:
setTimeout
in interface AsyncWebRequest
isAsyncStarted
public boolean isAsyncStarted()
- Description copied from interface:
AsyncWebRequest
- Whether async processing is in progress and has not yet completed.
- Specified by:
isAsyncStarted
in interface AsyncWebRequest
isAsyncCompleted
public boolean isAsyncCompleted()
- Description copied from interface:
AsyncWebRequest
- Whether async processing has completed either normally via calls to
AsyncWebRequest.complete()
or for other reasons such as a timeout likely
detected in a separate thread during async request processing.
- Specified by:
isAsyncCompleted
in interface AsyncWebRequest
setTimeoutHandler
public void setTimeoutHandler(java.lang.Runnable timeoutHandler)
- Description copied from interface:
AsyncWebRequest
- Invoked on a timeout to complete the response instead of the default
behavior that sets the status to 503 (SERVICE_UNAVAILABLE).
- Specified by:
setTimeoutHandler
in interface AsyncWebRequest
startAsync
public void startAsync()
- Description copied from interface:
AsyncWebRequest
- Mark the start of async request processing for example ensuring the
request remains open in order to be completed in a separate thread.
- Specified by:
startAsync
in interface AsyncWebRequest
complete
public void complete()
- Description copied from interface:
AsyncWebRequest
- Complete async request processing making a best effort but without any
effect if async request processing has already completed for any reason
including a timeout.
- Specified by:
complete
in interface AsyncWebRequest
sendError
public void sendError(HttpStatus status,
java.lang.String message)
- Description copied from interface:
AsyncWebRequest
- Send an error to the client making a best effort to do so but without any
effect if async request processing has already completed, for example due
to a timeout.
- Specified by:
sendError
in interface AsyncWebRequest
onTimeout
public void onTimeout(javax.servlet.AsyncEvent event)
throws java.io.IOException
- Specified by:
onTimeout
in interface javax.servlet.AsyncListener
- Throws:
java.io.IOException
onError
public void onError(javax.servlet.AsyncEvent event)
throws java.io.IOException
- Specified by:
onError
in interface javax.servlet.AsyncListener
- Throws:
java.io.IOException
onStartAsync
public void onStartAsync(javax.servlet.AsyncEvent event)
throws java.io.IOException
- Specified by:
onStartAsync
in interface javax.servlet.AsyncListener
- Throws:
java.io.IOException
onComplete
public void onComplete(javax.servlet.AsyncEvent event)
throws java.io.IOException
- Specified by:
onComplete
in interface javax.servlet.AsyncListener
- Throws:
java.io.IOException