nfrankel
08/14/2017, 2:19 PMnfrankel
08/14/2017, 2:19 PMnfrankel
08/14/2017, 2:19 PMsdeleuze
08/14/2017, 2:19 PMnfrankel
08/14/2017, 2:20 PMsdeleuze
08/14/2017, 2:20 PMis the equivalent ofRoutes(ref(), ref())
(types are not required thanks to Kotlin type inference) whereRoutes(ref<UserHandler>(), ref<MessageSource>())
is a shortcut forref<UserHandler>()
. We may provide an alternative syntax for autowiring classes by constructor which is pretty common in Koltin.applicationContext.getBean(UserHandler::class.java)
sdeleuze
08/14/2017, 2:21 PMapplicationContext.getBean()
which will be deferred when the lambda will be executed by Springnfrankel
08/14/2017, 2:21 PMsdeleuze
08/14/2017, 2:22 PMsdeleuze
08/14/2017, 2:23 PMref()
syntax with Kotlin type inference could be weird, that's why I am thinking to an alternative syntax to autowire by type constructor parametersnfrankel
08/14/2017, 2:28 PMbeans()
is a BeanDefinitionDsl
but ref()
is a function of BeanDefinitionContext
an inner class of BeanDefinitionDsl
i cannot import ref()
nfrankel
08/14/2017, 2:28 PMsdeleuze
08/14/2017, 2:29 PMnfrankel
08/14/2017, 2:29 PMsdeleuze
08/14/2017, 2:29 PMnfrankel
08/14/2017, 2:30 PMfun beans() = beans {
bean("controller") {
WelcomeController(WelcomeService(ref<WelcomeRepository>()))
}
}
sdeleuze
08/14/2017, 2:30 PMWelcomeService
constructor, you should notsdeleuze
08/14/2017, 2:31 PMsdeleuze
08/14/2017, 2:31 PMsdeleuze
08/14/2017, 2:31 PMnfrankel
08/14/2017, 2:31 PMnfrankel
08/14/2017, 2:31 PMnfrankel
08/14/2017, 2:32 PMsdeleuze
08/14/2017, 2:33 PMnfrankel
08/14/2017, 2:33 PMsdeleuze
08/14/2017, 2:33 PMsdeleuze
08/14/2017, 2:33 PMWelcomeService(...)
is not the way we can support thatsdeleuze
08/14/2017, 2:34 PM