當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。