Class AutowiredFieldValueResolver
java.lang.Object
org.springframework.beans.factory.aot.AutowiredFieldValueResolver
Resolver used to support the autowiring of fields. Typically used in
AOT-processed applications as a targeted alternative to the
AutowiredAnnotationBeanPostProcessor.
When resolving arguments in a native image, the Field being used must
be marked with an introspection hint so
that field annotations can be read. Full invocation hints are only required if the
resolveAndSet(RegisteredBean, Object) method of this class is being
used (typically to support private fields).
- Since:
- 6.0
- Author:
- Phillip Webb, Stephane Nicoll
-
Method Summary
Modifier and TypeMethodDescriptionstatic AutowiredFieldValueResolverCreate a newAutowiredFieldValueResolverfor the specified field where injection is optional.static AutowiredFieldValueResolverforRequiredField(String fieldName) Create a newAutowiredFieldValueResolverfor the specified field where injection is required.protected final voidregisterDependentBeans(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames) <T> @Nullable Tresolve(RegisteredBean registeredBean) Resolve the field value for the specified registered bean.<T> @Nullable Tresolve(RegisteredBean registeredBean, Class<T> requiredType) Resolve the field value for the specified registered bean.<T> voidresolve(RegisteredBean registeredBean, ThrowingConsumer<T> action) Resolve the field for the specified registered bean and provide it to the given action.voidresolveAndSet(RegisteredBean registeredBean, Object instance) Resolve the field value for the specified registered bean and set it using reflection.resolveObject(RegisteredBean registeredBean) Resolve the field value for the specified registered bean.withShortcut(String beanName) Return a newAutowiredFieldValueResolverinstance that uses a direct bean name injection shortcut.
-
Method Details
-
forField
Create a newAutowiredFieldValueResolverfor the specified field where injection is optional.- Parameters:
fieldName- the field name- Returns:
- a new
AutowiredFieldValueResolverinstance
-
forRequiredField
Create a newAutowiredFieldValueResolverfor the specified field where injection is required.- Parameters:
fieldName- the field name- Returns:
- a new
AutowiredFieldValueResolverinstance
-
withShortcut
Return a newAutowiredFieldValueResolverinstance that uses a direct bean name injection shortcut.- Parameters:
beanName- the bean name to use as a shortcut- Returns:
- a new
AutowiredFieldValueResolverinstance that uses the given shortcut bean name
-
resolve
Resolve the field for the specified registered bean and provide it to the given action.- Parameters:
registeredBean- the registered beanaction- the action to execute with the resolved field value
-
resolve
Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered beanrequiredType- the required type- Returns:
- the resolved field value
-
resolve
Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered bean- Returns:
- the resolved field value
-
resolveObject
Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered bean- Returns:
- the resolved field value
-
resolveAndSet
Resolve the field value for the specified registered bean and set it using reflection.- Parameters:
registeredBean- the registered beaninstance- the bean instance
-
registerDependentBeans
protected final void registerDependentBeans(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames)
-