Class ServletServerHttpAsyncRequestControl
- java.lang.Object
- org.springframework.http.server.ServletServerHttpAsyncRequestControl
- All Implemented Interfaces:
EventListener,AsyncListener,ServerHttpAsyncRequestControl
public class ServletServerHttpAsyncRequestControl extends Object implements ServerHttpAsyncRequestControl, AsyncListener
AServerHttpAsyncRequestControlto use on Servlet containers (Servlet 3.0+).- Since:
- 4.0
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description ServletServerHttpAsyncRequestControl(ServletServerHttpRequest request, ServletServerHttpResponse response)Constructor accepting a request and response pair that are expected to be of typeServletServerHttpRequestandServletServerHttpResponserespectively.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Mark asynchronous request processing as completed.booleanisCompleted()Return whether asynchronous request processing has been completed.booleanisStarted()Return whether asynchronous request processing has been started.voidonComplete(AsyncEvent event)Notifies this AsyncListener that an asynchronous operation has been completed.voidonError(AsyncEvent event)Notifies this AsyncListener that an asynchronous operation has failed to complete.voidonStartAsync(AsyncEvent event)Notifies this AsyncListener that a new asynchronous cycle is being initiated via a call to one of theServletRequest.startAsync()methods.voidonTimeout(AsyncEvent event)Notifies this AsyncListener that an asynchronous operation has timed out.voidstart()Enable asynchronous processing after which the response remains open until a call toServerHttpAsyncRequestControl.complete()is made or the server times out the request.voidstart(long timeout)A variation onServerHttpAsyncRequestControl.start()that allows specifying a timeout value to use to use for asynchronous processing.
Constructor Detail
ServletServerHttpAsyncRequestControl
public ServletServerHttpAsyncRequestControl(ServletServerHttpRequest request, ServletServerHttpResponse response)
Constructor accepting a request and response pair that are expected to be of typeServletServerHttpRequestandServletServerHttpResponserespectively.
Method Detail
isStarted
public boolean isStarted()
Description copied from interface:ServerHttpAsyncRequestControlReturn whether asynchronous request processing has been started.- Specified by:
isStartedin interfaceServerHttpAsyncRequestControl
isCompleted
public boolean isCompleted()
Description copied from interface:ServerHttpAsyncRequestControlReturn whether asynchronous request processing has been completed.- Specified by:
isCompletedin interfaceServerHttpAsyncRequestControl
start
public void start()
Description copied from interface:ServerHttpAsyncRequestControlEnable asynchronous processing after which the response remains open until a call toServerHttpAsyncRequestControl.complete()is made or the server times out the request. Once enabled, additional calls to this method are ignored.- Specified by:
startin interfaceServerHttpAsyncRequestControl
start
public void start(long timeout)
Description copied from interface:ServerHttpAsyncRequestControlA variation onServerHttpAsyncRequestControl.start()that allows specifying a timeout value to use to use for asynchronous processing. IfServerHttpAsyncRequestControl.complete()is not called within the specified value, the request times out.- Specified by:
startin interfaceServerHttpAsyncRequestControl
complete
public void complete()
Description copied from interface:ServerHttpAsyncRequestControlMark asynchronous request processing as completed.- Specified by:
completein interfaceServerHttpAsyncRequestControl
onComplete
public void onComplete(AsyncEvent event) throws IOException
Description copied from interface:javax.servlet.AsyncListenerNotifies this AsyncListener that an asynchronous operation has been completed.The
AsyncContextcorresponding to the asynchronous operation that has been completed may be obtained by callinggetAsyncContexton the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse), the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequestandgetSuppliedResponse, respectively, on the given event.- Specified by:
onCompletein interfaceAsyncListener- Parameters:
event- the AsyncEvent indicating that an asynchronous operation has been completed- Throws:
IOException- if an I/O related error has occurred during the processing of the given AsyncEvent
onStartAsync
public void onStartAsync(AsyncEvent event) throws IOException
Description copied from interface:javax.servlet.AsyncListenerNotifies this AsyncListener that a new asynchronous cycle is being initiated via a call to one of theServletRequest.startAsync()methods.The
AsyncContextcorresponding to the asynchronous operation that is being reinitialized may be obtained by callinggetAsyncContexton the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse), the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequestandgetSuppliedResponse, respectively, on the given event.This AsyncListener will not receive any events related to the new asynchronous cycle unless it registers itself (via a call to
AsyncContext.addListener(javax.servlet.AsyncListener)) with the AsyncContext that is delivered as part of the given AsyncEvent.- Specified by:
onStartAsyncin interfaceAsyncListener- Parameters:
event- the AsyncEvent indicating that a new asynchronous cycle is being initiated- Throws:
IOException- if an I/O related error has occurred during the processing of the given AsyncEvent
onError
public void onError(AsyncEvent event) throws IOException
Description copied from interface:javax.servlet.AsyncListenerNotifies this AsyncListener that an asynchronous operation has failed to complete.The
AsyncContextcorresponding to the asynchronous operation that failed to complete may be obtained by callinggetAsyncContexton the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse), the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequestandgetSuppliedResponse, respectively, on the given event.- Specified by:
onErrorin interfaceAsyncListener- Parameters:
event- the AsyncEvent indicating that an asynchronous operation has failed to complete- Throws:
IOException- if an I/O related error has occurred during the processing of the given AsyncEvent
onTimeout
public void onTimeout(AsyncEvent event) throws IOException
Description copied from interface:javax.servlet.AsyncListenerNotifies this AsyncListener that an asynchronous operation has timed out.The
AsyncContextcorresponding to the asynchronous operation that has timed out may be obtained by callinggetAsyncContexton the given event.In addition, if this AsyncListener had been registered via a call to
AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse), the supplied ServletRequest and ServletResponse objects may be retrieved by callinggetSuppliedRequestandgetSuppliedResponse, respectively, on the given event.- Specified by:
onTimeoutin interfaceAsyncListener- Parameters:
event- the AsyncEvent indicating that an asynchronous operation has timed out- Throws:
IOException- if an I/O related error has occurred during the processing of the given AsyncEvent