Current Kotlin bean DSL makes it possible to shoot yourself in the foot easily by allowing to write:
Which will trigger java.lang.IllegalStateException: [email protected]532cd8 has not been refreshed yet.
We should only expose ref() and provider() in the supplier responsible for providing the bean, since it will be call at the right time of the lifecycle.
We could maybe introduce some kind of BeanDefinitionContext:
And change crossinline function: () -> T to crossinline function: BeanDefinitionContext.() -> T in the bean supplier variant.
- We should maybe use this opportunity to provide direct access to ObjectProvider methods, expose Sequence instead of Stream, etc.
- We should maybe think about providing a router() variant that leverages this BeanDefinitionContext since this is a common use case.