A default implementation is provided that suits most needs and custom code fragments are only expected to be used by library authors having built custom arrangement on top of the core container.
Users are not expected to implement this interface directly, but rather extends
from BeanRegistrationCodeFragmentsDecorator and only override the
necessary method(s).
BeanRegistrationCodeFragmentsDecorator, BeanRegistrationAotContribution#withCustomCodeFragments(UnaryOperator)
| Modifier and Type | Field and Description |
|---|---|
| public static final String | BEAN_DEFINITION_VARIABLE
The variable name to used when creating the bean definition. |
| public static final String | INSTANCE_SUPPLIER_VARIABLE
The variable name to used when creating the bean definition. |
| Modifier and Type | Method and Description |
|---|---|
| public CodeBlock | Returns: the generated codethe generation context generationContext, BeanRegistrationCode the bean registration code beanRegistrationCode, boolean if direct suppliers may be used rather
than always needing an allowDirectSupplierShortcut)InstanceSupplierGenerate the instance supplier code. |
| public CodeBlock | Returns: the generated codethe generation context generationContext, ResolvableType the bean type beanType, BeanRegistrationCode the bean registration code beanRegistrationCode)Generate the code that defines the new bean definition instance. |
| public CodeBlock | Returns: the generated codethe generation context generationContext, BeanRegistrationCode the bean registration code beanRegistrationCode)Generate the return statement. |
| public CodeBlock | Returns: the generated codethe generation context generationContext, BeanRegistrationCode the bean registration code beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> any attribute filtering that should be applied attributeFilter)Generate the code that sets the properties of the bean definition. |
| public CodeBlock | Returns: the generated codethe 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)Generate the code that sets the instance supplier on the bean definition. |
| public ClassName | Returns: the targetClassNamethe registered bean registeredBean)Return the target for the registration. |
| BEAN_DEFINITION_VARIABLE | back to summary |
|---|---|
| public static final String BEAN_DEFINITION_VARIABLE The variable name to used when creating the bean definition. | |
| INSTANCE_SUPPLIER_VARIABLE | back to summary |
|---|---|
| public static final String INSTANCE_SUPPLIER_VARIABLE The variable name to used when creating the bean definition. | |
| generateInstanceSupplierCode | back to summary |
|---|---|
| public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut) Generate the instance supplier code.
| |
| generateNewBeanDefinitionCode | back to summary |
|---|---|
| public CodeBlock generateNewBeanDefinitionCode(GenerationContext generationContext, ResolvableType beanType, BeanRegistrationCode beanRegistrationCode) 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.
| |
| generateReturnCode | back to summary |
|---|---|
| public CodeBlock generateReturnCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) Generate the return statement.
| |
| generateSetBeanDefinitionPropertiesCode | back to summary |
|---|---|
| public CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition, Predicate<String> attributeFilter) Generate the code that sets the properties of the bean definition.
| |
| generateSetBeanInstanceSupplierCode | back to summary |
|---|---|
| public CodeBlock generateSetBeanInstanceSupplierCode(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode, CodeBlock instanceSupplierCode, List<MethodReference> postProcessors) Generate the code that sets the instance supplier on the bean definition.
The
| |
| getTarget | back to summary |
|---|---|
| public ClassName getTarget(RegisteredBean registeredBean) 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.
| |