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
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Mono<T>
deferredToMono
(kotlinx.coroutines.Deferred<T> source) Convert aDeferred
instance to aMono
.static Publisher<?>
invokeSuspendingFunction
(Method method, Object target, Object... args) Invoke a suspending function and converts it toMono
orFlux
.static Publisher<?>
invokeSuspendingFunction
(kotlin.coroutines.CoroutineContext context, Method method, Object target, Object... args) Invoke a suspending function and converts it toMono
orFlux
.static <T> kotlinx.coroutines.Deferred<T>
monoToDeferred
(reactor.core.publisher.Mono<T> source) Convert aMono
instance 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 aDeferred
instance to aMono
. -
monoToDeferred
public static <T> kotlinx.coroutines.Deferred<T> monoToDeferred(reactor.core.publisher.Mono<T> source) Convert aMono
instance to aDeferred
. -
invokeSuspendingFunction
Invoke a suspending function and converts it toMono
orFlux
. Uses an unconfined dispatcher.- Parameters:
method
- the suspending function to invoketarget
- the target to invokemethod
onargs
- the function arguments- Returns:
- the method invocation result as reactive stream
-
invokeSuspendingFunction
public static Publisher<?> invokeSuspendingFunction(kotlin.coroutines.CoroutineContext context, Method method, Object target, Object... args) Invoke a suspending function and converts it toMono
orFlux
.- Parameters:
context
- the coroutine context to usemethod
- the suspending function to invoketarget
- the target to invokemethod
onargs
- the function arguments- Returns:
- the method invocation result as reactive stream
- Since:
- 6.0
-