Provided
Marks an action method parameter as being provided by the platform context rather than resolved from the blackboard.
Use this annotation to inject services, components, or other platform-managed objects into action methods. This is particularly useful in @State classes where you need access to the enclosing component or other services without making the state class non-static.
Example:
@EmbabelComponent
class ReservationFlow(
private val bookingService: BookingService,
) {
@State
data class CollectDetails(val customerId: String) {
@Action
fun confirm(
details: ReservationDetails, // From blackboard
@Provided flow: ReservationFlow, // From context
): ConfirmState {
return ConfirmState(flow.bookingService.reserve(details))
}
}
}Content copied to clipboard
The actual resolution is handled by a com.embabel.agent.api.annotation.support.ContextProvider implementation, which is typically provided by the runtime environment (e.g., Spring).