类 ReactiveAdapterRegistry
- java.lang.Object
- org.springframework.core.ReactiveAdapterRegistry
public class ReactiveAdapterRegistry extends Object
A registry of adapters to adapt Reactive StreamsPublisher
to/from various async/reactive types such asCompletableFuture
, RxJavaObservable
, and others.By default, depending on classpath availability, adapters are registered for Reactor, RxJava 1, RxJava 2 types,
CompletableFuture
, Java 9+Flow.Publisher
and Kotlin CoroutinesDeferred
andFlow
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze
嵌套类概要
嵌套类 修饰符和类型 类 说明 static class
ReactiveAdapterRegistry.SpringCoreBlockHoundIntegration
BlockHoundIntegration
for spring-core classes.
构造器概要
构造器 构造器 说明 ReactiveAdapterRegistry()
Create a registry and auto-register default adapters.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 ReactiveAdapter
getAdapter(Class<?> reactiveType)
Get the adapter for the given reactive type.ReactiveAdapter
getAdapter(Class<?> reactiveType, Object source)
Get the adapter for the given reactive type.static ReactiveAdapterRegistry
getSharedInstance()
Return a shared defaultReactiveAdapterRegistry
instance, lazily building it once needed.boolean
hasAdapters()
Whether the registry has any adapters which would be the case if any of Reactor, RxJava 2, or RxJava 1 (+ RxJava Reactive Streams bridge) are present on the classpath.void
registerReactiveType(ReactiveTypeDescriptor descriptor, Function<Object,org.reactivestreams.Publisher<?>> toAdapter, Function<org.reactivestreams.Publisher<?>,Object> fromAdapter)
Register a reactive type along with functions to adapt to and from a Reactive StreamsPublisher
.
构造器详细资料
ReactiveAdapterRegistry
public ReactiveAdapterRegistry()
Create a registry and auto-register default adapters.- 另请参阅:
getSharedInstance()
方法详细资料
hasAdapters
public boolean hasAdapters()
Whether the registry has any adapters which would be the case if any of Reactor, RxJava 2, or RxJava 1 (+ RxJava Reactive Streams bridge) are present on the classpath.
registerReactiveType
public void registerReactiveType(ReactiveTypeDescriptor descriptor, Function<Object,org.reactivestreams.Publisher<?>> toAdapter, Function<org.reactivestreams.Publisher<?>,Object> fromAdapter)
Register a reactive type along with functions to adapt to and from a Reactive StreamsPublisher
. The function arguments assume that their input is neithernull
norOptional
.
getAdapter
@Nullable public ReactiveAdapter getAdapter(Class<?> reactiveType)
Get the adapter for the given reactive type.- 返回:
- the corresponding adapter, or
null
if none available
getAdapter
@Nullable public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Object source)
Get the adapter for the given reactive type. Or if a "source" object is provided, its actual type is used instead.- 参数:
reactiveType
- the reactive type (may benull
if a concrete source object is given)source
- an instance of the reactive type (i.e. to adapt from; may benull
if the reactive type is specified)- 返回:
- the corresponding adapter, or
null
if none available
getSharedInstance
public static ReactiveAdapterRegistry getSharedInstance()
Return a shared defaultReactiveAdapterRegistry
instance, lazily building it once needed.NOTE: We highly recommend passing a long-lived, pre-configured
ReactiveAdapterRegistry
instance for customization purposes. This accessor is only meant as a fallback for code paths that want to fall back on a default instance if one isn't provided.- 返回:
- the shared
ReactiveAdapterRegistry
instance - 从以下版本开始:
- 5.0.2