Package org.springframework.core
Class CoroutinesUtils
java.lang.Object
org.springframework.core.CoroutinesUtils
Utilities for working with Kotlin Coroutines.
- Since:
- 5.2
- Author:
- Sebastien Deleuze, Phillip Webb
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Mono<T>deferredToMono(kotlinx.coroutines.Deferred<T> source) Convert aDeferredinstance to aMono.static Publisher<?>invokeSuspendingFunction(Method method, Object target, Object... args) Invoke a suspending function and convert it toMonoorFlux.static Publisher<?>invokeSuspendingFunction(kotlin.coroutines.CoroutineContext context, Method method, Object target, Object... args) Invoke a suspending function and convert it toMonoorFlux.static <T> kotlinx.coroutines.Deferred<T>monoToDeferred(reactor.core.publisher.Mono<T> source) Convert aMonoinstance to aDeferred.
-
Constructor Details
-
CoroutinesUtils
public CoroutinesUtils()
-
-
Method Details
-
deferredToMono
public static <T> reactor.core.publisher.Mono<T> deferredToMono(kotlinx.coroutines.Deferred<T> source) Convert aDeferredinstance to aMono. -
monoToDeferred
public static <T> kotlinx.coroutines.Deferred<T> monoToDeferred(reactor.core.publisher.Mono<T> source) Convert aMonoinstance to aDeferred. -
invokeSuspendingFunction
public static Publisher<?> invokeSuspendingFunction(Method method, Object target, @Nullable Object... args) Invoke a suspending function and convert it toMonoorFlux. Uses an unconfined dispatcher.- Parameters:
method- the suspending function to invoketarget- the target to invokemethodonargs- the function arguments. If theContinuationargument is specified as the last argument (typicallynull), it is ignored.- Returns:
- the method invocation result as reactive stream
- Throws:
IllegalArgumentException- ifmethodis not a suspending function
-
invokeSuspendingFunction
public static Publisher<?> invokeSuspendingFunction(kotlin.coroutines.CoroutineContext context, Method method, @Nullable Object target, @Nullable Object... args) Invoke a suspending function and convert it toMonoorFlux.- Parameters:
context- the coroutine context to usemethod- the suspending function to invoketarget- the target to invokemethodonargs- the function arguments. If theContinuationargument is specified as the last argument (typicallynull), it is ignored.- Returns:
- the method invocation result as reactive stream
- Throws:
IllegalArgumentException- ifmethodis not a suspending function- Since:
- 6.0
-