Class BeanRegistrationCodeFragmentsDecorator
java.lang.Object
org.springframework.beans.factory.aot.BeanRegistrationCodeFragmentsDecorator
- All Implemented Interfaces:
BeanRegistrationCodeFragments
public class BeanRegistrationCodeFragmentsDecorator
extends Object
implements BeanRegistrationCodeFragments
A
BeanRegistrationCodeFragments decorator implementation. Typically
used when part of the default code fragments have to customized, by extending
this class and using it as part of
BeanRegistrationAotContribution.withCustomCodeFragments(UnaryOperator).- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.aot.BeanRegistrationCodeFragments
BEAN_DEFINITION_VARIABLE, INSTANCE_SUPPLIER_VARIABLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.CodeBlockgenerateInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, 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.org.springframework.javapoet.ClassNamegetTarget(RegisteredBean registeredBean) Return the target for the registration.
-
Constructor Details
-
BeanRegistrationCodeFragmentsDecorator
-
-
Method Details
-
getTarget
Description copied from interface:BeanRegistrationCodeFragmentsReturn the target for the registration. Used to determine where to write the code. This should take into account visibility issue, such as package access of an element of the bean to register.- Specified by:
getTargetin interfaceBeanRegistrationCodeFragments- Parameters:
registeredBean- the registered bean- Returns:
- the target
ClassName
-
generateNewBeanDefinitionCode
public org.springframework.javapoet.CodeBlock generateNewBeanDefinitionCode(GenerationContext generationContext, ResolvableType beanType, BeanRegistrationCode beanRegistrationCode) Description copied from interface:BeanRegistrationCodeFragmentsGenerate the code that defines the new bean definition instance.This should declare a variable named "beanDefinition" so that further fragments can refer to the variable to further tune the bean definition.
- Specified by:
generateNewBeanDefinitionCodein interfaceBeanRegistrationCodeFragments- 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) Description copied from interface:BeanRegistrationCodeFragmentsGenerate the code that sets the properties of the bean definition.- Specified by:
generateSetBeanDefinitionPropertiesCodein interfaceBeanRegistrationCodeFragments- 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) Description copied from interface:BeanRegistrationCodeFragmentsGenerate the code that sets the instance supplier on the bean definition.The
postProcessorsrepresent methods to be exposed once the instance has been created to further configure it. Each method should accept two parameters, theRegisteredBeanand the bean instance, and should return the modified bean instance.- Specified by:
generateSetBeanInstanceSupplierCodein interfaceBeanRegistrationCodeFragments- 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, boolean allowDirectSupplierShortcut) Description copied from interface:BeanRegistrationCodeFragmentsGenerate the instance supplier code.- Specified by:
generateInstanceSupplierCodein interfaceBeanRegistrationCodeFragments- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration codeallowDirectSupplierShortcut- 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) Description copied from interface:BeanRegistrationCodeFragmentsGenerate the return statement.- Specified by:
generateReturnCodein interfaceBeanRegistrationCodeFragments- Parameters:
generationContext- the generation contextbeanRegistrationCode- the bean registration code- Returns:
- the generated code
-