Class AsyncContextImpl
java.lang.Object
org.apache.catalina.core.AsyncContextImpl
- All Implemented Interfaces:
AsyncContext
,AsyncContextCallback
-
Field Summary
Fields inherited from interface jakarta.servlet.AsyncContext
ASYNC_CONTEXT_PATH, ASYNC_MAPPING, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(AsyncListener listener) Adds an event listener that will be called for different AsyncEvents firevoid
addListener
(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) Adds an event listener that will be called when different AsyncEvents firevoid
complete()
Completes the async request processing and closes the response stream<T extends AsyncListener>
TcreateListener
(Class<T> clazz) Creates and returns an AsyncListener objectvoid
Used to notify the Context that async processing has ended.void
dispatch()
void
dispatch
(ServletContext servletContext, String path) void
protected void
void
long
Get the current timeout.boolean
void
Used to notify the Context that async processing has started.boolean
Reports if the web application associated with this async request is available.boolean
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
Starts a new thread to process the asynchronous requestboolean
timeout()
-
Field Details
-
sm
-
-
Constructor Details
-
AsyncContextImpl
-
-
Method Details
-
complete
public void complete()Description copied from interface:jakarta.servlet.AsyncContext
Completes the async request processing and closes the response stream- Specified by:
complete
in interfaceAsyncContext
-
fireOnComplete
public void fireOnComplete()- Specified by:
fireOnComplete
in interfaceAsyncContextCallback
-
timeout
public boolean timeout() -
dispatch
public void dispatch()- Specified by:
dispatch
in interfaceAsyncContext
-
dispatch
- Specified by:
dispatch
in interfaceAsyncContext
- Parameters:
path
- The path to which the request/response should be dispatched relative to theServletContext
from which this async request was started.
-
dispatch
- Specified by:
dispatch
in interfaceAsyncContext
- Parameters:
servletContext
- TheServletContext
to which the request/response should be dispatched.path
- The path to which the request/response should be dispatched relative to the specifiedServletContext
.
-
getRequest
- Specified by:
getRequest
in interfaceAsyncContext
- Returns:
- a reference to the ServletRequest object
-
getResponse
- Specified by:
getResponse
in interfaceAsyncContext
- Returns:
- a reference to the ServletResponse object
-
start
Description copied from interface:jakarta.servlet.AsyncContext
Starts a new thread to process the asynchronous request- Specified by:
start
in interfaceAsyncContext
- Parameters:
run
- a Runnable that the new thread will run
-
addListener
Description copied from interface:jakarta.servlet.AsyncContext
Adds an event listener that will be called for different AsyncEvents fire- Specified by:
addListener
in interfaceAsyncContext
- Parameters:
listener
- an AsyncListener that will be called with AsyncEvent objects
-
addListener
public void addListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) Description copied from interface:jakarta.servlet.AsyncContext
Adds an event listener that will be called when different AsyncEvents fire- Specified by:
addListener
in interfaceAsyncContext
- Parameters:
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 AsyncEvent
-
createListener
Description copied from interface:jakarta.servlet.AsyncContext
Creates and returns an AsyncListener object- Specified by:
createListener
in interfaceAsyncContext
- Type Parameters:
T
- The type to create that extends AsyncListener- Parameters:
clazz
- The class to instantiate to create the listener- Returns:
- the newly created AsyncListener object
- Throws:
ServletException
- if the listener cannot be created
-
recycle
public void recycle() -
isStarted
public boolean isStarted() -
setStarted
public void setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse) -
hasOriginalRequestAndResponse
public boolean hasOriginalRequestAndResponse()- Specified by:
hasOriginalRequestAndResponse
in interfaceAsyncContext
- Returns:
- true if the Request and Response are the original ones
-
doInternalDispatch
- Throws:
ServletException
IOException
-
getTimeout
public long getTimeout()Description copied from interface:jakarta.servlet.AsyncContext
Get the current timeout.- Specified by:
getTimeout
in interfaceAsyncContext
- Returns:
- The timeout in milliseconds. 0 or less indicates no timeout.
-
setTimeout
public void setTimeout(long timeout) Description copied from interface:jakarta.servlet.AsyncContext
Set the timeout.- Specified by:
setTimeout
in interfaceAsyncContext
- Parameters:
timeout
- The timeout in milliseconds. 0 or less indicates no timeout.
-
isAvailable
public boolean isAvailable()Description copied from interface:AsyncContextCallback
Reports if the web application associated with this async request is available.- Specified by:
isAvailable
in interfaceAsyncContextCallback
- Returns:
true
if the associated web application is available, otherwisefalse
-
setErrorState
-
incrementInProgressAsyncCount
public void incrementInProgressAsyncCount()Description copied from interface:AsyncContextCallback
Used to notify the Context that async processing has started. Specifically, for the counting of in-progress async requests to work correctly, this must be called exactly once every time theAsyncStateMachine
transitions from DISPATCHED to any other state.- Specified by:
incrementInProgressAsyncCount
in interfaceAsyncContextCallback
-
decrementInProgressAsyncCount
public void decrementInProgressAsyncCount()Description copied from interface:AsyncContextCallback
Used to notify the Context that async processing has ended. Specifically, for the counting of in-progress async requests to work correctly, this must be called exactly once every time theAsyncStateMachine
transitions to DISPATCHED from any other state.- Specified by:
decrementInProgressAsyncCount
in interfaceAsyncContextCallback
-