Class BeanInstanceSupplier<T>

java.lang.Object
org.springframework.beans.factory.aot.BeanInstanceSupplier<T>
Type Parameters:
T - the type of instance supplied by this supplier
All Implemented Interfaces:
Supplier<T>, InstanceSupplier<T>, ThrowingSupplier<T>

public final class BeanInstanceSupplier<T> extends Object implements InstanceSupplier<T>
Specialized InstanceSupplier that provides the factory Method used to instantiate the underlying bean instance, if any. Transparently handles resolution of AutowiredArguments if necessary. Typically used in AOT-processed applications as a targeted alternative to the reflection based injection.

If no generator is provided, reflection is used to instantiate the bean instance, and full invocation hints are contributed. Multiple generator callback styles are supported:

  • A function with the registeredBean and resolved arguments for executables that require arguments resolution. An introspection hint is added so that parameter annotations can be read
  • A function with only the registeredBean for simpler cases that do not require resolution of arguments
  • A supplier when a method reference can be used
Generator callbacks handle checked exceptions so that the caller does not have to deal with them.
Since:
6.0
Author:
Phillip Webb, Stephane Nicoll, Juergen Hoeller
See Also: