Package cloud.piranha.webapp.impl
Class DefaultAsyncContext
- java.lang.Object
-
- cloud.piranha.webapp.impl.DefaultAsyncContext
-
- All Implemented Interfaces:
AsyncContext
public class DefaultAsyncContext extends Object implements AsyncContext
The default AsyncContext.- Author:
- Manfred Riem ([email protected])
-
-
Field Summary
-
Fields inherited from interface javax.servlet.AsyncContext
ASYNC_CONTEXT_PATH, ASYNC_MAPPING, ASYNC_PATH_INFO, ASYNC_QUERY_STRING, ASYNC_REQUEST_URI, ASYNC_SERVLET_PATH
-
-
Constructor Summary
Constructors Constructor Description DefaultAsyncContext(ServletRequest request, ServletResponse response)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(AsyncListener listener)
Add the listener.void
addListener(AsyncListener listener, ServletRequest request, ServletResponse response)
Add the listener.void
complete()
Complete the async context.<T extends AsyncListener>
TcreateListener(Class<T> type)
Create the listener.void
dispatch()
Dispatch the request.void
dispatch(String path)
Dispatch the request.void
dispatch(ServletContext servletContext, String path)
Dispatch.ServletRequest
getRequest()
Get the request.ServletResponse
getResponse()
Get the response.long
getTimeout()
Get the timeout.boolean
hasOriginalRequestAndResponse()
Do we have the original request and response?void
setTimeout(long timeout)
Set the timeout.void
start(Runnable runnable)
Start the thread.
-
-
-
Constructor Detail
-
DefaultAsyncContext
public DefaultAsyncContext(ServletRequest request, ServletResponse response)
Constructor.- Parameters:
request
- the servlet request.response
- the servlet response.
-
-
Method Detail
-
addListener
public void addListener(AsyncListener listener)
Add the listener.- Specified by:
addListener
in interfaceAsyncContext
- Parameters:
listener
- the listener.- See Also:
AsyncContext.addListener(javax.servlet.AsyncListener)
-
addListener
public void addListener(AsyncListener listener, ServletRequest request, ServletResponse response)
Add the listener.- Specified by:
addListener
in interfaceAsyncContext
- Parameters:
listener
- the listener.request
- the servlet request.response
- the servlet response.
-
complete
public void complete()
Complete the async context.- Specified by:
complete
in interfaceAsyncContext
-
createListener
public <T extends AsyncListener> T createListener(Class<T> type) throws ServletException
Create the listener.- Specified by:
createListener
in interfaceAsyncContext
- Type Parameters:
T
- the class.- Parameters:
type
- the type.- Returns:
- the listener.
- Throws:
ServletException
- when a Servlet error occurs.
-
dispatch
public void dispatch()
Description copied from interface:AsyncContext
Dispatch the request.- Specified by:
dispatch
in interfaceAsyncContext
- See Also:
AsyncContext.dispatch()
-
dispatch
public void dispatch(String path)
Description copied from interface:AsyncContext
Dispatch the request.- Specified by:
dispatch
in interfaceAsyncContext
- Parameters:
path
- the path.- See Also:
AsyncContext.dispatch(java.lang.String)
-
dispatch
public void dispatch(ServletContext servletContext, String path)
Dispatch.- Specified by:
dispatch
in interfaceAsyncContext
- Parameters:
servletContext
- the servlet context.path
- the path.
-
getRequest
public ServletRequest getRequest()
Get the request.- Specified by:
getRequest
in interfaceAsyncContext
- Returns:
- the request.
- See Also:
AsyncContext.getRequest()
-
getResponse
public ServletResponse getResponse()
Get the response.- Specified by:
getResponse
in interfaceAsyncContext
- Returns:
- the response.
- See Also:
AsyncContext.getResponse()
-
getTimeout
public long getTimeout()
Get the timeout.- Specified by:
getTimeout
in interfaceAsyncContext
- Returns:
- the timeout.
- See Also:
AsyncContext.getTimeout()
-
hasOriginalRequestAndResponse
public boolean hasOriginalRequestAndResponse()
Do we have the original request and response?- Specified by:
hasOriginalRequestAndResponse
in interfaceAsyncContext
- Returns:
- true if we do, false otherwise.
-
setTimeout
public void setTimeout(long timeout)
Set the timeout.- Specified by:
setTimeout
in interfaceAsyncContext
- Parameters:
timeout
- the timeout.
-
start
public void start(Runnable runnable)
Start the thread.- Specified by:
start
in interfaceAsyncContext
- Parameters:
runnable
- the runnable.
-
-