public final class ParameterResolutionDelegate extends Object
isAutowirable(java.lang.reflect.Parameter, int)
,
resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)
Modifier and Type | Method and 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 . |
public static boolean isAutowirable(Parameter parameter, int parameterIndex)
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
.
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 parameterresolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)
@Nullable public static Object resolveDependency(Parameter parameter, int parameterIndex, Class<?> containingClass, AutowireCapableBeanFactory beanFactory) throws BeansException
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.
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 parametercontainingClass
- 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
)null
if none foundBeansException
- if dependency resolution failedisAutowirable(java.lang.reflect.Parameter, int)
,
Autowired.required()
,
SynthesizingMethodParameter.forExecutable(Executable, int)
,
AutowireCapableBeanFactory.resolveDependency(DependencyDescriptor, String)