use of cn.taketoday.web.context.async.AsyncWebRequest in project today-framework by TAKETODAY.
the class ReactiveTypeHandlerTests method resetRequest.
private void resetRequest() {
this.servletRequest = new MockHttpServletRequest();
this.servletResponse = new MockHttpServletResponse();
this.webRequest = new ServletRequestContext(null, this.servletRequest, this.servletResponse);
AsyncWebRequest webRequest = new StandardServletAsyncWebRequest(this.servletRequest, this.servletResponse);
WebAsyncUtils.getAsyncManager(this.webRequest).setAsyncRequest(webRequest);
this.servletRequest.setAsyncSupported(true);
}
use of cn.taketoday.web.context.async.AsyncWebRequest in project today-framework by TAKETODAY.
the class RequestMappingHandlerAdapter method invokeHandlerMethod.
/**
* Invoke the {@link RequestMapping} handler method preparing a {@link ModelAndView}
* if view resolution is required.
*
* @see #createInvocableHandlerMethod(RequestContext, HandlerMethod)
*/
@Nullable
protected Object invokeHandlerMethod(RequestContext request, HandlerMethod handlerMethod) throws Throwable {
BindingContext bindingContext = createBindingContext(handlerMethod);
ModelFactory modelFactory = getModelFactory(handlerMethod, bindingContext);
ServletInvocableHandlerMethod invocableMethod = createInvocableHandlerMethod(request, handlerMethod);
RedirectModel inputRedirectModel = RequestContextUtils.getInputRedirectModel(request, redirectModelManager);
bindingContext.addAllAttributes(inputRedirectModel);
modelFactory.initModel(request, bindingContext, invocableMethod);
AsyncWebRequest asyncWebRequest = WebAsyncUtils.createAsyncWebRequest(request);
asyncWebRequest.setTimeout(asyncRequestTimeout);
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
asyncManager.setTaskExecutor(taskExecutor);
asyncManager.setAsyncRequest(asyncWebRequest);
asyncManager.registerCallableInterceptors(callableInterceptors);
asyncManager.registerDeferredResultInterceptors(deferredResultInterceptors);
if (asyncManager.hasConcurrentResult()) {
Object result = asyncManager.getConcurrentResult();
bindingContext = asyncManager.getBindingContext();
asyncManager.clearConcurrentResult();
LogFormatUtils.traceDebug(log, traceOn -> {
String formatted = LogFormatUtils.formatValue(result, !traceOn);
return "Resume with async result [" + formatted + "]";
});
invocableMethod = invocableMethod.wrapConcurrentResult(result);
}
Object returnValue = invocableMethod.invokeAndHandle(request, bindingContext);
if (asyncManager.isConcurrentHandlingStarted()) {
return null;
}
// modelFactory.updateModel(request, bindingContext);
return returnValue;
}
Aggregations