Class ParameterResolutionDelegate
- Since:
- 5.2
- Author:
- Sam Brannen, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isAutowirable
(Parameter parameter, int parameterIndex) Determine if the suppliedParameter
can potentially be autowired from anAutowireCapableBeanFactory
.static Object
resolveDependency
(Parameter parameter, int parameterIndex, Class<?> containingClass, AutowireCapableBeanFactory beanFactory) Resolve the dependency for the suppliedParameter
from the suppliedAutowireCapableBeanFactory
.
-
Method Details
-
isAutowirable
Determine if the suppliedParameter
can potentially be autowired from anAutowireCapableBeanFactory
.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 returnsfalse
.- Parameters:
parameter
- the parameter whose dependency should be autowired (must not benull
)parameterIndex
- the index of the parameter in the constructor or method that declares the parameter- See Also:
-
resolveDependency
@Nullable public static Object resolveDependency(Parameter parameter, int parameterIndex, Class<?> containingClass, AutowireCapableBeanFactory beanFactory) throws BeansException Resolve the dependency for the suppliedParameter
from the suppliedAutowireCapableBeanFactory
.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 therequired
flag set tofalse
.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 benull
)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 benull
)beanFactory
- theAutowireCapableBeanFactory
from which to resolve the dependency (must not benull
)- Returns:
- the resolved object, or
null
if none found - Throws:
BeansException
- if dependency resolution failed- See Also:
-