abstract class ParameterAutowireUtils
extends java.lang.Object
isAutowirable(Parameter)
,
resolveDependency(Parameter, Class, ApplicationContext)
Modifier | Constructor and Description |
---|---|
private |
ParameterAutowireUtils() |
Modifier and Type | Method and Description |
---|---|
private static <A extends java.lang.annotation.Annotation> |
findMergedAnnotation(java.lang.reflect.AnnotatedElement element,
java.lang.Class<A> annotationType) |
(package private) static boolean |
isAutowirable(java.lang.reflect.Parameter parameter)
Determine if the supplied
Parameter can potentially be
autowired from an ApplicationContext . |
(package private) static java.lang.Object |
resolveDependency(java.lang.reflect.Parameter parameter,
java.lang.Class<?> containingClass,
ApplicationContext applicationContext)
Resolve the dependency for the supplied
Parameter from the
supplied ApplicationContext . |
static boolean isAutowirable(java.lang.reflect.Parameter parameter)
Parameter
can potentially be
autowired from an ApplicationContext
.
Returns true
if the supplied parameter is of type
ApplicationContext
(or a sub-type thereof) or is annotated or
meta-annotated with @Autowired
,
@Qualifier
, or @Value
.
@Nullable static java.lang.Object resolveDependency(java.lang.reflect.Parameter parameter, java.lang.Class<?> containingClass, ApplicationContext applicationContext)
Parameter
from the
supplied ApplicationContext
.
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 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 resolvedcontainingClass
- 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 variablesapplicationContext
- the application context from which to resolve the
dependencynull
if none foundBeansException
- if dependency resolution failedisAutowirable(Parameter)
,
Autowired.required()
,
SynthesizingMethodParameter.forParameter(Parameter)
,
AutowireCapableBeanFactory.resolveDependency(DependencyDescriptor, String)
private static <A extends java.lang.annotation.Annotation> java.util.Optional<A> findMergedAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.Class<A> annotationType)