本文整理汇总了Java中org.springframework.web.method.support.ModelAndViewContainer.setRequestHandled方法的典型用法代码示例。如果您正苦于以下问题:Java ModelAndViewContainer.setRequestHandled方法的具体用法?Java ModelAndViewContainer.setRequestHandled怎么用?Java ModelAndViewContainer.setRequestHandled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.method.support.ModelAndViewContainer
的用法示例。
在下文中一共展示了ModelAndViewContainer.setRequestHandled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
final AsyncResponseEntity<?> asyncResponseEntity = AsyncResponseEntity.class.cast(returnValue);
Observable<?> observable = asyncResponseEntity.getObservable();
Single<?> single = asyncResponseEntity.getSingle();
MultiValueMap<String, String> headers = asyncResponseEntity.getHeaders();
HttpStatus status = asyncResponseEntity.getStatus();
if(observable != null)
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(new ObservableDeferredResult<>(observable, headers, status), mavContainer);
else if(single != null)
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(new SingleDeferredResult<>(single, headers, status), mavContainer);
}
开发者ID:quebic-source,项目名称:microservices-sample-project,代码行数:22,代码来源:AsyncResponseEntityReturnHandler.java
示例2: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
final DeferredResult<Object> deferredResult = new DeferredResult<>();
@SuppressWarnings("unchecked")
ListenableFuture<Object> futureValue = (ListenableFuture<Object>) returnValue;
Futures.addCallback(futureValue, new FutureCallback<Object>() {
@Override
public void onSuccess(@Nullable Object result) {
deferredResult.setResult(result);
}
@Override
public void onFailure(Throwable ex) {
deferredResult.setErrorResult(ex);
}
});
startDeferredResultProcessing(mavContainer, webRequest, deferredResult);
}
示例3: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
@SuppressWarnings("resource")
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
mavContainer.setRequestHandled(true);
Assert.isInstanceOf(HttpHeaders.class, returnValue);
HttpHeaders headers = (HttpHeaders) returnValue;
if (!headers.isEmpty()) {
HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);
ServletServerHttpResponse outputMessage = new ServletServerHttpResponse(servletResponse);
outputMessage.getHeaders().putAll(headers);
outputMessage.getBody(); // flush headers
}
}
示例4: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
throws IOException, HttpMediaTypeNotAcceptableException {
mavContainer.setRequestHandled(true);
HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
JsonResult jsonResult = new JsonResult(returnValue);
response.setContentType("application/json; charset=UTF-8");
JsonUtil.writeValue(response.getWriter(), jsonResult);
}
示例5: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
mavContainer.setRequestHandled(true);
HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);
ServletServerHttpResponse outputMessage = new ServletServerHttpResponse(servletResponse);
outputMessage.getBody();
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
WxRequest wxRequest = WxWebUtils.getWxRequestFromRequest(request);
wxAsyncMessageTemplate.send(wxRequest, returnValue);
}
示例6: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
final Observable<?> observable = Observable.class.cast(returnValue);
log.debug("handleReturnValue begin to process");
WebAsyncUtils.getAsyncManager(webRequest)
.startDeferredResultProcessing(new ObservableAdapter<>(observable), mavContainer);
log.debug("handleReturnValue stop to process");
}
示例7: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue,
MethodParameter returnType,
ModelAndViewContainer mavContainer,
NativeWebRequest webRequest) throws Exception {
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
ToDownload toDownload = returnType.getMethodAnnotation(ToDownload.class);
PathPartial d = toDownload.attachment() ? downloader : viewer;
d.service(request, response, Path.class.cast(returnValue));
mavContainer.setRequestHandled(true);
}
示例8: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
ModelAndView mav = (ModelAndView) returnValue;
if (mav.isReference()) {
String viewName = mav.getViewName();
mavContainer.setViewName(viewName);
if (viewName != null && isRedirectViewName(viewName)) {
mavContainer.setRedirectModelScenario(true);
}
}
else {
View view = mav.getView();
mavContainer.setView(view);
if (view instanceof SmartView) {
if (((SmartView) view).isRedirectView()) {
mavContainer.setRedirectModelScenario(true);
}
}
}
mavContainer.addAllAttributes(mav.getModel());
}
示例9: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
ServerHttpResponse outputMessage = new ServletServerHttpResponse(response);
if (ResponseEntity.class.isAssignableFrom(returnValue.getClass())) {
ResponseEntity<?> responseEntity = (ResponseEntity<?>) returnValue;
outputMessage.setStatusCode(responseEntity.getStatusCode());
outputMessage.getHeaders().putAll(responseEntity.getHeaders());
returnValue = responseEntity.getBody();
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
}
ServletRequest request = webRequest.getNativeRequest(ServletRequest.class);
ShallowEtagHeaderFilter.disableContentCaching(request);
Assert.isInstanceOf(StreamingResponseBody.class, returnValue);
StreamingResponseBody streamingBody = (StreamingResponseBody) returnValue;
Callable<Void> callable = new StreamingResponseBodyTask(outputMessage.getBody(), streamingBody);
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(callable, mavContainer);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:StreamingResponseBodyReturnValueHandler.java
示例10: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
Callable<?> callable = (Callable<?>) returnValue;
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(callable, mavContainer);
}
示例11: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
WebAsyncTask<?> webAsyncTask = (WebAsyncTask<?>) returnValue;
webAsyncTask.setBeanFactory(this.beanFactory);
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(webAsyncTask, mavContainer);
}
示例12: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
final DeferredResult<Object> deferredResult = new DeferredResult<Object>();
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
@SuppressWarnings("unchecked")
CompletionStage<Object> future = (CompletionStage<Object>) returnValue;
future.thenAccept(new Consumer<Object>() {
@Override
public void accept(Object result) {
deferredResult.setResult(result);
}
});
future.exceptionally(new Function<Throwable, Object>() {
@Override
public Object apply(Throwable ex) {
deferredResult.setErrorResult(ex);
return null;
}
});
}
示例13: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue == null) {
mavContainer.setRequestHandled(true);
return;
}
DeferredResult<?> deferredResult = (DeferredResult<?>) returnValue;
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DeferredResultMethodReturnValueHandler.java
示例14: resolveArgument
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
/**
* Set {@link ModelAndViewContainer#setRequestHandled(boolean)} to
* {@code false} to indicate that the method signature provides access
* to the response. If subsequently the underlying method returns
* {@code null}, the request is considered directly handled.
*/
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
if (mavContainer != null) {
mavContainer.setRequestHandled(true);
}
HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
Class<?> paramType = parameter.getParameterType();
if (ServletResponse.class.isAssignableFrom(paramType)) {
Object nativeResponse = webRequest.getNativeResponse(paramType);
if (nativeResponse == null) {
throw new IllegalStateException(
"Current response is not of type [" + paramType.getName() + "]: " + response);
}
return nativeResponse;
}
else if (OutputStream.class.isAssignableFrom(paramType)) {
return response.getOutputStream();
}
else if (Writer.class.isAssignableFrom(paramType)) {
return response.getWriter();
}
else {
// should not happen
Method method = parameter.getMethod();
throw new UnsupportedOperationException("Unknown parameter type: " + paramType + " in method: " + method);
}
}
示例15: handleReturnValue
import org.springframework.web.method.support.ModelAndViewContainer; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
mavContainer.setRequestHandled(true);
// Try even with null return value. ResponseBodyAdvice could get involved.
writeWithMessageConverters(returnValue, returnType, webRequest);
}