Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
jvmMain.assembly.RaptorLifecyclePlugin.kt Maven / Gradle / Ivy
package io.fluidsonic.raptor.lifecycle
import io.fluidsonic.raptor.*
import io.fluidsonic.raptor.di.*
import kotlin.coroutines.*
import kotlin.reflect.*
public object RaptorLifecyclePlugin : RaptorPluginWithConfiguration {
override fun RaptorPluginCompletionScope.complete(): RaptorLifecyclePluginConfiguration {
val component = componentRegistry.one(Keys.lifecycleComponent)
val serviceRegistrations = component.serviceRegistrations()
if (serviceRegistrations.isNotEmpty())
configure(RaptorDIPlugin) {
di {
for (registration in serviceRegistrations)
registration.install(this)
}
}
return RaptorLifecyclePluginConfiguration(
serviceControllers = serviceRegistrations.map { registration ->
RaptorServiceController(
diKey = registration.diKey,
name = registration.name,
)
}
)
}
override fun RaptorPluginInstallationScope.install() {
componentRegistry.register(Keys.lifecycleComponent, RaptorLifecycleComponent())
optional(RaptorDIPlugin) {
di {
provide { get().coroutineContext }
provide { context.lifecycle }
}
}
lifecycle {
onStart("service creations") { context.lifecycle.createServices() }
onStart("services", Int.MIN_VALUE + 1) { context.lifecycle.startServices() }
onStop("services", Int.MAX_VALUE) { context.lifecycle.stopServices() }
}
}
override fun toString(): String = "lifecycle"
}
@RaptorDsl
public val RaptorPluginScope.lifecycle: RaptorLifecycleComponent
get() = componentRegistry.oneOrNull(Keys.lifecycleComponent) ?: throw RaptorPluginNotInstalledException(RaptorLifecyclePlugin)
@RaptorDsl
public fun RaptorPluginScope.service(
name: String,
factory: RaptorDI.() -> Service,
): RaptorServiceComponent =
lifecycle.service(name = name, factory = factory)
@RaptorDsl
public inline fun RaptorPluginScope.service(
noinline factory: RaptorDI.() -> Service,
): RaptorServiceComponent =
service(name = Service::class.qualifiedName ?: "", factory = factory)
@JvmName("service0")
@RaptorDsl
public inline fun
RaptorPluginScope.service(
factory: KFunction0,
): RaptorServiceComponent =
service { factory() }
@JvmName("service1")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1,
>
RaptorPluginScope.service(
factory: KFunction1,
): RaptorServiceComponent =
service { factory(get()) }
@JvmName("service2")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2,
>
RaptorPluginScope.service(
factory: KFunction2,
): RaptorServiceComponent =
service { factory(get(), get()) }
@JvmName("service3")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3,
>
RaptorPluginScope.service(
factory: KFunction3,
): RaptorServiceComponent =
service { factory(get(), get(), get()) }
@JvmName("service4")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4,
>
RaptorPluginScope.service(
factory: KFunction4,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get()) }
@JvmName("service5")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5,
>
RaptorPluginScope.service(
factory: KFunction5,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get()) }
@JvmName("service6")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6,
>
RaptorPluginScope.service(
factory: KFunction6,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get(), get()) }
@JvmName("service7")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7,
>
RaptorPluginScope.service(
factory: KFunction7,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get(), get(), get()) }
@JvmName("service8")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8,
>
RaptorPluginScope.service(
factory: KFunction8,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get(), get(), get(), get()) }
@JvmName("service9")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9,
>
RaptorPluginScope.service(
factory: KFunction9,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get(), get(), get(), get(), get()) }
@JvmName("service10")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
>
RaptorPluginScope.service(
factory: KFunction10,
): RaptorServiceComponent =
service { factory(get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) }
@JvmName("service11")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11,
>
RaptorPluginScope.service(
factory: KFunction11,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(),
)
}
@JvmName("service12")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12,
>
RaptorPluginScope.service(
factory: KFunction12,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(),
)
}
@JvmName("service13")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13,
>
RaptorPluginScope.service(
factory: KFunction13,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(),
)
}
@JvmName("service14")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14,
>
RaptorPluginScope.service(
factory: KFunction14,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(),
)
}
@JvmName("service15")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15,
>
RaptorPluginScope.service(
factory: KFunction15,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(),
)
}
@JvmName("service16")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15, reified A16,
>
RaptorPluginScope.service(
factory: KFunction16,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(), get(),
)
}
@JvmName("service17")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15, reified A16, reified A17,
>
RaptorPluginScope.service(
factory: KFunction17,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(), get(), get(),
)
}
@JvmName("service18")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15, reified A16, reified A17, reified A18,
>
RaptorPluginScope.service(
factory: KFunction18,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(), get(), get(), get(),
)
}
@JvmName("service19")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15, reified A16, reified A17, reified A18, reified A19,
>
RaptorPluginScope.service(
factory: KFunction19,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(), get(), get(), get(), get(),
)
}
@JvmName("service20")
@RaptorDsl
public inline fun
<
reified Service : RaptorService,
reified A1, reified A2, reified A3, reified A4, reified A5, reified A6, reified A7, reified A8, reified A9, reified A10,
reified A11, reified A12, reified A13, reified A14, reified A15, reified A16, reified A17, reified A18, reified A19, reified A20,
>
RaptorPluginScope.service(
factory: KFunction20,
): RaptorServiceComponent =
service {
factory(
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
)
}