类 RequestResponseBodyAdviceChain
java.lang.Object
cn.taketoday.web.bind.resolver.RequestResponseBodyAdviceChain
- 所有已实现的接口:
RequestBodyAdvice,ResponseBodyAdvice<Object>
public class RequestResponseBodyAdviceChain
extends Object
implements RequestBodyAdvice, ResponseBodyAdvice<Object>
Invokes
RequestBodyAdvice and ResponseBodyAdvice where each
instance may be (and is most likely) wrapped with
ControllerAdviceBean.- 从以下版本开始:
- 4.0 2022/1/22 21:44
- 作者:
- Rossen Stoyanchev, Harry Yang
-
字段概要
字段修饰符和类型字段说明 -
构造器概要
构造器构造器说明RequestResponseBodyAdviceChain(List<Object> requestResponseBodyAdvice) Create an instance from a list of objects that are either of typeControllerAdviceBeanorRequestBodyAdvice. -
方法概要
修饰符和类型方法说明afterBodyRead(Object body, HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) Invoked third (and last) after the request body is converted to an Object.beforeBodyRead(HttpInputMessage request, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) Invoked second before the request body is read and converted.beforeBodyWrite(Object body, cn.taketoday.core.MethodParameter returnType, MediaType contentType, HttpMessageConverter<?> converter, RequestContext context) Invoked after anHttpMessageConverteris selected and just before its write method is invoked.static <T> List<T>getAdviceByType(List<Object> bodyAdvice, Class<T> adviceType) private <A> List<A>getMatchingAdvice(cn.taketoday.core.MethodParameter parameter, Class<? extends A> adviceType, List<Object> availableAdvice) handleEmptyBody(Object body, HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) Invoked second (and last) if the body is empty.booleansupports(cn.taketoday.core.MethodParameter param, Type type, HttpMessageConverter<?> converter) Invoked first to determine if this interceptor applies.booleansupports(Object body, cn.taketoday.core.MethodParameter returnType, HttpMessageConverter<?> converter) Whether this component supports the given controller method return type and the selectedHttpMessageConvertertype.
-
字段详细资料
-
requestBodyAdvice
-
responseBodyAdvice
-
-
构造器详细资料
-
RequestResponseBodyAdviceChain
Create an instance from a list of objects that are either of typeControllerAdviceBeanorRequestBodyAdvice.
-
-
方法详细资料
-
getAdviceByType
-
supports
public boolean supports(cn.taketoday.core.MethodParameter param, Type type, HttpMessageConverter<?> converter) 从接口复制的说明:RequestBodyAdviceInvoked first to determine if this interceptor applies.- 指定者:
supports在接口中RequestBodyAdvice- 参数:
param- the method parametertype- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>.converter- the selected converter- 返回:
- whether this interceptor should be invoked or not
-
supports
public boolean supports(@Nullable Object body, @Nullable cn.taketoday.core.MethodParameter returnType, HttpMessageConverter<?> converter) 从接口复制的说明:ResponseBodyAdviceWhether this component supports the given controller method return type and the selectedHttpMessageConvertertype.- 指定者:
supports在接口中ResponseBodyAdvice<Object>returnType- the return typeconverter- the selected converter- 返回:
trueifResponseBodyAdvice.beforeBodyWrite(java.lang.Object, cn.taketoday.core.MethodParameter, cn.taketoday.http.MediaType, cn.taketoday.http.converter.HttpMessageConverter<?>, cn.taketoday.web.RequestContext)should be invoked;falseotherwise
-
beforeBodyRead
public HttpInputMessage beforeBodyRead(HttpInputMessage request, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) throws IOException 从接口复制的说明:RequestBodyAdviceInvoked second before the request body is read and converted.- 指定者:
beforeBodyRead在接口中RequestBodyAdvice- 参数:
request- the requestparameter- the target method parametertargetType- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>.converter- the converter used to deserialize the body- 返回:
- the input request or a new instance (never
null) - 抛出:
IOException
-
afterBodyRead
public Object afterBodyRead(Object body, HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) 从接口复制的说明:RequestBodyAdviceInvoked third (and last) after the request body is converted to an Object.- 指定者:
afterBodyRead在接口中RequestBodyAdvice- 参数:
body- set to the converter Object before the first advice is calledinputMessage- the requestparameter- the target method parametertargetType- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>.converter- the converter used to deserialize the body- 返回:
- the same body or a new instance
-
beforeBodyWrite
@Nullable public Object beforeBodyWrite(@Nullable Object body, @Nullable cn.taketoday.core.MethodParameter returnType, MediaType contentType, HttpMessageConverter<?> converter, RequestContext context) 从接口复制的说明:ResponseBodyAdviceInvoked after anHttpMessageConverteris selected and just before its write method is invoked.- 指定者:
beforeBodyWrite在接口中ResponseBodyAdvice<Object>- 参数:
body- the body to be writtenreturnType- the return type of the controller methodcontentType- the content type selected through content negotiationconverter- the converter selected to write to the responsecontext- the current request context- 返回:
- the body that was passed in or a modified (possibly new) instance
-
handleEmptyBody
@Nullable public Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) 从接口复制的说明:RequestBodyAdviceInvoked second (and last) if the body is empty.- 指定者:
handleEmptyBody在接口中RequestBodyAdvice- 参数:
body- usually set tonullbefore the first advice is calledinputMessage- the requestparameter- the method parametertargetType- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>.converter- the selected converter- 返回:
- the value to use, or
nullwhich may then raise anHttpMessageNotReadableExceptionif the argument is required
-
getMatchingAdvice
-