类 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

      public RequestResponseBodyAdviceChain(@Nullable List<Object> requestResponseBodyAdvice)
      Create an instance from a list of objects that are either of type ControllerAdviceBean or RequestBodyAdvice.
  • 方法详细资料

    • getAdviceByType

      public static <T> List<T> getAdviceByType(@Nullable List<Object> bodyAdvice, Class<T> adviceType)
    • supports

      public boolean supports(cn.taketoday.core.MethodParameter param, Type type, HttpMessageConverter<?> converter)
      从接口复制的说明: RequestBodyAdvice
      Invoked first to determine if this interceptor applies.
      指定者:
      supports 在接口中 RequestBodyAdvice
      参数:
      param - the method parameter
      type - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<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)
      从接口复制的说明: ResponseBodyAdvice
      Whether this component supports the given controller method return type and the selected HttpMessageConverter type.
      指定者:
      supports 在接口中 ResponseBodyAdvice<Object>
      returnType - the return type
      converter - the selected converter
      返回:
      true if ResponseBodyAdvice.beforeBodyWrite(java.lang.Object, cn.taketoday.core.MethodParameter, cn.taketoday.http.MediaType, cn.taketoday.http.converter.HttpMessageConverter<?>, cn.taketoday.web.RequestContext) should be invoked; false otherwise
    • beforeBodyRead

      public HttpInputMessage beforeBodyRead(HttpInputMessage request, cn.taketoday.core.MethodParameter parameter, Type targetType, HttpMessageConverter<?> converter) throws IOException
      从接口复制的说明: RequestBodyAdvice
      Invoked second before the request body is read and converted.
      指定者:
      beforeBodyRead 在接口中 RequestBodyAdvice
      参数:
      request - the request
      parameter - the target method parameter
      targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<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)
      从接口复制的说明: RequestBodyAdvice
      Invoked 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 called
      inputMessage - the request
      parameter - the target method parameter
      targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<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)
      从接口复制的说明: ResponseBodyAdvice
      Invoked after an HttpMessageConverter is selected and just before its write method is invoked.
      指定者:
      beforeBodyWrite 在接口中 ResponseBodyAdvice<Object>
      参数:
      body - the body to be written
      returnType - the return type of the controller method
      contentType - the content type selected through content negotiation
      converter - the converter selected to write to the response
      context - 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)
      从接口复制的说明: RequestBodyAdvice
      Invoked second (and last) if the body is empty.
      指定者:
      handleEmptyBody 在接口中 RequestBodyAdvice
      参数:
      body - usually set to null before the first advice is called
      inputMessage - the request
      parameter - the method parameter
      targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
      converter - the selected converter
      返回:
      the value to use, or null which may then raise an HttpMessageNotReadableException if the argument is required
    • getMatchingAdvice

      private <A> List<A> getMatchingAdvice(@Nullable cn.taketoday.core.MethodParameter parameter, Class<? extends A> adviceType, List<Object> availableAdvice)