|
//--------------------------------------------------------------------- |
|
// Convenient methods for registering individual beans |
|
//--------------------------------------------------------------------- |
|
|
|
/** |
|
* Register a bean from the given bean class, optionally customizing its |
|
* bean definition metadata (typically declared as a lambda expression |
|
* or method reference). |
|
* @param beanClass the class of the bean |
|
* @param customizers one or more callbacks for customizing the |
|
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag |
|
* @since 5.0 |
|
*/ |
|
public <T> void registerBean(Class<T> beanClass, BeanDefinitionCustomizer... customizers) { |
|
registerBean(null, beanClass, null, customizers); |
|
} |
|
|
|
/** |
|
* Register a bean from the given bean class, using the given supplier for |
|
* obtaining a new instance (typically declared as a lambda expression or |
|
* method reference), optionally customizing its bean definition metadata |
|
* (again typically declared as a lambda expression or method reference). |
|
* @param beanName the name of the bean (may be {@code null}) |
|
* @param beanClass the class of the bean |
|
* @param customizers one or more callbacks for customizing the |
|
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag |
|
* @since 5.0 |
|
*/ |
|
public <T> void registerBean(String beanName, Class<T> beanClass, BeanDefinitionCustomizer... customizers) { |
|
registerBean(beanName, beanClass, null, customizers); |
|
} |
|
|
|
/** |
|
* Register a bean from the given bean class, using the given supplier for |
|
* obtaining a new instance (typically declared as a lambda expression or |
|
* method reference), optionally customizing its bean definition metadata |
|
* (again typically declared as a lambda expression or method reference). |
|
* @param beanClass the class of the bean |
|
* @param supplier a callback for creating an instance of the bean |
|
* @param customizers one or more callbacks for customizing the |
|
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag |
|
* @since 5.0 |
|
*/ |
|
public <T> void registerBean(Class<T> beanClass, Supplier<T> supplier, BeanDefinitionCustomizer... customizers) { |
|
registerBean(null, beanClass, supplier, customizers); |
|
} |
|
|
|
/** |
|
* Register a bean from the given bean class, using the given supplier for |
|
* obtaining a new instance (typically declared as a lambda expression or |
|
* method reference), optionally customizing its bean definition metadata |
|
* (again typically declared as a lambda expression or method reference). |
|
* @param beanName the name of the bean (may be {@code null}) |
|
* @param beanClass the class of the bean |
|
* @param supplier a callback for creating an instance of the bean |
|
* @param customizers one or more callbacks for customizing the |
|
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag |
|
* @since 5.0 |
|
*/ |
|
public <T> void registerBean(String beanName, Class<T> beanClass, Supplier<T> supplier, |
Phil Webb opened SPR-15197 and commented
The current
registerBeanmethods added to support functional registration take abeanTypeclass.spring-framework/spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java
Lines 357 to 416 in cb0d992
I have a feeling that we may need to register beans that include generics. e.g.
Perhaps we should also offer
registerBeanvariants that take aResolvableType.Affects: 5.0 M4
Issue Links:
0 votes, 5 watchers