类 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
- 所有已实现的接口:
EventListener
,AsyncListener
,AsyncWebRequest
,NativeWebRequest
,RequestAttributes
,WebRequest
public class StandardServletAsyncWebRequest extends ServletWebRequest implements AsyncWebRequest, AsyncListener
A Servlet 3.0 implementation ofAsyncWebRequest
.The servlet and all filters involved in an async request must have async support enabled using the Servlet API or by adding an
<async-supported>true</async-supported>
element to servlet and filter declarations inweb.xml
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.web.context.request.ServletRequestAttributes
DESTRUCTION_CALLBACK_NAME_PREFIX, immutableValueTypes
从类继承的字段 org.springframework.web.context.request.AbstractRequestAttributes
requestDestructionCallbacks
从接口继承的字段 org.springframework.web.context.request.RequestAttributes
REFERENCE_REQUEST, REFERENCE_SESSION, SCOPE_REQUEST, SCOPE_SESSION
构造器概要
构造器 构造器 说明 StandardServletAsyncWebRequest(HttpServletRequest request, HttpServletResponse response)
Create a new instance for the given request/response pair.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addCompletionHandler(Runnable runnable)
Add a handler to invoke when request processing completes.void
addErrorHandler(Consumer<Throwable> exceptionHandler)
Add a handler to invoke when an error occurred while concurrent handling of a request.void
addTimeoutHandler(Runnable timeoutHandler)
Add a handler to invoke when concurrent handling has timed out.void
dispatch()
Dispatch the request to the container in order to resume processing after concurrent execution in an application thread.boolean
isAsyncComplete()
Whether async request processing has completed.boolean
isAsyncStarted()
Whether the request is in async mode following a call toAsyncWebRequest.startAsync()
.void
onComplete(AsyncEvent event)
Notifies this AsyncListener that an asynchronous operation has been completed.void
onError(AsyncEvent event)
Notifies this AsyncListener that an asynchronous operation has failed to complete.void
onStartAsync(AsyncEvent event)
Notifies this AsyncListener that a new asynchronous cycle is being initiated via a call to one of theServletRequest.startAsync()
methods.void
onTimeout(AsyncEvent event)
Notifies this AsyncListener that an asynchronous operation has timed out.void
setTimeout(Long timeout)
In Servlet 3 async processing, the timeout period begins after the container processing thread has exited.void
startAsync()
Mark the start of asynchronous request processing so that when the main processing thread exits, the response remains open for further processing in another thread.从类继承的方法 org.springframework.web.context.request.ServletWebRequest
checkNotModified, checkNotModified, checkNotModified, getContextPath, getDescription, getHeader, getHeaderNames, getHeaderValues, getHttpMethod, getLocale, getNativeRequest, getNativeRequest, getNativeResponse, getNativeResponse, getParameter, getParameterMap, getParameterNames, getParameterValues, getRemoteUser, getUserPrincipal, isNotModified, isSecure, isUserInRole, toString
从类继承的方法 org.springframework.web.context.request.ServletRequestAttributes
getAttribute, getAttributeNames, getRequest, getResponse, getSession, getSessionId, getSessionMutex, isImmutableSessionAttribute, registerDestructionCallback, registerSessionDestructionCallback, removeAttribute, resolveReference, setAttribute, updateAccessedSessionAttributes
从类继承的方法 org.springframework.web.context.request.AbstractRequestAttributes
isRequestActive, registerRequestDestructionCallback, removeRequestDestructionCallback, requestCompleted
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.context.request.NativeWebRequest
getNativeRequest, getNativeRequest, getNativeResponse, getNativeResponse
从接口继承的方法 org.springframework.web.context.request.RequestAttributes
getAttribute, getAttributeNames, getSessionId, getSessionMutex, registerDestructionCallback, removeAttribute, resolveReference, setAttribute
从接口继承的方法 org.springframework.web.context.request.WebRequest
checkNotModified, checkNotModified, checkNotModified, getContextPath, getDescription, getHeader, getHeaderNames, getHeaderValues, getLocale, getParameter, getParameterMap, getParameterNames, getParameterValues, getRemoteUser, getUserPrincipal, isSecure, isUserInRole
构造器详细资料
StandardServletAsyncWebRequest
public StandardServletAsyncWebRequest(HttpServletRequest request, HttpServletResponse response)
Create a new instance for the given request/response pair.- 参数:
request
- current HTTP requestresponse
- current HTTP response
方法详细资料
setTimeout
public void setTimeout(Long timeout)
In Servlet 3 async processing, the timeout period begins after the container processing thread has exited.- 指定者:
setTimeout
在接口中AsyncWebRequest
- 参数:
timeout
- amount of time in milliseconds;null
means no timeout, i.e. rely on the default timeout of the container.
addTimeoutHandler
public void addTimeoutHandler(Runnable timeoutHandler)
从接口复制的说明:AsyncWebRequest
Add a handler to invoke when concurrent handling has timed out.- 指定者:
addTimeoutHandler
在接口中AsyncWebRequest
addErrorHandler
public void addErrorHandler(Consumer<Throwable> exceptionHandler)
从接口复制的说明:AsyncWebRequest
Add a handler to invoke when an error occurred while concurrent handling of a request.- 指定者:
addErrorHandler
在接口中AsyncWebRequest
addCompletionHandler
public void addCompletionHandler(Runnable runnable)
从接口复制的说明:AsyncWebRequest
Add a handler to invoke when request processing completes.- 指定者:
addCompletionHandler
在接口中AsyncWebRequest
isAsyncStarted
public boolean isAsyncStarted()
从接口复制的说明:AsyncWebRequest
Whether the request is in async mode following a call toAsyncWebRequest.startAsync()
. Returns "false" if asynchronous processing never started, has completed, or the request was dispatched for further processing.- 指定者:
isAsyncStarted
在接口中AsyncWebRequest
isAsyncComplete
public boolean isAsyncComplete()
Whether async request processing has completed.It is important to avoid use of request and response objects after async processing has completed. Servlet containers often re-use them.
- 指定者:
isAsyncComplete
在接口中AsyncWebRequest
startAsync
public void startAsync()
从接口复制的说明:AsyncWebRequest
Mark the start of asynchronous request processing so that when the main processing thread exits, the response remains open for further processing in another thread.- 指定者:
startAsync
在接口中AsyncWebRequest
dispatch
public void dispatch()
从接口复制的说明:AsyncWebRequest
Dispatch the request to the container in order to resume processing after concurrent execution in an application thread.- 指定者:
dispatch
在接口中AsyncWebRequest
onStartAsync
public void onStartAsync(AsyncEvent event) throws IOException
从接口复制的说明:javax.servlet.AsyncListener
Notifies this AsyncListener that a new asynchronous cycle is being initiated via a call to one of theServletRequest.startAsync()
methods.The
AsyncContext
corresponding to the asynchronous operation that is being reinitialized may be obtained by callinggetAsyncContext
on the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse)
, the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequest
andgetSuppliedResponse
, respectively, on the given event.This AsyncListener will not receive any events related to the new asynchronous cycle unless it registers itself (via a call to
AsyncContext.addListener(javax.servlet.AsyncListener)
) with the AsyncContext that is delivered as part of the given AsyncEvent.- 指定者:
onStartAsync
在接口中AsyncListener
- 参数:
event
- the AsyncEvent indicating that a new asynchronous cycle is being initiated- 抛出:
IOException
- if an I/O related error has occurred during the processing of the given AsyncEvent
onError
public void onError(AsyncEvent event) throws IOException
从接口复制的说明:javax.servlet.AsyncListener
Notifies this AsyncListener that an asynchronous operation has failed to complete.The
AsyncContext
corresponding to the asynchronous operation that failed to complete may be obtained by callinggetAsyncContext
on the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse)
, the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequest
andgetSuppliedResponse
, respectively, on the given event.- 指定者:
onError
在接口中AsyncListener
- 参数:
event
- the AsyncEvent indicating that an asynchronous operation has failed to complete- 抛出:
IOException
- if an I/O related error has occurred during the processing of the given AsyncEvent
onTimeout
public void onTimeout(AsyncEvent event) throws IOException
从接口复制的说明:javax.servlet.AsyncListener
Notifies this AsyncListener that an asynchronous operation has timed out.The
AsyncContext
corresponding to the asynchronous operation that has timed out may be obtained by callinggetAsyncContext
on the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse)
, the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequest
andgetSuppliedResponse
, respectively, on the given event.- 指定者:
onTimeout
在接口中AsyncListener
- 参数:
event
- the AsyncEvent indicating that an asynchronous operation has timed out- 抛出:
IOException
- if an I/O related error has occurred during the processing of the given AsyncEvent
onComplete
public void onComplete(AsyncEvent event) throws IOException
从接口复制的说明:javax.servlet.AsyncListener
Notifies this AsyncListener that an asynchronous operation has been completed.The
AsyncContext
corresponding to the asynchronous operation that has been completed may be obtained by callinggetAsyncContext
on the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse)
, the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequest
andgetSuppliedResponse
, respectively, on the given event.- 指定者:
onComplete
在接口中AsyncListener
- 参数:
event
- the AsyncEvent indicating that an asynchronous operation has been completed- 抛出:
IOException
- if an I/O related error has occurred during the processing of the given AsyncEvent