Top Description Fields Constructors Methods
org.springframework.core

public abstract Class CoroutinesUtils

extends Object
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier, java.util.Map, .Objects, kotlin.Unit, kotlin.coroutines.CoroutineContext, kotlin.jvm.JvmClassMappingKt, kotlin.reflect.KClass, kotlin.reflect.KClassifier, kotlin.reflect.KFunction, kotlin.reflect.KParameter, kotlin.reflect.full.KCallables, kotlin.reflect.jvm.KCallablesJvm, kotlin.reflect.jvm.ReflectJvmMapping, kotlinx.coroutines.BuildersKt, kotlinx.coroutines.CoroutineStart, kotlinx.coroutines.Deferred, kotlinx.coroutines.Dispatchers, kotlinx.coroutines.GlobalScope, kotlinx.coroutines.flow.Flow, kotlinx.coroutines.reactor.MonoKt, kotlinx.coroutines.reactor.ReactorFlowKt, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.util.Assert, .CollectionUtils, .ReflectionUtils

Utilities for working with Kotlin Coroutines.
Authors
Sebastien Deleuze, Phillip Webb
Since
5.2

Field Summary

Modifier and TypeField and Description
private static final ReflectionUtils.MethodFilter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Flux<?>
asFlux(Object flow)

public static <T> Mono<T>
deferredToMono(kotlinx.coroutines.Deferred<T> source)

Convert a Deferred instance to a Mono.

public static Publisher<?>

Returns:

the method invocation result as reactive stream
invokeSuspendingFunction
(Method
the suspending function to invoke
method
,
Object
the target to invoke method on
target
,
Object...
the function arguments. If the Continuation argument is specified as the last argument (typically null), it is ignored.
args
)

Invoke a suspending function and convert it to Mono or Flux.

public static Publisher<?>

Returns:

the method invocation result as reactive stream
invokeSuspendingFunction
(kotlin.coroutines.CoroutineContext
the coroutine context to use
context
,
Method
the suspending function to invoke
method
,
Object
the target to invoke method on
target
,
Object...
the function arguments. If the Continuation argument is specified as the last argument (typically null), it is ignored.
args
)

Invoke a suspending function and convert it to Mono or Flux.

public static <T> kotlinx.coroutines.Deferred<T>
monoToDeferred(Mono<T> source)

Convert a Mono instance to a Deferred.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boxImplFilterback to summary
private static final ReflectionUtils.MethodFilter boxImplFilter

Constructor Detail

CoroutinesUtilsback to summary
public CoroutinesUtils()

Method Detail

asFluxback to summary
private static Flux<?> asFlux(Object flow)
deferredToMonoback to summary
public static <T> Mono<T> deferredToMono(kotlinx.coroutines.Deferred<T> source)

Convert a Deferred instance to a Mono.

invokeSuspendingFunctionback to summary
public static Publisher<?> invokeSuspendingFunction(Method method, Object target, Object... args)

Invoke a suspending function and convert it to Mono or Flux. Uses an unconfined dispatcher.

Parameters
method:Method

the suspending function to invoke

target:Object

the target to invoke method on

args:Object[]

the function arguments. If the Continuation argument is specified as the last argument (typically null), it is ignored.

Returns:Publisher<?>

the method invocation result as reactive stream

Exceptions
IllegalArgumentException:
if method is not a suspending function
invokeSuspendingFunctionback to summary
public static Publisher<?> invokeSuspendingFunction(kotlin.coroutines.CoroutineContext context, Method method, Object target, Object... args)

Invoke a suspending function and convert it to Mono or Flux.

Parameters
context:kotlin.coroutines.CoroutineContext

the coroutine context to use

method:Method

the suspending function to invoke

target:Object

the target to invoke method on

args:Object[]

the function arguments. If the Continuation argument is specified as the last argument (typically null), it is ignored.

Returns:Publisher<?>

the method invocation result as reactive stream

Annotations
@SuppressWarnings:deprecation
Exceptions
IllegalArgumentException:
if method is not a suspending function
Since
6.0
monoToDeferredback to summary
public static <T> kotlinx.coroutines.Deferred<T> monoToDeferred(Mono<T> source)

Convert a Mono instance to a Deferred.