CoroutineModelProcessor

@Provider
class CoroutineModelProcessor @Inject constructor(val injectionManager: InjectionManager, val asyncContextProvider: Provider<AsyncContext>) : ModelProcessor

Jersey ModelProcessor that finds resource methods that are implemented with a suspend function, and redefines them with a dynamically created non-suspend function. That dynamically created implementation will then use the CoroutineInvocationHandler to invoke the suspend function.

Constructors

Link copied to clipboard
@Inject
fun CoroutineModelProcessor(injectionManager: InjectionManager, asyncContextProvider: Provider<AsyncContext>)

Functions

Link copied to clipboard
private fun buildCoroutineReplacedResource(resource: Resource): Resource

Replace any suspend function (ie, function whose last param is a Continuation) with a dynamically created non-suspend implementation

Link copied to clipboard
private fun createClassWrapper(method: ResourceMethod): Class<*>
Link copied to clipboard
private fun getContinuationTypeParameter(continuationType: Type): Type

Extract the type parameter from the continuation Type to be used as the return value for the generated function. Special case Unit->void conversion to correctly generate a void method instead of an Object/Unit returning method

Link copied to clipboard
open override fun processResourceModel(resourceModel: ResourceModel, configuration: Configuration): ResourceModel

Go though every child resource in the resourceModel and replace any coroutine resource methods found

Link copied to clipboard
open override fun processSubResource(subResourceModel: ResourceModel, configuration: Configuration): ResourceModel

Go though every child resource in the subResourceModel and replace any coroutine resource methods found

Properties

Link copied to clipboard
private val asyncContextProvider: Provider<AsyncContext>
Link copied to clipboard
private val injectionManager: InjectionManager