Class BeanRegistrationCodeFragments
java.lang.Object
org.springframework.beans.factory.aot.BeanRegistrationCodeFragments
Class used to generate the various fragments of code needed to register a
bean.
- Since:
- 6.0
- Author:
- Phillip Webb
- See Also:
-
BeanRegistrationCodeFragmentsWrapperBeanRegistrationCodeFragmentsCustomizer
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBeanRegistrationCodeFragments(BeanRegistrationCodeFragments codeFragments) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.CodeBlockgenerateInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, Executable constructorOrFactoryMethod, boolean allowDirectSupplierShortcut) Generate the instance supplier code.org.springframework.javapoet.CodeBlockgenerateNewBeanDefinitionCode(GenerationContext generationContext, ResolvableType beanType, BeanRegistrationCode beanRegistrationCode) Generate the code that defines the new bean definition instance.org.springframework.javapoet.CodeBlockgenerateReturnCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) Generate the return statement.org.springframework.javapoet.CodeBlockgenerateSetBeanDefinitionPropertiesCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> attributeFilter) Generate the code that sets the properties of the bean definition.org.springframework.javapoet.CodeBlockgenerateSetBeanInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, org.springframework.javapoet.CodeBlock instanceSupplierCode, List<MethodReference> postProcessors) Generate the code that sets the instance supplier on the bean definition.Class<?>getTarget(RegisteredBean registeredBean, Executable constructorOrFactoryMethod) Return the target for the registration.
-
Field Details
-
BEAN_DEFINITION_VARIABLE
The variable name to used when creating the bean definition.- See Also:
-
INSTANCE_SUPPLIER_VARIABLE
The variable name to used when creating the bean definition.- See Also:
-
-
Constructor Details
-
BeanRegistrationCodeFragments
-
-
Method Details
-
getTarget
Return the target for the registration. Used to determine where to write the code.- Parameters:
registeredBean- the registered beanconstructorOrFactoryMethod- the constructor or factory method- Returns:
- the target class
-
generateNewBeanDefinitionCode
public org.springframework.javapoet.CodeBlock generateNewBeanDefinitionCode(GenerationContext generationContext, ResolvableType beanType, BeanRegistrationCode beanRegistrationCode) Generate the code that defines the new bean definition instance.- Parameters:
generationContext- the generation contextbeanType- the bean typebeanRegistrationCode- the bean registration code- Returns:
- the generated code
-
generateSetBeanDefinitionPropertiesCode
public org.springframework.javapoet.CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> attributeFilter) Generate the code that sets the properties of the bean definition.- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration codeattributeFilter- any attribute filtering that should be applied- Returns:
- the generated code
-
generateSetBeanInstanceSupplierCode
public org.springframework.javapoet.CodeBlock generateSetBeanInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, org.springframework.javapoet.CodeBlock instanceSupplierCode, List<MethodReference> postProcessors) Generate the code that sets the instance supplier on the bean definition.- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration codeinstanceSupplierCode- the instance supplier code supplier codepostProcessors- any instance post processors that should be applied- Returns:
- the generated code
- See Also:
-
generateInstanceSupplierCode
public org.springframework.javapoet.CodeBlock generateInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, Executable constructorOrFactoryMethod, boolean allowDirectSupplierShortcut) Generate the instance supplier code.- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration codeconstructorOrFactoryMethod- the constructor or factory method for the beanallowDirectSupplierShortcut- if direct suppliers may be used rather than always needing anInstanceSupplier- Returns:
- the generated code
-
generateReturnCode
public org.springframework.javapoet.CodeBlock generateReturnCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) Generate the return statement.- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration code- Returns:
- the generated code
-