Class AutowiredInstantiationArgumentsResolver
java.lang.Object
org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver
Resolver used to support the autowiring of constructors or factory methods.
Typically used in AOT-processed applications as a targeted alternative to the
reflection based injection.
When resolving arguments in a native image, the Constructor or
Method being used must be marked with an
introspection hint so that parameter
annotations can be read. Full invocation hints
are only required if the resolveAndInstantiate methods of this class
are being used (typically to support private constructors, methods or
classes).
- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionforConstructor(Class<?>... parameterTypes) Create aAutowiredInstantiationArgumentsResolverthat resolves arguments for the specified bean constructor.forFactoryMethod(Class<?> declaringClass, String methodName, Class<?>... parameterTypes) Create a newAutowiredInstantiationArgumentsResolverthat resolves arguments for the specified factory method.protected final voidregisterDependentBeans(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames) resolve(RegisteredBean registeredBean) Resolve arguments for the specified registered bean.<T> Tresolve(RegisteredBean registeredBean, ThrowingFunction<AutowiredArguments, T> generator) Resolve arguments for the specified registered bean and provide them to the given generator in order to return a result.<T> TresolveAndInstantiate(RegisteredBean registeredBean) Resolve arguments for the specified registered bean and instantiate a new instance using reflection.<T> TresolveAndInstantiate(RegisteredBean registeredBean, Class<T> requiredType) Resolve arguments for the specified registered bean and instantiate a new instance using reflection.withShortcuts(String... beanNames) Return a newAutowiredInstantiationArgumentsResolverinstance that uses direct bean name injection shortcuts for specific parameters.
-
Method Details
-
forConstructor
Create aAutowiredInstantiationArgumentsResolverthat resolves arguments for the specified bean constructor.- Parameters:
parameterTypes- the constructor parameter types- Returns:
- a new
AutowiredInstantiationArgumentsResolverinstance
-
forFactoryMethod
public static AutowiredInstantiationArgumentsResolver forFactoryMethod(Class<?> declaringClass, String methodName, Class<?>... parameterTypes) Create a newAutowiredInstantiationArgumentsResolverthat resolves arguments for the specified factory method.- Parameters:
declaringClass- the class that declares the factory methodmethodName- the factory method nameparameterTypes- the factory method parameter types- Returns:
- a new
AutowiredInstantiationArgumentsResolverinstance
-
withShortcuts
Return a newAutowiredInstantiationArgumentsResolverinstance that uses direct bean name injection shortcuts for specific parameters.- Parameters:
beanNames- the bean names to use as shortcuts (aligned with the constructor or factory method parameters)- Returns:
- a new
AutowiredInstantiationArgumentsResolverinstance that uses the shortcuts
-
resolve
public <T> T resolve(RegisteredBean registeredBean, ThrowingFunction<AutowiredArguments, T> generator) Resolve arguments for the specified registered bean and provide them to the given generator in order to return a result.- Parameters:
registeredBean- the registered beangenerator- the generator to execute with the resolved constructor or factory method arguments
-
resolve
Resolve arguments for the specified registered bean.- Parameters:
registeredBean- the registered bean- Returns:
- the resolved constructor or factory method arguments
-
resolveAndInstantiate
Resolve arguments for the specified registered bean and instantiate a new instance using reflection.- Parameters:
registeredBean- the registered bean- Returns:
- an instance of the bean
-
resolveAndInstantiate
Resolve arguments for the specified registered bean and instantiate a new instance using reflection.- Parameters:
registeredBean- the registered beanrequiredType- the required result type- Returns:
- an instance of the bean
-
registerDependentBeans
protected final void registerDependentBeans(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames)
-