Package org.springframework.beans.factory.annotation

# Class ParameterResolutionDelegate

java.lang.Object
org.springframework.beans.factory.annotation.ParameterResolutionDelegate

public final class ParameterResolutionDelegate extends Object
Public delegate for resolving autowirable parameters on externally managed constructors and methods.

Since:
  5.2
Author:
  Sam Brannen, Juergen Hoeller
See Also:
  - `isAutowirable(java.lang.reflect.Parameter, int)`
  - `resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`isAutowirable(Parameter parameter, int parameterIndex)`
Determine if the supplied `Parameter` can potentially be autowired from an `AutowireCapableBeanFactory`.
`static Object`
`resolveDependency(Parameter parameter, int parameterIndex, Class<?> containingClass, AutowireCapableBeanFactory beanFactory)`
Resolve the dependency for the supplied `Parameter` from the supplied `AutowireCapableBeanFactory`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### isAutowirable

public static boolean isAutowirable(Parameter parameter, int parameterIndex)
Determine if the supplied `Parameter` can potentially be autowired from an `AutowireCapableBeanFactory`.

Returns `true` if the supplied parameter is annotated or meta-annotated with `@Autowired`, `@Qualifier`, or `@Value`.

Note that `resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)` may still be able to resolve the dependency for the supplied parameter even if this method returns `false`.

Parameters:
  `parameter` - the parameter whose dependency should be autowired (must not be `null`)
  `parameterIndex` - the index of the parameter in the constructor or method that declares the parameter
See Also:
  - `resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)`

### resolveDependency

@Nullable public static Object resolveDependency(Parameter parameter, int parameterIndex, Class<?> containingClass, AutowireCapableBeanFactory beanFactory) throws BeansException
Resolve the dependency for the supplied `Parameter` from the supplied `AutowireCapableBeanFactory`.

Provides comprehensive autowiring support for individual method parameters on par with Spring's dependency injection facilities for autowired fields and methods, including support for `@Autowired`, `@Qualifier`, and `@Value` with support for property placeholders and SpEL expressions in `@Value` declarations.

The dependency is required unless the parameter is annotated or meta-annotated with `@Autowired` with the `required` flag set to `false`.

If an explicit qualifier is not declared, the name of the parameter will be used as the qualifier for resolving ambiguities.

Parameters:
  `parameter` - the parameter whose dependency should be resolved (must not be `null`)
  `parameterIndex` - the index of the parameter in the constructor or method that declares the parameter
  `containingClass` - the concrete class that contains the parameter; this may differ from the class that declares the parameter in that it may be a subclass thereof, potentially substituting type variables (must not be `null`)
  `beanFactory` - the `AutowireCapableBeanFactory` from which to resolve the dependency (must not be `null`)
Returns:
  the resolved object, or `null` if none found
Throws:
  `BeansException` - if dependency resolution failed
See Also:
  - `isAutowirable(java.lang.reflect.Parameter, int)`
  - `Autowired.required()`
  - `SynthesizingMethodParameter.forExecutable(Executable, int)`
  - `AutowireCapableBeanFactory.resolveDependency(DependencyDescriptor, String)`