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
  • Constructor Details

  • Method Details

    • getTarget

      public org.springframework.javapoet.ClassName getTarget(RegisteredBean registeredBean)
      Description copied from interface: BeanRegistrationCodeFragments
      Return 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:
      getTarget in interface BeanRegistrationCodeFragments
      Parameters:
      registeredBean - the registered bean
      Returns:
      the target ClassName
    • generateNewBeanDefinitionCode

      public org.springframework.javapoet.CodeBlock generateNewBeanDefinitionCode(org.springframework.aot.generate.GenerationContext generationContext, org.springframework.core.ResolvableType beanType, BeanRegistrationCode beanRegistrationCode)
      Description copied from interface: BeanRegistrationCodeFragments
      Generate 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:
      generateNewBeanDefinitionCode in interface BeanRegistrationCodeFragments
      Parameters:
      generationContext - the generation context
      beanType - the bean type
      beanRegistrationCode - the bean registration code
      Returns:
      the generated code
    • generateSetBeanDefinitionPropertiesCode

      public org.springframework.javapoet.CodeBlock generateSetBeanDefinitionPropertiesCode(org.springframework.aot.generate.GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> attributeFilter)
      Description copied from interface: BeanRegistrationCodeFragments
      Generate the code that sets the properties of the bean definition.
      Specified by:
      generateSetBeanDefinitionPropertiesCode in interface BeanRegistrationCodeFragments
      Parameters:
      generationContext - the generation context
      beanRegistrationCode - the bean registration code
      attributeFilter - any attribute filtering that should be applied
      Returns:
      the generated code
    • generateSetBeanInstanceSupplierCode

      public org.springframework.javapoet.CodeBlock generateSetBeanInstanceSupplierCode(org.springframework.aot.generate.GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, org.springframework.javapoet.CodeBlock instanceSupplierCode, List<org.springframework.aot.generate.MethodReference> postProcessors)
      Description copied from interface: BeanRegistrationCodeFragments
      Generate the code that sets the instance supplier on the bean definition.

      The postProcessors represent methods to be exposed once the instance has been created to further configure it. Each method should accept two parameters, the RegisteredBean and the bean instance, and should return the modified bean instance.

      Specified by:
      generateSetBeanInstanceSupplierCode in interface BeanRegistrationCodeFragments
      Parameters:
      generationContext - the generation context
      beanRegistrationCode - the bean registration code
      instanceSupplierCode - the instance supplier code supplier code
      postProcessors - any instance post processors that should be applied
      Returns:
      the generated code
      See Also:
    • generateInstanceSupplierCode

      public org.springframework.javapoet.CodeBlock generateInstanceSupplierCode(org.springframework.aot.generate.GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut)
      Description copied from interface: BeanRegistrationCodeFragments
      Generate the instance supplier code.
      Specified by:
      generateInstanceSupplierCode in interface BeanRegistrationCodeFragments
      Parameters:
      generationContext - the generation context
      beanRegistrationCode - the bean registration code
      allowDirectSupplierShortcut - if direct suppliers may be used rather than always needing an InstanceSupplier
      Returns:
      the generated code
    • generateReturnCode

      public org.springframework.javapoet.CodeBlock generateReturnCode(org.springframework.aot.generate.GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode)
      Description copied from interface: BeanRegistrationCodeFragments
      Generate the return statement.
      Specified by:
      generateReturnCode in interface BeanRegistrationCodeFragments
      Parameters:
      generationContext - the generation context
      beanRegistrationCode - the bean registration code
      Returns:
      the generated code