- java.lang.Object
-
- com.github.robtimus.servlet.AsyncUtils
-
public final class AsyncUtils extends Object
A utility classes for dealing with asynchronous request handling.- Author:
- Rob Spoor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
doFilter(ServletRequest request, ServletResponse response, FilterChain chain, ServletConsumer action)
Proceeds in the filter chain and executes an action after the chain ends.
-
-
-
Method Detail
-
doFilter
public static void doFilter(ServletRequest request, ServletResponse response, FilterChain chain, ServletConsumer action) throws IOException, ServletException
Proceeds in the filter chain and executes an action after the chain ends. This method can be used to ensure the given action is executed at the end of the request, regardless of whether or not the request is handled asynchronously.If the request has not been put into asynchronous mode, this method will execute the following:
However, if the request has been put into asynchronous mode, this method will ensure that the given action will execute once the asynchronous operation completes, successfully or not.try { chain.doFilter(request, response); } finally { action.run(request, response); }
- Parameters:
request
- The request to use in bothchain.doFilter
and the action.response
- The response to use in bothchain.doFilter
and the action.chain
- The filter chain to callFilterChain.doFilter(ServletRequest, ServletResponse)
on.action
- The action to execute after the chain ends.- Throws:
IOException
- Re-thrown from the call tochain.doFilter
or the action.ServletException
- Re-thrown from the call tochain.doFilter
.NullPointerException
- If the request, response filter chain or action isnull
.
-
-