withBean

open fun <T> withBean(type: Class<T>, constructorArgs: Array<Any>): SELF

Register the specified user bean with the ApplicationContext. The bean name is generated from the configured BeanNameGenerator on the underlying context.

Such beans are registered after regular user configurations in the order of registration.

Return

a new instance with the updated bean

Parameters

type

the type of the bean

constructorArgs

custom argument values to be fed into Spring's constructorresolution algorithm, resolving either all arguments or just specific ones, withthe rest to be resolved through regular autowiring (may be null or empty)

<T>

the type of the bean


open fun <T> withBean(name: String, type: Class<T>, constructorArgs: Array<Any>): SELF

Register the specified user bean with the ApplicationContext.

Such beans are registered after regular user configurations in the order of registration.

Return

a new instance with the updated bean

Parameters

name

the bean name or null to use a generated name

type

the type of the bean

constructorArgs

custom argument values to be fed into Spring's constructorresolution algorithm, resolving either all arguments or just specific ones, withthe rest to be resolved through regular autowiring (may be null or empty)

<T>

the type of the bean


open fun <T> withBean(type: Class<T>, supplier: Supplier<T>, customizers: Array<BeanDefinitionCustomizer>): SELF

Register the specified user bean with the ApplicationContext. The bean name is generated from the configured BeanNameGenerator on the underlying context.

Such beans are registered after regular user configurations in the order of registration.

Return

a new instance with the updated bean

Parameters

type

the type of the bean

supplier

a supplier for the bean

customizers

one or more callbacks for customizing the factory's BeanDefinition, e.g. setting a lazy-init or primary flag

<T>

the type of the bean


open fun <T> withBean(name: String, type: Class<T>, supplier: Supplier<T>, customizers: Array<BeanDefinitionCustomizer>): SELF

Register the specified user bean with the ApplicationContext. The bean name is generated from the configured BeanNameGenerator on the underlying context.

Such beans are registered after regular user configurations in the order of registration.

Return

a new instance with the updated bean

Parameters

name

the bean name or null to use a generated name

type

the type of the bean

supplier

a supplier for the bean

customizers

one or more callbacks for customizing the factory's BeanDefinition, e.g. setting a lazy-init or primary flag

<T>

the type of the bean