Top Inners Fields Constructors Methods
org.apache.catalina.core

public Class AsyncContextImpl

extends Object
implements AsyncContext, AsyncContextCallback
Class Inheritance
All Implemented Interfaces
org.apache.coyote.AsyncContextCallback, jakarta.servlet.AsyncContext
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.util.ArrayList, .List, java.util.concurrent.atomic.AtomicBoolean, javax.naming.NamingException, jakarta.servlet.AsyncContext, .AsyncEvent, .AsyncListener, .RequestDispatcher, .ServletContext, .ServletException, .ServletRequest, .ServletResponse, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.apache.catalina.AsyncDispatcher, .Context, .Globals, .Host, .Valve, org.apache.catalina.connector.Request, org.apache.coyote.ActionCode, .AsyncContextCallback, .RequestInfo, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.UDecoder, org.apache.tomcat.util.res.StringManager

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final Object
private Context
private volatile Runnable
private AsyncEvent
private final AtomicBoolean
private final AtomicBoolean
private boolean
private final List<AsyncListenerWrapper>
private static final Log
private volatile Request
private volatile ServletRequest
private volatile ServletResponse
protected static final StringManager
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addListener(AsyncListener
an AsyncListener that will be called with AsyncEvent objects
listener
)

Implements jakarta.servlet.AsyncContext.addListener.

Adds an event listener that will be called for different AsyncEvents fire

public void
addListener(AsyncListener
an AsyncListener that will be called with AsyncEvent objects
listener
,
ServletRequest
the ServletRequest that will be passed with the AsyncEvent
servletRequest
,
ServletResponse
the ServletResponse that will be passed with the AsyncEvent
servletResponse
)

Implements jakarta.servlet.AsyncContext.addListener.

Adds an event listener that will be called when different AsyncEvents fire

private void
private void
public void
complete()

Implements jakarta.servlet.AsyncContext.complete.

Completes the async request processing and closes the response stream

public <T extends AsyncListener> T
createListener(Class<T>
The class to instantiate to create the listener
clazz
)

Implements jakarta.servlet.AsyncContext.createListener.

Creates and returns an AsyncListener object

public void
decrementInProgressAsyncCount()

Implements org.apache.coyote.AsyncContextCallback.decrementInProgressAsyncCount.

Used to notify the Context that async processing has ended.

public void
public void
dispatch(String
The path to which the request/response should be dispatched relative to the ServletContext from which this async request was started.
path
)

Implements jakarta.servlet.AsyncContext.dispatch.

public void
dispatch(ServletContext
The ServletContext to which the request/response should be dispatched.
servletContext
,
String
The path to which the request/response should be dispatched relative to the specified ServletContext.
path
)

Implements jakarta.servlet.AsyncContext.dispatch.

protected void
public void
public ServletRequest
public ServletResponse
public long
getTimeout()

Implements jakarta.servlet.AsyncContext.getTimeout.

Get the current timeout.

public boolean
public void
incrementInProgressAsyncCount()

Implements org.apache.coyote.AsyncContextCallback.incrementInProgressAsyncCount.

Used to notify the Context that async processing has started.

public boolean
isAvailable()

Implements org.apache.coyote.AsyncContextCallback.isAvailable.

Reports if the web application associated with this async request is available.

public boolean
private void
logDebug(String method)

public void
public void
setErrorState(Throwable t, boolean fireOnError)

public void
setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse)

public void
setTimeout(long
The timeout in milliseconds. 0 or less indicates no timeout.
timeout
)

Implements jakarta.servlet.AsyncContext.setTimeout.

Set the timeout.

public void
start(final Runnable
a Runnable that the new thread will run
run
)

Implements jakarta.servlet.AsyncContext.start.

Starts a new thread to process the asynchronous request

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asyncContextLockback to summary
private final Object asyncContextLock
contextback to summary
private Context context
dispatchback to summary
private volatile Runnable dispatch
eventback to summary
private AsyncEvent event
hasErrorProcessingStartedback to summary
private final AtomicBoolean hasErrorProcessingStarted
hasOnErrorReturnedback to summary
private final AtomicBoolean hasOnErrorReturned
hasOriginalRequestAndResponseback to summary
private boolean hasOriginalRequestAndResponse
listenersback to summary
private final List<AsyncListenerWrapper> listeners
logback to summary
private static final Log log
requestback to summary
private volatile Request request
servletRequestback to summary
private volatile ServletRequest servletRequest
servletResponseback to summary
private volatile ServletResponse servletResponse
smback to summary
protected static final StringManager sm
timeoutback to summary
private long timeout

Constructor Detail

AsyncContextImplback to summary
public AsyncContextImpl(Request request)

Method Detail

addListenerback to summary
public void addListener(AsyncListener listener)

Implements jakarta.servlet.AsyncContext.addListener.

Doc from jakarta.servlet.AsyncContext.addListener.

Adds an event listener that will be called for different AsyncEvents fire

Parameters
listener:AsyncListener

an AsyncListener that will be called with AsyncEvent objects

Annotations
@Override
addListenerback to summary
public void addListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse)

Implements jakarta.servlet.AsyncContext.addListener.

Doc from jakarta.servlet.AsyncContext.addListener.

Adds an event listener that will be called when different AsyncEvents fire

Parameters
listener:AsyncListener

an AsyncListener that will be called with AsyncEvent objects

servletRequest:ServletRequest

the ServletRequest that will be passed with the AsyncEvent

servletResponse:ServletResponse

the ServletResponse that will be passed with the AsyncEvent

Annotations
@Override
checkback to summary
private void check()
clearServletRequestResponseback to summary
private void clearServletRequestResponse()
completeback to summary
public void complete()

Implements jakarta.servlet.AsyncContext.complete.

Doc from jakarta.servlet.AsyncContext.complete.

Completes the async request processing and closes the response stream

Annotations
@Override
createListenerback to summary
public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException

Implements jakarta.servlet.AsyncContext.createListener.

Doc from jakarta.servlet.AsyncContext.createListener.

Creates and returns an AsyncListener object

Parameters
<T>
The type to create that extends AsyncListener
clazz:Class<T>

The class to instantiate to create the listener

Returns:T

the newly created AsyncListener object

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
ServletException:
if the listener cannot be created
decrementInProgressAsyncCountback to summary
public void decrementInProgressAsyncCount()

Implements org.apache.coyote.AsyncContextCallback.decrementInProgressAsyncCount.

Doc from org.apache.coyote.AsyncContextCallback.decrementInProgressAsyncCount.

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 the AsyncStateMachine transitions to DISPATCHED from any other state.

Annotations
@Override
dispatchback to summary
public void dispatch()

Implements jakarta.servlet.AsyncContext.dispatch.

Annotations
@Override
dispatchback to summary
public void dispatch(String path)

Implements jakarta.servlet.AsyncContext.dispatch.

Parameters
path:String

Doc from jakarta.servlet.AsyncContext.dispatch.

The path to which the request/response should be dispatched relative to the ServletContext from which this async request was started.

Annotations
@Override
dispatchback to summary
public void dispatch(ServletContext servletContext, String path)

Implements jakarta.servlet.AsyncContext.dispatch.

Parameters
servletContext:ServletContext

Doc from jakarta.servlet.AsyncContext.dispatch.

The ServletContext to which the request/response should be dispatched.

path:String

Doc from jakarta.servlet.AsyncContext.dispatch.

The path to which the request/response should be dispatched relative to the specified ServletContext.

Annotations
@Override
doInternalDispatchback to summary
protected void doInternalDispatch() throws ServletException, IOException
fireOnCompleteback to summary
public void fireOnComplete()

Implements org.apache.coyote.AsyncContextCallback.fireOnComplete.

Annotations
@Override
getRequestback to summary
public ServletRequest getRequest()

Implements jakarta.servlet.AsyncContext.getRequest.

Returns:ServletRequest

Doc from jakarta.servlet.AsyncContext.getRequest.

a reference to the ServletRequest object

Annotations
@Override
getResponseback to summary
public ServletResponse getResponse()

Implements jakarta.servlet.AsyncContext.getResponse.

Returns:ServletResponse

Doc from jakarta.servlet.AsyncContext.getResponse.

a reference to the ServletResponse object

Annotations
@Override
getTimeoutback to summary
public long getTimeout()

Implements jakarta.servlet.AsyncContext.getTimeout.

Doc from jakarta.servlet.AsyncContext.getTimeout.

Get the current timeout.

Returns:long

The timeout in milliseconds. 0 or less indicates no timeout.

Annotations
@Override
hasOriginalRequestAndResponseback to summary
public boolean hasOriginalRequestAndResponse()

Implements jakarta.servlet.AsyncContext.hasOriginalRequestAndResponse.

Returns:boolean

Doc from jakarta.servlet.AsyncContext.hasOriginalRequestAndResponse.

true if the Request and Response are the original ones

Annotations
@Override
incrementInProgressAsyncCountback to summary
public void incrementInProgressAsyncCount()

Implements org.apache.coyote.AsyncContextCallback.incrementInProgressAsyncCount.

Doc from org.apache.coyote.AsyncContextCallback.incrementInProgressAsyncCount.

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 the AsyncStateMachine transitions from DISPATCHED to any other state.

Annotations
@Override
isAvailableback to summary
public boolean isAvailable()

Implements org.apache.coyote.AsyncContextCallback.isAvailable.

Doc from org.apache.coyote.AsyncContextCallback.isAvailable.

Reports if the web application associated with this async request is available.

Returns:boolean

true if the associated web application is available, otherwise false

Annotations
@Override
isStartedback to summary
public boolean isStarted()
logDebugback to summary
private void logDebug(String method)
recycleback to summary
public void recycle()
setErrorStateback to summary
public void setErrorState(Throwable t, boolean fireOnError)
setStartedback to summary
public void setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse)
setTimeoutback to summary
public void setTimeout(long timeout)

Implements jakarta.servlet.AsyncContext.setTimeout.

Doc from jakarta.servlet.AsyncContext.setTimeout.

Set the timeout.

Parameters
timeout:long

The timeout in milliseconds. 0 or less indicates no timeout.

Annotations
@Override
startback to summary
public void start(final Runnable run)

Implements jakarta.servlet.AsyncContext.start.

Doc from jakarta.servlet.AsyncContext.start.

Starts a new thread to process the asynchronous request

Parameters
run:Runnable

a Runnable that the new thread will run

Annotations
@Override
timeoutback to summary
public boolean timeout()
org.apache.catalina.core back to summary

private Class AsyncContextImpl.AsyncRunnable

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final AsyncDispatcher
private final Request
private final ServletRequest
private final ServletResponse

Constructor Summary

AccessConstructor and Description
pack-priv
AsyncRunnable(Request request, AsyncDispatcher applicationDispatcher, ServletRequest servletRequest, ServletResponse servletResponse)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationDispatcherback to summary
private final AsyncDispatcher applicationDispatcher
requestback to summary
private final Request request
servletRequestback to summary
private final ServletRequest servletRequest
servletResponseback to summary
private final ServletResponse servletResponse

Constructor Detail

AsyncRunnableback to summary
pack-priv AsyncRunnable(Request request, AsyncDispatcher applicationDispatcher, ServletRequest servletRequest, ServletResponse servletResponse)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
org.apache.catalina.core back to summary

private Class AsyncContextImpl.DebugException

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

DebugExceptionback to summary
private DebugException()
org.apache.catalina.core back to summary

private Class AsyncContextImpl.RunnableWrapper

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final Context
private final Request
private final Runnable

Constructor Summary

AccessConstructor and Description
pack-priv
RunnableWrapper(Runnable wrapped, Context ctxt, Request coyoteRequest)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final Context context
coyoteRequestback to summary
private final Request coyoteRequest
wrappedback to summary
private final Runnable wrapped

Constructor Detail

RunnableWrapperback to summary
pack-priv RunnableWrapper(Runnable wrapped, Context ctxt, Request coyoteRequest)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@SuppressWarnings:deprecation
@Override