Class BeanDefinitionRegistrar
java.lang.Object
org.springframework.beans.factory.generator.config.BeanDefinitionRegistrar
BeanDefinition
registration mechanism offering transparent
dependency resolution, as well as exception management.
Used by code generators and for internal use within the framework only.
- Since:
- 6.0
- Author:
- Stephane Nicoll
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Callback interface used by instance suppliers that need to resolve dependencies for theExecutable
used to create the instance as well as anyMember
that should be handled by the context.static interface
AConsumer
that allows to invoke code that throws a checked exception.static interface
AFunction
that allows to invoke code that throws a checked exception.static interface
ASupplier
that allows to invoke code that throws a checked exception. -
Method Summary
Modifier and TypeMethodDescriptionCustomize theRootBeanDefinition
using the specified consumer.static BeanDefinitionRegistrar
Initialize the registration of an inner bean with the specified type.static BeanDefinitionRegistrar
inner
(ResolvableType beanType) Initialize the registration of an inner bean with the specified type.instanceSupplier
(BeanDefinitionRegistrar.ThrowableFunction<BeanDefinitionRegistrar.BeanInstanceContext, ?> instanceContext) Specify how the bean instance should be created and initialized, using theBeanDefinitionRegistrar.BeanInstanceContext
to resolve dependencies if necessary.instanceSupplier
(BeanDefinitionRegistrar.ThrowableSupplier<?> instanceSupplier) Specify how the bean instance should be created and initialized.static BeanDefinitionRegistrar
Initialize the registration of a bean with the specified name and type.static BeanDefinitionRegistrar
of
(String beanName, ResolvableType beanType) Initialize the registration of a bean with the specified name and type.void
register
(DefaultListableBeanFactory beanFactory) Register theRootBeanDefinition
defined by this instance to the specified bean factory.Return theRootBeanDefinition
defined by this instance.withConstructor
(Class<?>... parameterTypes) Specify the constructor to use to instantiate the bean.withFactoryMethod
(Class<?> declaredType, String name, Class<?>... parameterTypes) Specify the factory method to use to instantiate the bean.
-
Method Details
-
of
Initialize the registration of a bean with the specified name and type.- Parameters:
beanName
- the name of the beanbeanType
- the type of the bean- Returns:
- a registrar for the specified bean
-
of
Initialize the registration of a bean with the specified name and type.- Parameters:
beanName
- the name of the beanbeanType
- the type of the bean- Returns:
- a registrar for the specified bean
-
inner
Initialize the registration of an inner bean with the specified type.- Parameters:
beanType
- the type of the inner bean- Returns:
- a registrar for the specified inner bean
-
inner
Initialize the registration of an inner bean with the specified type.- Parameters:
beanType
- the type of the inner bean- Returns:
- a registrar for the specified inner bean
-
withFactoryMethod
public BeanDefinitionRegistrar withFactoryMethod(Class<?> declaredType, String name, Class<?>... parameterTypes) Specify the factory method to use to instantiate the bean.- Parameters:
declaredType
- thedeclared type
of the factory method.name
- the name of the methodparameterTypes
- the parameter types of the method- Returns:
this
, to facilitate method chaining- See Also:
-
withConstructor
Specify the constructor to use to instantiate the bean.- Parameters:
parameterTypes
- the parameter types of the constructor- Returns:
this
, to facilitate method chaining
-
instanceSupplier
public BeanDefinitionRegistrar instanceSupplier(BeanDefinitionRegistrar.ThrowableFunction<BeanDefinitionRegistrar.BeanInstanceContext, ?> instanceContext) Specify how the bean instance should be created and initialized, using theBeanDefinitionRegistrar.BeanInstanceContext
to resolve dependencies if necessary.- Parameters:
instanceContext
- theBeanDefinitionRegistrar.BeanInstanceContext
to use- Returns:
this
, to facilitate method chaining
-
instanceSupplier
public BeanDefinitionRegistrar instanceSupplier(BeanDefinitionRegistrar.ThrowableSupplier<?> instanceSupplier) Specify how the bean instance should be created and initialized.- Returns:
this
, to facilitate method chaining
-
customize
public BeanDefinitionRegistrar customize(BeanDefinitionRegistrar.ThrowableConsumer<RootBeanDefinition> bd) Customize theRootBeanDefinition
using the specified consumer.- Parameters:
bd
- a consumer for the bean definition- Returns:
this
, to facilitate method chaining
-
register
Register theRootBeanDefinition
defined by this instance to the specified bean factory.- Parameters:
beanFactory
- the bean factory to use
-
toBeanDefinition
Return theRootBeanDefinition
defined by this instance.- Returns:
- the bean definition
-