Top Description Fields Constructors Methods
org.springframework.beans.factory.aot

public Class BeanRegistrationCodeFragmentsDecorator

extends Object
implements BeanRegistrationCodeFragments
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.aot.BeanRegistrationCodeFragments
Imports
java.util.List, java.util.function.Predicate, .UnaryOperator, org.springframework.aot.generate.GenerationContext, .MethodReference, org.springframework.beans.factory.support.RegisteredBean, .RootBeanDefinition, org.springframework.core.ResolvableType, org.springframework.javapoet.ClassName, .CodeBlock, org.springframework.util.Assert

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).
Authors
Phillip Webb, Stephane Nicoll
Since
6.0

Field Summary

Modifier and TypeField and Description
private final BeanRegistrationCodeFragments

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public CodeBlock
generateInstanceSupplierCode(GenerationContext
the generation context
generationContext
,
BeanRegistrationCode
the bean registration code
beanRegistrationCode
,
boolean
if direct suppliers may be used rather than always needing an InstanceSupplier
allowDirectSupplierShortcut
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateInstanceSupplierCode.

Generate the instance supplier code.

public CodeBlock
generateNewBeanDefinitionCode(GenerationContext
the generation context
generationContext
,
ResolvableType
the bean type
beanType
,
BeanRegistrationCode
the bean registration code
beanRegistrationCode
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateNewBeanDefinitionCode.

Generate the code that defines the new bean definition instance.

public CodeBlock
generateReturnCode(GenerationContext
the generation context
generationContext
,
BeanRegistrationCode
the bean registration code
beanRegistrationCode
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateReturnCode.

Generate the return statement.

public CodeBlock
generateSetBeanDefinitionPropertiesCode(GenerationContext
the generation context
generationContext
,
BeanRegistrationCode
the bean registration code
beanRegistrationCode
,
RootBeanDefinition beanDefinition, Predicate<String>
any attribute filtering that should be applied
attributeFilter
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode.

Generate the code that sets the properties of the bean definition.

public CodeBlock
generateSetBeanInstanceSupplierCode(GenerationContext
the generation context
generationContext
,
BeanRegistrationCode
the bean registration code
beanRegistrationCode
,
CodeBlock
the instance supplier code supplier code
instanceSupplierCode
,
List<MethodReference>
any instance post processors that should be applied
postProcessors
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanInstanceSupplierCode.

Generate the code that sets the instance supplier on the bean definition.

public ClassName
getTarget(RegisteredBean
the registered bean
registeredBean
)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.getTarget.

Return the target for the registration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final BeanRegistrationCodeFragments delegate

Constructor Detail

BeanRegistrationCodeFragmentsDecoratorback to summary
protected BeanRegistrationCodeFragmentsDecorator(BeanRegistrationCodeFragments delegate)

Method Detail

generateInstanceSupplierCodeback to summary
public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateInstanceSupplierCode.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateInstanceSupplierCode.

Generate the instance supplier code.

Parameters
generationContext:GenerationContext

the generation context

beanRegistrationCode:BeanRegistrationCode

the bean registration code

allowDirectSupplierShortcut:boolean

if direct suppliers may be used rather than always needing an InstanceSupplier

Returns:CodeBlock

the generated code

Annotations
@Override
generateNewBeanDefinitionCodeback to summary
public CodeBlock generateNewBeanDefinitionCode(GenerationContext generationContext, ResolvableType beanType, BeanRegistrationCode beanRegistrationCode)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateNewBeanDefinitionCode.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateNewBeanDefinitionCode.

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.

Parameters
generationContext:GenerationContext

the generation context

beanType:ResolvableType

the bean type

beanRegistrationCode:BeanRegistrationCode

the bean registration code

Returns:CodeBlock

the generated code

Annotations
@Override
generateReturnCodeback to summary
public CodeBlock generateReturnCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateReturnCode.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateReturnCode.

Generate the return statement.

Parameters
generationContext:GenerationContext

the generation context

beanRegistrationCode:BeanRegistrationCode

the bean registration code

Returns:CodeBlock

the generated code

Annotations
@Override
generateSetBeanDefinitionPropertiesCodeback to summary
public CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> attributeFilter)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode.

Generate the code that sets the properties of the bean definition.

Parameters
generationContext:GenerationContext

the generation context

beanRegistrationCode:BeanRegistrationCode

the bean registration code

attributeFilter:Predicate<String>

any attribute filtering that should be applied

Returns:CodeBlock

the generated code

Annotations
@Override
generateSetBeanInstanceSupplierCodeback to summary
public CodeBlock generateSetBeanInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, CodeBlock instanceSupplierCode, List<MethodReference> postProcessors)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanInstanceSupplierCode.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.generateSetBeanInstanceSupplierCode.

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.

Parameters
generationContext:GenerationContext

the generation context

beanRegistrationCode:BeanRegistrationCode

the bean registration code

instanceSupplierCode:CodeBlock

the instance supplier code supplier code

postProcessors:List<MethodReference>

any instance post processors that should be applied

Returns:CodeBlock

the generated code

Annotations
@Override
getTargetback to summary
public ClassName getTarget(RegisteredBean registeredBean)

Implements org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.getTarget.

Doc from org.springframework.beans.factory.aot.BeanRegistrationCodeFragments.getTarget.

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.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:ClassName

the target ClassName

Annotations
@Override