Class ReferencedMethodArgumentsResolver

java.lang.Object
org.apache.dubbo.config.spring6.beans.factory.aot.ReferencedMethodArgumentsResolver

public final class ReferencedMethodArgumentsResolver extends Object
Resolver used to support the autowiring of methods. Typically used in AOT-processed applications as a targeted alternative to the ReferenceAnnotationBeanPostProcessor.

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).

  • Method Details

    • forMethod

      public static ReferencedMethodArgumentsResolver forMethod(String methodName, Class<?>... parameterTypes)
      Create a new ReferencedMethodArgumentsResolver for the specified method where injection is optional.
      Parameters:
      methodName - the method name
      parameterTypes - the factory method parameter types
      Returns:
      a new AutowiredFieldValueResolver instance
    • forRequiredMethod

      public static ReferencedMethodArgumentsResolver forRequiredMethod(String methodName, Class<?>... parameterTypes)
      Create a new ReferencedMethodArgumentsResolver for the specified method where injection is required.
      Parameters:
      methodName - the method name
      parameterTypes - the factory method parameter types
      Returns:
      a new AutowiredFieldValueResolver instance
    • withShortcut

      public ReferencedMethodArgumentsResolver withShortcut(String... beanNames)
      Return a new ReferencedMethodArgumentsResolver 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 ReferencedMethodArgumentsResolver instance that uses the shortcuts
    • resolve

      public void resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean, org.springframework.util.function.ThrowingConsumer<org.springframework.beans.factory.aot.AutowiredArguments> action)
      Resolve the method arguments for the specified registered bean and provide it to the given action.
      Parameters:
      registeredBean - the registered bean
      action - the action to execute with the resolved method arguments
    • resolve

      @Nullable public org.springframework.beans.factory.aot.AutowiredArguments resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean)
      Resolve the method arguments for the specified registered bean.
      Parameters:
      registeredBean - the registered bean
      Returns:
      the resolved method arguments
    • resolveAndInvoke

      public void resolveAndInvoke(org.springframework.beans.factory.support.RegisteredBean registeredBean, Object instance)
      Resolve the method arguments for the specified registered bean and invoke the method using reflection.
      Parameters:
      registeredBean - the registered bean
      instance - the bean instance