Class AutowiredMethodArgumentsResolver
java.lang.Object
org.springframework.beans.factory.aot.AutowiredMethodArgumentsResolver
Resolver used to support the autowiring of methods. Typically used in
AOT-processed applications as a targeted alternative to the
AutowiredAnnotationBeanPostProcessor
.
When resolving arguments in a native image, the Method
being used
must be marked with an introspection
hint
so that field annotations can be read. Full invocation
hints are only required if the
resolveAndInvoke(RegisteredBean, Object)
method of this class is
being used (typically to support private methods).
- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll
-
Method Summary
Modifier and TypeMethodDescriptionCreate a newAutowiredMethodArgumentsResolver
for the specified method where injection is optional.forRequiredMethod
(String methodName, Class<?>... parameterTypes) Create a newAutowiredMethodArgumentsResolver
for the specified method where injection is required.protected final void
registerDependentBeans
(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames) resolve
(RegisteredBean registeredBean) Resolve the method arguments for the specified registered bean.void
resolve
(RegisteredBean registeredBean, ThrowingConsumer<AutowiredArguments> action) Resolve the method arguments for the specified registered bean and provide it to the given action.void
resolveAndInvoke
(RegisteredBean registeredBean, Object instance) Resolve the method arguments for the specified registered bean and invoke the method using reflection.withShortcut
(String... beanNames) Return a newAutowiredInstantiationArgumentsResolver
instance that uses direct bean name injection shortcuts for specific parameters.
-
Method Details
-
forMethod
public static AutowiredMethodArgumentsResolver forMethod(String methodName, Class<?>... parameterTypes) Create a newAutowiredMethodArgumentsResolver
for the specified method where injection is optional.- Parameters:
methodName
- the method nameparameterTypes
- the factory method parameter types- Returns:
- a new
AutowiredFieldValueResolver
instance
-
forRequiredMethod
public static AutowiredMethodArgumentsResolver forRequiredMethod(String methodName, Class<?>... parameterTypes) Create a newAutowiredMethodArgumentsResolver
for the specified method where injection is required.- Parameters:
methodName
- the method nameparameterTypes
- the factory method parameter types- Returns:
- a new
AutowiredFieldValueResolver
instance
-
withShortcut
Return a newAutowiredInstantiationArgumentsResolver
instance that uses direct bean name injection shortcuts for specific parameters.- Parameters:
beanNames
- the bean names to use as shortcuts (aligned with the method parameters)- Returns:
- a new
AutowiredMethodArgumentsResolver
instance that uses the shortcuts
-
resolve
Resolve the method arguments for the specified registered bean and provide it to the given action.- Parameters:
registeredBean
- the registered beanaction
- the action to execute with the resolved method arguments
-
resolve
Resolve the method arguments for the specified registered bean.- Parameters:
registeredBean
- the registered bean- Returns:
- the resolved method arguments
-
resolveAndInvoke
Resolve the method arguments for the specified registered bean and invoke the method using reflection.- Parameters:
registeredBean
- the registered beaninstance
- the bean instance
-
registerDependentBeans
protected final void registerDependentBeans(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames)
-