当前位置: 首页>>代码示例>>Java>>正文


Java ModelAndViewContainer.setRequestHandled方法代码示例

本文整理汇总了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);
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:26,代码来源:GuavaLFReturnValueHandler.java

示例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
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:HttpHeadersReturnValueHandler.java

示例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);
}
 
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:11,代码来源:JsonBodyReturnValueProcessor.java

示例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);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:12,代码来源:WxAsyncMessageReturnValueHandler.java

示例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");
}
 
开发者ID:bobxwang,项目名称:springboot-scala-withswagger,代码行数:15,代码来源:ObservableReturnValueHandler.java

示例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);
}
 
开发者ID:zjnu-acm,项目名称:judge,代码行数:14,代码来源:PathDownloaderHandler.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ModelAndViewMethodReturnValueHandler.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:CallableMethodReturnValueHandler.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:AsyncTaskMethodReturnValueHandler.java

示例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;
		}
	});
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:CompletionStageReturnValueHandler.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:ServletResponseMethodArgumentResolver.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:RequestResponseBodyMethodProcessor.java


注:本文中的org.springframework.web.method.support.ModelAndViewContainer.setRequestHandled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。