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
Nested ClassesModifier and TypeClassDescriptionfinal classCallback interface used by instance suppliers that need to resolve dependencies for theExecutableused to create the instance as well as anyMemberthat should be handled by the context.static interfaceAConsumerthat allows to invoke code that throws a checked exception.static interfaceAFunctionthat allows to invoke code that throws a checked exception.static interfaceASupplierthat allows to invoke code that throws a checked exception. -
Method Summary
Modifier and TypeMethodDescriptionCustomize theRootBeanDefinitionusing the specified consumer.static BeanDefinitionRegistrarInitialize the registration of an inner bean with the specified type.static BeanDefinitionRegistrarinner(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.BeanInstanceContextto resolve dependencies if necessary.instanceSupplier(BeanDefinitionRegistrar.ThrowableSupplier<?> instanceSupplier) Specify how the bean instance should be created and initialized.static BeanDefinitionRegistrarInitialize the registration of a bean with the specified name and type.static BeanDefinitionRegistrarof(String beanName, ResolvableType beanType) Initialize the registration of a bean with the specified name and type.voidregister(DefaultListableBeanFactory beanFactory) Register theRootBeanDefinitiondefined by this instance to the specified bean factory.Return theRootBeanDefinitiondefined 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 typeof 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.BeanInstanceContextto resolve dependencies if necessary.- Parameters:
instanceContext- theBeanDefinitionRegistrar.BeanInstanceContextto 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 theRootBeanDefinitionusing the specified consumer.- Parameters:
bd- a consumer for the bean definition- Returns:
this, to facilitate method chaining
-
register
Register theRootBeanDefinitiondefined by this instance to the specified bean factory.- Parameters:
beanFactory- the bean factory to use
-
toBeanDefinition
Return theRootBeanDefinitiondefined by this instance.- Returns:
- the bean definition
-