public class AsyncContextImpl extends Object implements AsyncContext, AsyncContextCallback
Modifier and Type | Field and Description |
---|---|
protected static StringManager |
sm |
ASYNC_CONTEXT_PATH, ASYNC_MAPPING, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH
Constructor and Description |
---|
AsyncContextImpl(Request request) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(AsyncListener listener)
Adds an event listener that will be called for different AsyncEvents fire
|
void |
addListener(AsyncListener listener,
ServletRequest servletRequest,
ServletResponse servletResponse)
Adds an event listener that will be called when different AsyncEvents fire
|
void |
complete()
Completes the async request processing and closes the response stream
|
<T extends AsyncListener> |
createListener(Class<T> clazz)
Creates and returns an AsyncListener object
|
void |
decrementInProgressAsyncCount()
Used to notify the Context that async processing has ended.
|
void |
dispatch() |
void |
dispatch(ServletContext servletContext,
String path) |
void |
dispatch(String path) |
protected void |
doInternalDispatch() |
void |
fireOnComplete() |
ServletRequest |
getRequest() |
ServletResponse |
getResponse() |
long |
getTimeout()
Get the current timeout.
|
boolean |
hasOriginalRequestAndResponse() |
void |
incrementInProgressAsyncCount()
Used to notify the Context that async processing has started.
|
boolean |
isAvailable()
Reports if the web application associated with this async request is
available.
|
boolean |
isStarted() |
void |
recycle() |
void |
setErrorState(Throwable t,
boolean fireOnError) |
void |
setStarted(Context context,
ServletRequest request,
ServletResponse response,
boolean originalRequestResponse) |
void |
setTimeout(long timeout)
Set the timeout.
|
void |
start(Runnable run)
Starts a new thread to process the asynchronous request
|
boolean |
timeout() |
protected static final StringManager sm
public AsyncContextImpl(Request request)
public void complete()
javax.servlet.AsyncContext
complete
in interface AsyncContext
public void fireOnComplete()
fireOnComplete
in interface AsyncContextCallback
public boolean timeout()
public void dispatch()
dispatch
in interface AsyncContext
public void dispatch(String path)
dispatch
in interface AsyncContext
path
- The path to which the request/response should be dispatched
relative to the ServletContext
from which this async
request was started.public void dispatch(ServletContext servletContext, String path)
dispatch
in interface AsyncContext
servletContext
- The ServletContext
to which the request/response
should be dispatched.path
- The path to which the request/response should be dispatched
relative to the specified ServletContext
.public ServletRequest getRequest()
getRequest
in interface AsyncContext
public ServletResponse getResponse()
getResponse
in interface AsyncContext
public void start(Runnable run)
javax.servlet.AsyncContext
start
in interface AsyncContext
run
- a Runnable that the new thread will runpublic void addListener(AsyncListener listener)
javax.servlet.AsyncContext
addListener
in interface AsyncContext
listener
- an AsyncListener that will be called with AsyncEvent objectspublic void addListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse)
javax.servlet.AsyncContext
addListener
in interface AsyncContext
listener
- an AsyncListener that will be called with AsyncEvent objectsservletRequest
- the ServletRequest that will be passed with the AsyncEventservletResponse
- the ServletResponse that will be passed with the AsyncEventpublic <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException
javax.servlet.AsyncContext
createListener
in interface AsyncContext
T
- The type to create that extends AsyncListenerclazz
- The class to instantiate to create the listenerServletException
- if the listener cannot be createdpublic void recycle()
public boolean isStarted()
public void setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse)
public boolean hasOriginalRequestAndResponse()
hasOriginalRequestAndResponse
in interface AsyncContext
protected void doInternalDispatch() throws ServletException, IOException
ServletException
IOException
public long getTimeout()
javax.servlet.AsyncContext
getTimeout
in interface AsyncContext
public void setTimeout(long timeout)
javax.servlet.AsyncContext
setTimeout
in interface AsyncContext
timeout
- The timeout in milliseconds. 0 or less indicates no
timeout.public boolean isAvailable()
AsyncContextCallback
isAvailable
in interface AsyncContextCallback
true
if the associated web application is available,
otherwise false
public void setErrorState(Throwable t, boolean fireOnError)
public void incrementInProgressAsyncCount()
AsyncContextCallback
AsyncStateMachine
transitions from DISPATCHED to any other state.incrementInProgressAsyncCount
in interface AsyncContextCallback
public void decrementInProgressAsyncCount()
AsyncContextCallback
AsyncStateMachine
transitions to DISPATCHED from any other state.decrementInProgressAsyncCount
in interface AsyncContextCallback
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.