Top Description Fields Constructors Methods
org.springframework.beans.factory.aot

public final Class AutowiredMethodArgumentsResolver

extends AutowiredElementResolver
Class Inheritance
Imports
java.lang.reflect.Method, java.util.Arrays, .LinkedHashSet, .Set, java.util.stream.Collectors, org.springframework.aot.hint.ExecutableMode, org.springframework.beans.BeansException, .TypeConverter, org.springframework.beans.factory.InjectionPoint, .UnsatisfiedDependencyException, org.springframework.beans.factory.config.AutowireCapableBeanFactory, .ConfigurableBeanFactory, .DependencyDescriptor, org.springframework.beans.factory.support.RegisteredBean, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ReflectionUtils, org.springframework.util.function.ThrowingConsumer

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

Authors
Phillip Webb, Stephane Nicoll
Since
6.0

Field Summary

Modifier and TypeField and Description
private final String
private final Class<?>[]
private final boolean
private final String[]

Constructor Summary

AccessConstructor and Description
private
AutowiredMethodArgumentsResolver(String methodName, Class<?>[] parameterTypes, boolean required, String[] shortcuts)

Method Summary

Modifier and TypeMethod and Description
public static AutowiredMethodArgumentsResolver

Returns:

a new AutowiredFieldValueResolver instance
forMethod
(String
the method name
methodName
,
Class<?>...
the factory method parameter types
parameterTypes
)

Create a new AutowiredMethodArgumentsResolver for the specified method where injection is optional.

public static AutowiredMethodArgumentsResolver

Returns:

a new AutowiredFieldValueResolver instance
forRequiredMethod
(String
the method name
methodName
,
Class<?>...
the factory method parameter types
parameterTypes
)

Create a new AutowiredMethodArgumentsResolver for the specified method where injection is required.

private Method
getMethod(RegisteredBean registeredBean)

public void
resolve(RegisteredBean
the registered bean
registeredBean
,
ThrowingConsumer<AutowiredArguments>
the action to execute with the resolved method arguments
action
)

Resolve the method arguments for the specified registered bean and provide it to the given action.

public AutowiredArguments

Returns:

the resolved method arguments
resolve
(RegisteredBean
the registered bean
registeredBean
)

Resolve the method arguments for the specified registered bean.

public void
resolveAndInvoke(RegisteredBean
the registered bean
registeredBean
,
Object
the bean instance
instance
)

Resolve the method arguments for the specified registered bean and invoke the method using reflection.

private AutowiredArguments
resolveArguments(RegisteredBean registeredBean, Method method)

private String
toCommaSeparatedNames(Class<?>... parameterTypes)

public AutowiredMethodArgumentsResolver

Returns:

a new AutowiredMethodArgumentsResolver instance that uses the shortcuts
withShortcut
(String...
the bean names to use as shortcuts (aligned with the method parameters)
beanNames
)

Return a new AutowiredMethodArgumentsResolver instance that uses direct bean name injection shortcuts for specific parameters.

Inherited from org.springframework.beans.factory.aot.AutowiredElementResolver:
registerDependentBeans

Field Detail

methodNameback to summary
private final String methodName
parameterTypesback to summary
private final Class<?>[] parameterTypes
requiredback to summary
private final boolean required
shortcutsback to summary
private final String[] shortcuts
Annotations
@Nullable

Constructor Detail

AutowiredMethodArgumentsResolverback to summary
private AutowiredMethodArgumentsResolver(String methodName, Class<?>[] parameterTypes, boolean required, String[] shortcuts)

Method Detail

forMethodback to summary
public static AutowiredMethodArgumentsResolver forMethod(String methodName, Class<?>... parameterTypes)

Create a new AutowiredMethodArgumentsResolver for the specified method where injection is optional.

Parameters
methodName:String

the method name

parameterTypes:Class<?>[]

the factory method parameter types

Returns:AutowiredMethodArgumentsResolver

a new AutowiredFieldValueResolver instance

forRequiredMethodback to summary
public static AutowiredMethodArgumentsResolver forRequiredMethod(String methodName, Class<?>... parameterTypes)

Create a new AutowiredMethodArgumentsResolver for the specified method where injection is required.

Parameters
methodName:String

the method name

parameterTypes:Class<?>[]

the factory method parameter types

Returns:AutowiredMethodArgumentsResolver

a new AutowiredFieldValueResolver instance

getMethodback to summary
private Method getMethod(RegisteredBean registeredBean)
resolveback to summary
public void resolve(RegisteredBean registeredBean, ThrowingConsumer<AutowiredArguments> action)

Resolve the method arguments for the specified registered bean and provide it to the given action.

Parameters
registeredBean:RegisteredBean

the registered bean

action:ThrowingConsumer<AutowiredArguments>

the action to execute with the resolved method arguments

resolveback to summary
public AutowiredArguments resolve(RegisteredBean registeredBean)

Resolve the method arguments for the specified registered bean.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:AutowiredArguments

the resolved method arguments

Annotations
@Nullable
resolveAndInvokeback to summary
public void resolveAndInvoke(RegisteredBean registeredBean, Object instance)

Resolve the method arguments for the specified registered bean and invoke the method using reflection.

Parameters
registeredBean:RegisteredBean

the registered bean

instance:Object

the bean instance

resolveArgumentsback to summary
private AutowiredArguments resolveArguments(RegisteredBean registeredBean, Method method)
Annotations
@Nullable
toCommaSeparatedNamesback to summary
private String toCommaSeparatedNames(Class<?>... parameterTypes)
withShortcutback to summary
public AutowiredMethodArgumentsResolver withShortcut(String... beanNames)

Return a new AutowiredMethodArgumentsResolver instance that uses direct bean name injection shortcuts for specific parameters.

Parameters
beanNames:String[]

the bean names to use as shortcuts (aligned with the method parameters)

Returns:AutowiredMethodArgumentsResolver

a new AutowiredMethodArgumentsResolver instance that uses the shortcuts