Search in sources :

Example 1 with DeferredResultProcessingInterceptorAdapter

use of org.springframework.web.context.request.async.DeferredResultProcessingInterceptorAdapter in project spring-framework by spring-projects.

the class TestDispatcherServlet method registerAsyncResultInterceptors.

private void registerAsyncResultInterceptors(final HttpServletRequest request) {
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
    asyncManager.registerCallableInterceptor(KEY, new CallableProcessingInterceptorAdapter() {

        @Override
        public <T> void postProcess(NativeWebRequest r, Callable<T> task, Object value) throws Exception {
            getMvcResult(request).setAsyncResult(value);
        }
    });
    asyncManager.registerDeferredResultInterceptor(KEY, new DeferredResultProcessingInterceptorAdapter() {

        @Override
        public <T> void postProcess(NativeWebRequest r, DeferredResult<T> result, Object value) throws Exception {
            getMvcResult(request).setAsyncResult(value);
        }
    });
}
Also used : WebAsyncManager(org.springframework.web.context.request.async.WebAsyncManager) DeferredResultProcessingInterceptorAdapter(org.springframework.web.context.request.async.DeferredResultProcessingInterceptorAdapter) CallableProcessingInterceptorAdapter(org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter) NativeWebRequest(org.springframework.web.context.request.NativeWebRequest) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 NativeWebRequest (org.springframework.web.context.request.NativeWebRequest)1 CallableProcessingInterceptorAdapter (org.springframework.web.context.request.async.CallableProcessingInterceptorAdapter)1 DeferredResultProcessingInterceptorAdapter (org.springframework.web.context.request.async.DeferredResultProcessingInterceptorAdapter)1 WebAsyncManager (org.springframework.web.context.request.async.WebAsyncManager)1