spring-framework / org.springframework.context.support / BeanDefinitionDsl

BeanDefinitionDsl

open class BeanDefinitionDsl : ApplicationContextInitializer<GenericApplicationContext>

Class implementing functional bean definition Kotlin DSL.

Types

BeanSupplierContext

open class BeanSupplierContext

Limit access to ref() and provider() to bean supplier lambdas.

Role

enum class Role

Role enum constants.

Scope

enum class Scope

Scope enum constants.

Constructors

<init>

BeanDefinitionDsl(init: BeanDefinitionDsl.() -> Unit, condition: (ConfigurableEnvironment) -> Boolean = { true })

Create a new bean definition DSL.

Properties

env

val env: ConfigurableEnvironment

Shortcut for context.environment

Functions

bean

fun <T : Any> bean(name: String? = null, scope: BeanDefinitionDsl.Scope? = null, isLazyInit: Boolean? = null, isPrimary: Boolean? = null, isAutowireCandidate: Boolean? = null, initMethodName: String? = null, destroyMethodName: String? = null, description: String? = null, role: BeanDefinitionDsl.Role? = null): Unit

Declare a bean definition from the given bean class which can be inferred when possible.

fun <T : Any> bean(name: String? = null, scope: BeanDefinitionDsl.Scope? = null, isLazyInit: Boolean? = null, isPrimary: Boolean? = null, isAutowireCandidate: Boolean? = null, initMethodName: String? = null, destroyMethodName: String? = null, description: String? = null, role: BeanDefinitionDsl.Role? = null, function: BeanDefinitionDsl.BeanSupplierContext.() -> T): Unit

Declare a bean definition using the given supplier for obtaining a new instance.

environment

fun environment(condition: ConfigurableEnvironment.() -> Boolean, init: BeanDefinitionDsl.() -> Unit): Unit

Take in account bean definitions enclosed in the provided lambda only when the specified environment-based predicate is true.

initialize

open fun initialize(context: GenericApplicationContext): Unit

Register the bean defined via the DSL on the provided application context.

profile

fun profile(profile: String, init: BeanDefinitionDsl.() -> Unit): Unit

Take in account bean definitions enclosed in the provided lambda only when the specified profile is active.