jvmMain.assembly.RaptorServiceRegistration.kt Maven / Gradle / Ivy
package io.fluidsonic.raptor.lifecycle
import io.fluidsonic.raptor.*
import io.fluidsonic.raptor.di.*
internal class RaptorServiceRegistration(
val factory: RaptorDI.() -> Service,
val name: String,
private val providedKeys: List>,
) : RaptorComponent.Base>(RaptorLifecyclePlugin) {
val diKey = ServiceDIKey(name)
fun install(di: RaptorDIComponent<*>) {
val diKey = diKey
di.provide(diKey, factory)
for (key in providedKeys)
di.provide(key) { get(diKey) }
}
}