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 AutowiredFieldValueResolver
Create a newAutowiredFieldValueResolver
for the specified field where injection is optional.static AutowiredFieldValueResolver
forRequiredField
(String fieldName) Create a newAutowiredFieldValueResolver
for the specified field where injection is required.protected final void
registerDependentBeans
(ConfigurableBeanFactory beanFactory, String beanName, Set<String> autowiredBeanNames) <T> @Nullable T
resolve
(RegisteredBean registeredBean) Resolve the field value for the specified registered bean.<T> @Nullable T
resolve
(RegisteredBean registeredBean, Class<T> requiredType) Resolve the field value for the specified registered bean.<T> void
resolve
(RegisteredBean registeredBean, ThrowingConsumer<T> action) Resolve the field for the specified registered bean and provide it to the given action.void
resolveAndSet
(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 newAutowiredFieldValueResolver
instance that uses a direct bean name injection shortcut.
-
Method Details
-
forField
Create a newAutowiredFieldValueResolver
for the specified field where injection is optional.- Parameters:
fieldName
- the field name- Returns:
- a new
AutowiredFieldValueResolver
instance
-
forRequiredField
Create a newAutowiredFieldValueResolver
for the specified field where injection is required.- Parameters:
fieldName
- the field name- Returns:
- a new
AutowiredFieldValueResolver
instance
-
withShortcut
Return a newAutowiredFieldValueResolver
instance that uses a direct bean name injection shortcut.- Parameters:
beanName
- the bean name to use as a shortcut- Returns:
- a new
AutowiredFieldValueResolver
instance 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)
-