BeanRegistrarDsl
Contract for registering programmatically beans.
Typically imported with an @Import annotation on @Configuration classes.
@Configuration
@Import(MyBeanRegistrar::class)
class MyConfiguration {
}Content copied to clipboard
In Kotlin, a bean registrar is typically created with a BeanRegistrarDsl to register beans programmatically in a concise and flexible way.
class MyBeanRegistrar : BeanRegistrarDsl({
registerBean<Foo>()
registerBean(
name = "bar",
prototype = true,
lazyInit = true,
description = "Custom description") {
Bar(bean<Foo>())
}
profile("baz") {
registerBean { Baz("Hello World!") }
}
})Content copied to clipboard
Author
Sebastien Deleuze
Since
7.0
Types
Properties
Functions
Link copied to clipboard
Apply the nested block if the given profile expression matches the active profiles.
Link copied to clipboard
Register beans using the given BeanRegistrar.
Link copied to clipboard
inline fun <T : Any> registerBean(autowirable: Boolean = true, backgroundInit: Boolean = false, description: String? = null, fallback: Boolean = false, infrastructure: Boolean = false, lazyInit: Boolean = false, order: Int? = null, primary: Boolean = false, prototype: Boolean = false): String
inline fun <T : Any> registerBean(name: String, autowirable: Boolean = true, backgroundInit: Boolean = false, description: String? = null, fallback: Boolean = false, infrastructure: Boolean = false, lazyInit: Boolean = false, order: Int? = null, primary: Boolean = false, prototype: Boolean = false)
Register a bean from the given bean class, which will be instantiated using the related resolvable constructor if any.
inline fun <T : Any> registerBean(autowirable: Boolean = true, backgroundInit: Boolean = false, description: String? = null, fallback: Boolean = false, infrastructure: Boolean = false, lazyInit: Boolean = false, order: Int? = null, primary: Boolean = false, prototype: Boolean = false, crossinline supplier: BeanRegistrarDsl.SupplierContextDsl<T>.() -> T): String
inline fun <T : Any> registerBean(name: String, autowirable: Boolean = true, backgroundInit: Boolean = false, description: String? = null, fallback: Boolean = false, infrastructure: Boolean = false, lazyInit: Boolean = false, order: Int? = null, primary: Boolean = false, prototype: Boolean = false, crossinline supplier: BeanRegistrarDsl.SupplierContextDsl<T>.() -> T)
Register a bean from the given bean class, which will be instantiated using the provided supplier.