Class ReferencedFieldValueResolver
java.lang.Object
org.apache.dubbo.config.spring6.beans.factory.aot.ReferencedFieldValueResolver
Resolver used to support the autowiring of fields. Typically used in
AOT-processed applications as a targeted alternative to the
ReferenceAnnotationBeanPostProcessor.
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).
-
Method Summary
Modifier and TypeMethodDescriptionstatic ReferencedFieldValueResolverCreate a newReferencedFieldValueResolverfor the specified field where injection is optional.static ReferencedFieldValueResolverforRequiredField(String fieldName) Create a newReferencedFieldValueResolverfor the specified field where injection is required.<T> Tresolve(org.springframework.beans.factory.support.RegisteredBean registeredBean) Resolve the field value for the specified registered bean.<T> Tresolve(org.springframework.beans.factory.support.RegisteredBean registeredBean, Class<T> requiredType) Resolve the field value for the specified registered bean.<T> voidresolve(org.springframework.beans.factory.support.RegisteredBean registeredBean, org.springframework.util.function.ThrowingConsumer<T> action) Resolve the field for the specified registered bean and provide it to the given action.voidresolveAndSet(org.springframework.beans.factory.support.RegisteredBean registeredBean, Object instance) Resolve the field value for the specified registered bean and set it using reflection.resolveObject(org.springframework.beans.factory.support.RegisteredBean registeredBean) Resolve the field value for the specified registered bean.withShortcut(String beanName) Return a newReferencedFieldValueResolverinstance that uses a direct bean name injection shortcut.
-
Method Details
-
forField
Create a newReferencedFieldValueResolverfor the specified field where injection is optional.- Parameters:
fieldName- the field name- Returns:
- a new
ReferencedFieldValueResolverinstance
-
forRequiredField
Create a newReferencedFieldValueResolverfor the specified field where injection is required.- Parameters:
fieldName- the field name- Returns:
- a new
ReferencedFieldValueResolverinstance
-
withShortcut
Return a newReferencedFieldValueResolverinstance that uses a direct bean name injection shortcut.- Parameters:
beanName- the bean name to use as a shortcut- Returns:
- a new
ReferencedFieldValueResolverinstance that uses the shortcuts
-
resolve
public <T> void resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean, org.springframework.util.function.ThrowingConsumer<T> action) 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
@Nullable public <T> T resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean, Class<T> requiredType) Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered beanrequiredType- the required type- Returns:
- the resolved field value
-
resolve
@Nullable public <T> T resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean) Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered bean- Returns:
- the resolved field value
-
resolveObject
@Nullable public Object resolveObject(org.springframework.beans.factory.support.RegisteredBean registeredBean) Resolve the field value for the specified registered bean.- Parameters:
registeredBean- the registered bean- Returns:
- the resolved field value
-
resolveAndSet
public void resolveAndSet(org.springframework.beans.factory.support.RegisteredBean registeredBean, Object instance) Resolve the field value for the specified registered bean and set it using reflection.- Parameters:
registeredBean- the registered beaninstance- the bean instance
-