SpringContextProvider

class SpringContextProvider(applicationContext: <Error class: unknown class>) : ContextProvider

Spring implementation of ContextProvider that retrieves objects from the Spring ApplicationContext.

This enables injection of Spring beans into action methods using the com.embabel.agent.api.annotation.Provided annotation.

Example:

@State
data class MyState(val data: String) {
@Action
fun process(@Provided myService: MyService): NextState {
return NextState(myService.transform(data))
}
}

Parameters

applicationContext

the Spring application context to retrieve beans from

See also

Constructors

Link copied to clipboard
constructor(applicationContext: <Error class: unknown class>)

Functions

Link copied to clipboard
open override fun <T : Any> getFromContext(type: Class<T>): T?

Retrieve an object of the specified type from the context.

Link copied to clipboard
open override fun hasInContext(type: Class<*>): Boolean

Check if an object of the specified type is available in the context.