类 ReactiveTypeHandler

java.lang.Object
cn.taketoday.web.handler.method.ReactiveTypeHandler

final class ReactiveTypeHandler extends Object
Private helper class to assist with handling "reactive" return values types that can be adapted to a Reactive Streams Publisher through the ReactiveAdapterRegistry.

Such return values may be bridged to a ResponseBodyEmitter for streaming purposes at the presence of a streaming media type or based on the generic type.

For all other cases Publisher output is collected and bridged to DeferredResult for standard async request processing.

从以下版本开始:
4.0 2022/4/8 23:54
作者:
Rossen Stoyanchev, Harry Yang
  • 字段详细资料

    • log

      private static final cn.taketoday.logging.Logger log
    • STREAMING_TIMEOUT_VALUE

      private static final long STREAMING_TIMEOUT_VALUE
      另请参阅:
    • WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON

      private static final MediaType WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON
    • taskExecutor

      private final cn.taketoday.core.task.TaskExecutor taskExecutor
    • adapterRegistry

      private final cn.taketoday.core.ReactiveAdapterRegistry adapterRegistry
    • contentNegotiationManager

      private final ContentNegotiationManager contentNegotiationManager
  • 构造器详细资料

    • ReactiveTypeHandler

      public ReactiveTypeHandler()
    • ReactiveTypeHandler

      public ReactiveTypeHandler(ContentNegotiationManager manager)
    • ReactiveTypeHandler

      public ReactiveTypeHandler(cn.taketoday.core.ReactiveAdapterRegistry registry, cn.taketoday.core.task.TaskExecutor executor, ContentNegotiationManager manager)
  • 方法详细资料

    • isReactiveType

      public boolean isReactiveType(Class<?> type)
      Whether the type can be adapted to a Reactive Streams Publisher.
    • handleValue

      @Nullable public ResponseBodyEmitter handleValue(Object returnValue, cn.taketoday.core.MethodParameter returnType, RequestContext request) throws Exception
      Process the given reactive return value and decide whether to adapt it to a ResponseBodyEmitter or a DeferredResult.
      返回:
      an emitter for streaming, or null if handled internally with a DeferredResult
      抛出:
      Exception
    • findConcreteStreamingMediaType

      @Nullable static MediaType findConcreteStreamingMediaType(Collection<MediaType> acceptedMediaTypes)
      Attempts to find a concrete MediaType that can be streamed (as json separated by newlines in the response body). This method considers two concrete types APPLICATION_NDJSON and APPLICATION_STREAM_JSON) as well as any subtype of application that has the +x-ndjson suffix. In the later case, the media type MUST be concrete for it to be considered.

      For example application/vnd.myapp+x-ndjson is considered a streaming type while application/*+x-ndjson isn't.

      参数:
      acceptedMediaTypes - the collection of acceptable media types in the request
      返回:
      the concrete streaming MediaType if one could be found or null if none could be found
    • getMediaTypes

      抛出:
      HttpMediaTypeNotAcceptableException
    • getEmitter

      private ResponseBodyEmitter getEmitter(MediaType mediaType)