@@ -236,6 +236,42 @@ open class BeanDefinitionDsl internal constructor (private val init: BeanDefinit
236236 context.registerBean(beanName, T ::class .java, Supplier { function.invoke(BeanSupplierContext (context)) }, customizer)
237237 }
238238
239+ /* *
240+ * Declare a bean definition using the given callable reference with no parameter
241+ * for obtaining a new instance.
242+ *
243+ * @param f the callable reference
244+ * @param name the name of the bean
245+ * @param scope Override the target scope of this bean, specifying a new scope name.
246+ * @param isLazyInit Set whether this bean should be lazily initialized.
247+ * @param isPrimary Set whether this bean is a primary autowire candidate.
248+ * @param isAutowireCandidate Set whether this bean is a candidate for getting
249+ * autowired into some other bean.
250+ * @param initMethodName Set the name of the initializer method
251+ * @param destroyMethodName Set the name of the destroy method
252+ * @param description Set a human-readable description of this bean definition
253+ * @param role Set the role hint for this bean definition
254+ * @see GenericApplicationContext.registerBean
255+ * @see org.springframework.beans.factory.config.BeanDefinition
256+ * @since 5.2.3
257+ */
258+ inline fun <reified T : Any >
259+ bean (crossinline f : () -> T ,
260+ name : String? = null,
261+ scope : BeanDefinitionDsl .Scope ? = null,
262+ isLazyInit : Boolean? = null,
263+ isPrimary : Boolean? = null,
264+ isAutowireCandidate : Boolean? = null,
265+ initMethodName : String? = null,
266+ destroyMethodName : String? = null,
267+ description : String? = null,
268+ role : BeanDefinitionDsl .Role ? = null) {
269+
270+ bean(name, scope, isLazyInit, isPrimary, isAutowireCandidate, initMethodName, destroyMethodName, description, role) {
271+ f.invoke()
272+ }
273+ }
274+
239275 /* *
240276 * Declare a bean definition using the given callable reference with 1 parameter
241277 * autowired by type for obtaining a new instance.
0 commit comments