Fix Kotlin bean DSL conditional handling

Issue: SPR-16412
This commit is contained in:
Sebastien Deleuze
2018-06-01 14:24:51 +02:00
parent 356bfe6e2e
commit b71d0eeec9
2 changed files with 18 additions and 12 deletions

View File

@@ -195,7 +195,7 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
autowireMode: Autowire = Autowire.NO,
isAutowireCandidate: Boolean? = null,
crossinline function: () -> T) {
val customizer = BeanDefinitionCustomizer { bd ->
scope?.let { bd.scope = scope.name.toLowerCase() }
isLazyInit?.let { bd.isLazyInit = isLazyInit }
@@ -255,9 +255,11 @@ open class BeanDefinitionDsl(private val init: BeanDefinitionDsl.() -> Unit,
*/
override fun initialize(context: GenericApplicationContext) {
this.context = context
for (child in children) {
child.initialize(context)
}
init()
for (child in children) {
if (child.condition.invoke(context.environment)) {
child.initialize(context)
}
}
}
}