public interface AsyncContext
ServletRequest.startAsync()
or
ServletRequest.startAsync(javax.servlet.ServletRequest,javax.servlet.ServletResponse)
.
Subsequent call to these methods return the same context instance.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ASYNC_CONTEXT_PATH
Name of the attribute for the context path.
|
static java.lang.String |
ASYNC_PATH_INFO
Name of the attribute for the path info.
|
static java.lang.String |
ASYNC_QUERY_STRING
Name of the attribute for the query string.
|
static java.lang.String |
ASYNC_REQUEST_URI
Name of the attribute for the request URI.
|
static java.lang.String |
ASYNC_SERVLET_PATH
Name of the attribute for the servlet path.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(AsyncListener listener)
Adds a listener to receive
AsyncEvent s for this context. |
void |
addListener(AsyncListener listener,
ServletRequest request,
ServletResponse response)
Adds a listener to receive
AsyncEvent s for this context. |
void |
complete()
Completes this asynchronous operation.
|
<T extends AsyncListener> |
createListener(java.lang.Class<T> t)
Instantiates an
AsyncListener from the given class. |
void |
dispatch()
Dispatches the request/response pair to the servlet container.
|
void |
dispatch(ServletContext context,
java.lang.String path)
Dispatches the request/response pair to the specified path and
context.
|
void |
dispatch(java.lang.String path)
Dispatches the request/response pair to the specified path.
|
ServletRequest |
getRequest()
Returns the original request.
|
ServletResponse |
getResponse()
Returns the original response.
|
long |
getTimeout()
Returns the timeout in milliseconds for this context.
|
boolean |
hasOriginalRequestAndResponse()
Indicates whether this context was initialized with the original
request/response pair.
|
void |
setTimeout(long timeout)
Sets the timeout in milliseconds for this context.
|
void |
start(java.lang.Runnable runnable)
Requests the servlet container to execute the specified runnable.
|
static final java.lang.String ASYNC_REQUEST_URI
static final java.lang.String ASYNC_CONTEXT_PATH
static final java.lang.String ASYNC_PATH_INFO
static final java.lang.String ASYNC_SERVLET_PATH
static final java.lang.String ASYNC_QUERY_STRING
ServletRequest getRequest()
ServletResponse getResponse()
boolean hasOriginalRequestAndResponse()
void dispatch()
ServletRequest.startAsync(javax.servlet.ServletRequest,javax.servlet.ServletResponse)
was called with a HttpServletRequest
, then
the URI for dispatch will be its request-URI, otherwise the URI will
be that of the request when it was last dispatched.
The dispatcher type of the request is
DispatcherType.ASYNC
.
This method returns immediately.java.lang.IllegalStateException
- if complete()
was called,
or a dispatch method was called but the startAsync method was not
calledServletRequest.getDispatcherType()
void dispatch(java.lang.String path)
DispatcherType.ASYNC
.
This method returns immediately.path
- the dispatch target within the servlet context of this
async contextjava.lang.IllegalStateException
- if complete()
was called,
or a dispatch method was called but the startAsync method was not
calledServletRequest.getDispatcherType()
void dispatch(ServletContext context, java.lang.String path)
DispatcherType.ASYNC
.
This method returns immediately.path
- the dispatch target within the specified servlet contextcontext
- the servlet contextjava.lang.IllegalStateException
- if complete()
was called,
or a dispatch method was called but the startAsync method was not
calledServletRequest.getDispatcherType()
void complete()
void start(java.lang.Runnable runnable)
void addListener(AsyncListener listener)
AsyncEvent
s for this context.void addListener(AsyncListener listener, ServletRequest request, ServletResponse response)
AsyncEvent
s for this context.
The specified request and response will be passed in the event.<T extends AsyncListener> T createListener(java.lang.Class<T> t) throws ServletException
AsyncListener
from the given class.ServletException
void setTimeout(long timeout)
long getTimeout()