Class ReactiveAdapterRegistry
Publisher to/from various
async/reactive types such as CompletableFuture, RxJava Flowable, etc.
This is designed to complement Spring's Reactor Mono/Flux support while
also being usable without Reactor, for example, 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.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classBlockHoundIntegrationfor spring-core classes.
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a registry and auto-register default adapters.
- 
Method SummaryModifier and TypeMethodDescriptiongetAdapter(@Nullable Class<?> reactiveType, @Nullable Object source) Get the adapter for the given reactive type.getAdapter(Class<?> reactiveType) Get the adapter for the given reactive type.static ReactiveAdapterRegistryReturn a shared defaultReactiveAdapterRegistryinstance, lazily building it once needed.booleanReturn whether the registry has any adapters.voidregisterReactiveType(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toAdapter, Function<Publisher<?>, Object> fromAdapter) Register a reactive type along with functions to adapt to and from a Reactive StreamsPublisher.voidregisterReactiveTypeOverride(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toAdapter, Function<Publisher<?>, Object> fromAdapter) Register a reactive type along with functions to adapt to and from a Reactive StreamsPublisher.
- 
Constructor Details- 
ReactiveAdapterRegistrypublic ReactiveAdapterRegistry()Create a registry and auto-register default adapters.- See Also:
 
 
- 
- 
Method Details- 
registerReactiveTypepublic void registerReactiveType(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toAdapter, Function<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. - See Also:
 
- 
registerReactiveTypeOverridepublic void registerReactiveTypeOverride(ReactiveTypeDescriptor descriptor, Function<Object, Publisher<?>> toAdapter, Function<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. - Since:
- 5.3.30
- See Also:
 
- 
hasAdapterspublic boolean hasAdapters()Return whether the registry has any adapters.
- 
getAdapterGet the adapter for the given reactive type.- Returns:
- the corresponding adapter, or nullif none available
 
- 
getAdapterpublic @Nullable 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.- Parameters:
- reactiveType- the reactive type (may be- nullif a concrete source object is given)
- source- an instance of the reactive type (i.e. to adapt from; may be- nullif the reactive type is specified)
- Returns:
- the corresponding adapter, or nullif none available
 
 
-