Class InstanceSupplierCodeGenerator
java.lang.Object
org.springframework.beans.factory.aot.InstanceSupplierCodeGenerator
Default code generator to create an
InstanceSupplier
, usually in
the form of a BeanInstanceSupplier
that retains the executable
that is used to instantiate the bean. Takes care of registering the
necessary hints if reflection or a JDK proxy is required.
Generated code is usually a method reference that generates the
BeanInstanceSupplier
, but some shortcut can be used as well such as:
InstanceSupplier.of(TheGeneratedClass::getMyBeanInstance);
- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll, Juergen Hoeller, Sebastien Deleuze
- See Also:
-
Constructor Summary
ConstructorDescriptionInstanceSupplierCodeGenerator
(GenerationContext generationContext, org.springframework.javapoet.ClassName className, GeneratedMethods generatedMethods, boolean allowDirectSupplierShortcut) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.CodeBlock
generateCode
(RegisteredBean registeredBean, Executable constructorOrFactoryMethod) Generate the instance supplier code.
-
Constructor Details
-
InstanceSupplierCodeGenerator
public InstanceSupplierCodeGenerator(GenerationContext generationContext, org.springframework.javapoet.ClassName className, GeneratedMethods generatedMethods, boolean allowDirectSupplierShortcut) Create a new instance.- Parameters:
generationContext
- the generation contextclassName
- the class name of the bean to instantiategeneratedMethods
- the generated methodsallowDirectSupplierShortcut
- whether a direct supplier may be used rather than always needing anInstanceSupplier
-
-
Method Details
-
generateCode
public org.springframework.javapoet.CodeBlock generateCode(RegisteredBean registeredBean, Executable constructorOrFactoryMethod) Generate the instance supplier code.- Parameters:
registeredBean
- the bean to handleconstructorOrFactoryMethod
- the executable to use to create the bean- Returns:
- the generated code
-