类 ReactiveAdapterRegistry
Publisher to/from various
async/reactive types such as CompletableFuture, RxJava Flowable, etc.
This is designed to complement Infra Reactor Mono/Flux support while
also being usable without Reactor, e.g. just for org.reactivestreams bridging.
By default, depending on classpath availability, adapters are registered for Reactor
(including CompletableFuture and Flow.Publisher adapters), RxJava 3,
Kotlin Coroutines' Deferred (bridged via Reactor) and SmallRye Mutiny 1.x/2.x.
If Reactor is not present, a simple Flow.Publisher bridge will be registered.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明static classBlockHoundIntegrationfor core classes.private static classprivate static classprivate static classprivate static classReactiveAdapter variant that wraps adapted Publishers asFluxorMonodepending onReactiveTypeDescriptor.isMultiValue().private static classprivate static class -
字段概要
字段修饰符和类型字段说明private final ArrayList<ReactiveAdapter>private static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static ReactiveAdapterRegistry -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private ReactiveAdapterbuildAdapter(ReactiveTypeDescriptor descriptor, Function<Object, org.reactivestreams.Publisher<?>> toAdapter, Function<org.reactivestreams.Publisher<?>, Object> fromAdapter) getAdapter(Class<?> reactiveType) Get the adapter for the given reactive type.getAdapter(Class<?> reactiveType, Object source) Get the adapter for the given reactive type.static ReactiveAdapterRegistryReturn a shared defaultReactiveAdapterRegistryinstance, lazily building it once needed.booleanWhether the registry has any adapters.private static booleanvoidregisterReactiveType(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.voidregisterReactiveTypeOverride(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.
-
字段详细资料
-
mutinyPresent
private static final boolean mutinyPresent -
reactorPresent
private static final boolean reactorPresent -
rxjava3Present
private static final boolean rxjava3Present -
reactiveStreamsPresent
private static final boolean reactiveStreamsPresent -
adapters
-
构造器详细资料
-
ReactiveAdapterRegistry
public ReactiveAdapterRegistry()Create a registry and auto-register default adapters.- 另请参阅:
-
-
方法详细资料
-
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 neithernullnorOptional.This variant registers the new adapter after existing adapters. It will be matched for the exact reactive type if no earlier adapter was registered for the specific type, and it will be matched for assignability in a second pass if no earlier adapter had an assignable type before.
-
registerReactiveTypeOverride
public void registerReactiveTypeOverride(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 neithernullnorOptional.This variant registers the new adapter first, effectively overriding any previously registered adapters for the same reactive type. This allows for overriding existing adapters, in particular default adapters.
Note that existing adapters for specific types will still match before an assignability match with the new adapter. In order to override all existing matches, a new reactive type adapter needs to be registered for every specific type, not relying on subtype assignability matches.
-
buildAdapter
private ReactiveAdapter buildAdapter(ReactiveTypeDescriptor descriptor, Function<Object, org.reactivestreams.Publisher<?>> toAdapter, Function<org.reactivestreams.Publisher<?>, Object> fromAdapter) -
hasAdapters
public boolean hasAdapters()Whether the registry has any adapters. -
getAdapter
Get the adapter for the given reactive type.- 返回:
- the corresponding adapter, or
nullif 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 benullif a concrete source object is given)source- an instance of the reactive type (i.e. to adapt from; may benullif the reactive type is specified)- 返回:
- the corresponding adapter, or
nullif none available
-
isPresent
-