public class ReactiveAdapterRegistry
extends java.lang.Object
Publisher
to/from
various async/reactive types such as CompletableFuture
, RxJava
Observable
, and others.
By default, depending on classpath availability, adapters are registered
for Reactor, RxJava 1, RxJava 2 types, and CompletableFuture
.
Modifier and Type | Class and Description |
---|---|
private static class |
ReactiveAdapterRegistry.ReactorAdapter
Extension of ReactiveAdapter that wraps adapted (raw) Publisher's as
Flux or Mono depending on the underlying reactive type's
stream semantics. |
private static class |
ReactiveAdapterRegistry.ReactorRegistrar |
private static class |
ReactiveAdapterRegistry.RxJava1Registrar |
private static class |
ReactiveAdapterRegistry.RxJava2Registrar |
Modifier and Type | Field and Description |
---|---|
private java.util.List<ReactiveAdapter> |
adapters |
private static boolean |
reactorPresent |
private static boolean |
rxJava1Adapter |
private static boolean |
rxJava1Present |
private static boolean |
rxJava2Present |
Constructor and Description |
---|
ReactiveAdapterRegistry()
Create a registry and auto-register default adapters.
|
Modifier and Type | Method and Description |
---|---|
ReactiveAdapter |
getAdapter(java.lang.Class<?> reactiveType)
Get the adapter for the given reactive type.
|
ReactiveAdapter |
getAdapter(java.lang.Class<?> reactiveType,
java.lang.Object source)
Get the adapter for the given reactive type.
|
void |
registerReactiveType(ReactiveTypeDescriptor descriptor,
java.util.function.Function<java.lang.Object,<any>> toAdapter,
java.util.function.Function<<any>,java.lang.Object> fromAdapter)
Register a reactive type along with functions to adapt to and from a
Reactive Streams
Publisher . |
private static final boolean reactorPresent
private static final boolean rxJava1Present
private static final boolean rxJava1Adapter
private static final boolean rxJava2Present
private final java.util.List<ReactiveAdapter> adapters
public ReactiveAdapterRegistry()
public void registerReactiveType(ReactiveTypeDescriptor descriptor, java.util.function.Function<java.lang.Object,<any>> toAdapter, java.util.function.Function<<any>,java.lang.Object> fromAdapter)
Publisher
. The functions can assume their
input is never be null
nor Optional
.public ReactiveAdapter getAdapter(java.lang.Class<?> reactiveType)
public ReactiveAdapter getAdapter(java.lang.Class<?> reactiveType, java.lang.Object source)
reactiveType
- the reactive typesource
- an instance of the reactive type (i.e. to adapt from)