Class BeanRegistryAdapter
java.lang.Object
org.springframework.beans.factory.support.BeanRegistryAdapter
- All Implemented Interfaces:
BeanRegistry
- Since:
- 7.0
- Author:
- Sebastien Deleuze
-
Nested Class Summary
Nested classes/interfaces inherited from interface BeanRegistry
BeanRegistry.Spec<T>, BeanRegistry.SupplierContext -
Constructor Summary
ConstructorsConstructorDescriptionBeanRegistryAdapter(BeanDefinitionRegistry beanRegistry, ListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass) BeanRegistryAdapter(BeanDefinitionRegistry beanRegistry, ListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass, @Nullable MultiValueMap<String, BeanDefinitionCustomizer> customizers) BeanRegistryAdapter(DefaultListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass) -
Method Summary
Modifier and TypeMethodDescriptionvoidregister(BeanRegistrar registrar) Register beans using the givenBeanRegistrar.voidregisterAlias(String name, String alias) Given a name, register an alias for it.<T> StringregisterBean(Class<T> beanClass) Register a bean from the given class, which will be instantiated using the relatedresolvable constructorif any.<T> StringregisterBean(Class<T> beanClass, Consumer<BeanRegistry.Spec<T>> customizer) Register a bean from the given class, customizing it with the customizer callback.<T> voidregisterBean(String name, Class<T> beanClass) Register a bean from the given class, which will be instantiated using the relatedresolvable constructorif any.<T> voidregisterBean(String name, Class<T> beanClass, Consumer<BeanRegistry.Spec<T>> customizer) Register a bean from the given class, customizing it with the customizer callback.<T> voidregisterBean(String name, ParameterizedTypeReference<T> beanType) Register a bean from the given generics-containing type, which will be instantiated using the relatedresolvable constructorif any.<T> voidregisterBean(String name, ParameterizedTypeReference<T> beanType, Consumer<BeanRegistry.Spec<T>> customizer) Register a bean from the given generics-containing type, customizing it with the customizer callback.<T> StringregisterBean(ParameterizedTypeReference<T> beanType) Register a bean from the given generics-containing type, which will be instantiated using the relatedresolvable constructorif any.<T> StringregisterBean(ParameterizedTypeReference<T> beanType, Consumer<BeanRegistry.Spec<T>> customizer) Register a bean from the given generics-containing type, customizing it with the customizer callback.
-
Constructor Details
-
BeanRegistryAdapter
public BeanRegistryAdapter(DefaultListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass) -
BeanRegistryAdapter
public BeanRegistryAdapter(BeanDefinitionRegistry beanRegistry, ListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass) -
BeanRegistryAdapter
public BeanRegistryAdapter(BeanDefinitionRegistry beanRegistry, ListableBeanFactory beanFactory, Environment environment, Class<? extends BeanRegistrar> beanRegistrarClass, @Nullable MultiValueMap<String, BeanDefinitionCustomizer> customizers)
-
-
Method Details
-
registerAlias
Description copied from interface:BeanRegistryGiven a name, register an alias for it.- Specified by:
registerAliasin interfaceBeanRegistry- Parameters:
name- the canonical namealias- the alias to be registered
-
registerBean
Description copied from interface:BeanRegistryRegister a bean from the given class, which will be instantiated using the relatedresolvable constructorif any.For registering a bean with a generic type, consider
BeanRegistry.registerBean(ParameterizedTypeReference).- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
beanClass- the class of the bean- Returns:
- the generated bean name
- See Also:
-
registerBean
Description copied from interface:BeanRegistryRegister a bean from the given generics-containing type, which will be instantiated using the relatedresolvable constructorif any.- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
beanType- the generics-containing type of the bean- Returns:
- the generated bean name
-
registerBean
Description copied from interface:BeanRegistryRegister a bean from the given class, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with itsresolvable constructorotherwise.For registering a bean with a generic type, consider
BeanRegistry.registerBean(ParameterizedTypeReference, Consumer).- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
beanClass- the class of the beancustomizer- the callback to customize other bean properties than the name- Returns:
- the generated bean name
-
registerBean
public <T> String registerBean(ParameterizedTypeReference<T> beanType, Consumer<BeanRegistry.Spec<T>> customizer) Description copied from interface:BeanRegistryRegister a bean from the given generics-containing type, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with itsresolvable constructorotherwise.- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
beanType- the generics-containing type of the beancustomizer- the callback to customize other bean properties than the name- Returns:
- the generated bean name
-
registerBean
Description copied from interface:BeanRegistryRegister a bean from the given class, which will be instantiated using the relatedresolvable constructorif any.For registering a bean with a generic type, consider
BeanRegistry.registerBean(String, ParameterizedTypeReference).- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
name- the name of the beanbeanClass- the class of the bean
-
registerBean
Description copied from interface:BeanRegistryRegister a bean from the given generics-containing type, which will be instantiated using the relatedresolvable constructorif any.- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
name- the name of the beanbeanType- the generics-containing type of the bean
-
registerBean
public <T> void registerBean(String name, Class<T> beanClass, Consumer<BeanRegistry.Spec<T>> customizer) Description copied from interface:BeanRegistryRegister a bean from the given class, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with itsresolvable constructorotherwise.For registering a bean with a generic type, consider
BeanRegistry.registerBean(String, ParameterizedTypeReference, Consumer).- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
name- the name of the beanbeanClass- the class of the beancustomizer- the callback to customize other bean properties than the name
-
registerBean
public <T> void registerBean(String name, ParameterizedTypeReference<T> beanType, Consumer<BeanRegistry.Spec<T>> customizer) Description copied from interface:BeanRegistryRegister a bean from the given generics-containing type, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with itsresolvable constructorotherwise.- Specified by:
registerBeanin interfaceBeanRegistry- Parameters:
name- the name of the beanbeanType- the generics-containing type of the beancustomizer- the callback to customize other bean properties than the name
-
register
Description copied from interface:BeanRegistryRegister beans using the givenBeanRegistrar.- Specified by:
registerin interfaceBeanRegistry- Parameters:
registrar- the bean registrar that will be called to register additional beans
-