类 ReactiveTypeHandler
java.lang.Object
cn.taketoday.web.handler.method.ReactiveTypeHandler
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
-
嵌套类概要
嵌套类修饰符和类型类说明private static class(专用程序包) static classList of collect values where all elements are a specified type.private static classprivate static classprivate static classprivate static class -
字段概要
字段修饰符和类型字段说明private final cn.taketoday.core.ReactiveAdapterRegistryprivate final ContentNegotiationManagerprivate static final cn.taketoday.logging.Loggerprivate static final longprivate final cn.taketoday.core.task.TaskExecutorprivate static final MediaType -
构造器概要
构造器构造器说明ReactiveTypeHandler(cn.taketoday.core.ReactiveAdapterRegistry registry, cn.taketoday.core.task.TaskExecutor executor, ContentNegotiationManager manager) -
方法概要
修饰符和类型方法说明(专用程序包) static MediaTypefindConcreteStreamingMediaType(Collection<MediaType> acceptedMediaTypes) Attempts to find a concreteMediaTypethat can be streamed (as json separated by newlines in the response body).private ResponseBodyEmittergetEmitter(MediaType mediaType) private Collection<MediaType>getMediaTypes(RequestContext request) handleValue(Object returnValue, cn.taketoday.core.MethodParameter returnType, RequestContext request) Process the given reactive return value and decide whether to adapt it to aResponseBodyEmitteror aDeferredResult.booleanisReactiveType(Class<?> type) Whether the type can be adapted to a Reactive StreamsPublisher.
-
字段详细资料
-
log
private static final cn.taketoday.logging.Logger log -
STREAMING_TIMEOUT_VALUE
private static final long STREAMING_TIMEOUT_VALUE- 另请参阅:
-
WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON
-
taskExecutor
private final cn.taketoday.core.task.TaskExecutor taskExecutor -
adapterRegistry
private final cn.taketoday.core.ReactiveAdapterRegistry adapterRegistry -
contentNegotiationManager
-
-
构造器详细资料
-
ReactiveTypeHandler
public ReactiveTypeHandler() -
ReactiveTypeHandler
-
ReactiveTypeHandler
public ReactiveTypeHandler(cn.taketoday.core.ReactiveAdapterRegistry registry, cn.taketoday.core.task.TaskExecutor executor, ContentNegotiationManager manager)
-
-
方法详细资料
-
isReactiveType
Whether the type can be adapted to a Reactive StreamsPublisher. -
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 aResponseBodyEmitteror aDeferredResult.- 返回:
- an emitter for streaming, or
nullif handled internally with aDeferredResult - 抛出:
Exception
-
findConcreteStreamingMediaType
Attempts to find a concreteMediaTypethat can be streamed (as json separated by newlines in the response body). This method considers two concrete typesAPPLICATION_NDJSONandAPPLICATION_STREAM_JSON) as well as any subtype of application that has the+x-ndjsonsuffix. In the later case, the media type MUST be concrete for it to be considered.For example
application/vnd.myapp+x-ndjsonis considered a streaming type whileapplication/*+x-ndjsonisn't.- 参数:
acceptedMediaTypes- the collection of acceptable media types in the request- 返回:
- the concrete streaming
MediaTypeif one could be found ornullif none could be found
-
getMediaTypes
private Collection<MediaType> getMediaTypes(RequestContext request) throws HttpMediaTypeNotAcceptableException -
getEmitter
-