类 QualifierAnnotationAutowireCandidateResolver
- java.lang.Object
- org.springframework.beans.factory.support.SimpleAutowireCandidateResolver
- org.springframework.beans.factory.support.GenericTypeAwareAutowireCandidateResolver
- org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
- 所有已实现的接口:
Cloneable
,Aware
,BeanFactoryAware
,AutowireCandidateResolver
public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwareAutowireCandidateResolver
AutowireCandidateResolver
implementation that matches bean definition qualifiers againstqualifier annotations
on the field or parameter to be autowired. Also supports suggested expression values through avalue
annotation.Also supports JSR-330's
Qualifier
annotation, if available.- 从以下版本开始:
- 2.5
- 作者:
- Mark Fisher, Juergen Hoeller, Stephane Nicoll
- 另请参阅:
AutowireCandidateQualifier
,Qualifier
,Value
字段概要
从类继承的字段 org.springframework.beans.factory.support.SimpleAutowireCandidateResolver
INSTANCE
构造器概要
构造器 构造器 说明 QualifierAnnotationAutowireCandidateResolver()
Create a new QualifierAnnotationAutowireCandidateResolver for Spring's standardQualifier
annotation.QualifierAnnotationAutowireCandidateResolver(Class<? extends Annotation> qualifierType)
Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation type.QualifierAnnotationAutowireCandidateResolver(Set<Class<? extends Annotation>> qualifierTypes)
Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation types.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addQualifierType(Class<? extends Annotation> qualifierType)
Register the given type to be used as a qualifier when autowiring.protected boolean
checkQualifier(BeanDefinitionHolder bdHolder, Annotation annotation, TypeConverter typeConverter)
Match the given qualifier annotation against the candidate bean definition.protected boolean
checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch)
Match the given qualifier annotations against the candidate bean definition.protected Object
extractValue(AnnotationAttributes attr)
Extract the value attribute from the given annotation.protected Object
findValue(Annotation[] annotationsToSearch)
Determine a suggested value from any of the given candidate annotations.protected Annotation
getFactoryMethodAnnotation(RootBeanDefinition bd, Class<? extends Annotation> type)
protected Annotation
getQualifiedElementAnnotation(RootBeanDefinition bd, Class<? extends Annotation> type)
Object
getSuggestedValue(DependencyDescriptor descriptor)
Determine whether the given dependency declares a value annotation.boolean
hasQualifier(DependencyDescriptor descriptor)
Determine whether the given dependency declares a qualifier annotation.boolean
isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
Determine whether the provided bean definition is an autowire candidate.protected boolean
isQualifier(Class<? extends Annotation> annotationType)
Checks whether the given annotation type is a recognized qualifier type.boolean
isRequired(DependencyDescriptor descriptor)
Determine whether the given dependency declares an autowired annotation, checking its required flag.void
setValueAnnotationType(Class<? extends Annotation> valueAnnotationType)
Set the 'value' annotation type, to be used on fields, method parameters and constructor parameters.从类继承的方法 org.springframework.beans.factory.support.GenericTypeAwareAutowireCandidateResolver
checkGenericTypeMatch, cloneIfNecessary, getBeanFactory, getResolvedDecoratedDefinition, getReturnTypeForFactoryMethod, setBeanFactory
从类继承的方法 org.springframework.beans.factory.support.SimpleAutowireCandidateResolver
getLazyResolutionProxyIfNecessary
构造器详细资料
QualifierAnnotationAutowireCandidateResolver
public QualifierAnnotationAutowireCandidateResolver()
QualifierAnnotationAutowireCandidateResolver
public QualifierAnnotationAutowireCandidateResolver(Class<? extends Annotation> qualifierType)
Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation type.- 参数:
qualifierType
- the qualifier annotation to look for
QualifierAnnotationAutowireCandidateResolver
public QualifierAnnotationAutowireCandidateResolver(Set<Class<? extends Annotation>> qualifierTypes)
Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation types.- 参数:
qualifierTypes
- the qualifier annotations to look for
方法详细资料
addQualifierType
public void addQualifierType(Class<? extends Annotation> qualifierType)
Register the given type to be used as a qualifier when autowiring.This identifies qualifier annotations for direct use (on fields, method parameters and constructor parameters) as well as meta annotations that in turn identify actual qualifier annotations.
This implementation only supports annotations as qualifier types. The default is Spring's
Qualifier
annotation which serves as a qualifier for direct use and also as a meta annotation.- 参数:
qualifierType
- the annotation type to register
setValueAnnotationType
public void setValueAnnotationType(Class<? extends Annotation> valueAnnotationType)
Set the 'value' annotation type, to be used on fields, method parameters and constructor parameters.The default value annotation type is the Spring-provided
Value
annotation.This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate a default value expression for a specific argument.
isAutowireCandidate
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
Determine whether the provided bean definition is an autowire candidate.To be considered a candidate the bean's autowire-candidate attribute must not have been set to 'false'. Also, if an annotation on the field or parameter to be autowired is recognized by this bean factory as a qualifier, the bean must 'match' against the annotation as well as any attributes it may contain. The bean definition must contain the same qualifier or match by meta attributes. A "value" attribute will fallback to match against the bean name or an alias if a qualifier or attribute does not match.
- 指定者:
isAutowireCandidate
在接口中AutowireCandidateResolver
- 覆盖:
isAutowireCandidate
在类中GenericTypeAwareAutowireCandidateResolver
- 参数:
bdHolder
- the bean definition including bean name and aliasesdescriptor
- the descriptor for the target method parameter or field- 返回:
- whether the bean definition qualifies as autowire candidate
- 另请参阅:
Qualifier
checkQualifiers
protected boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch)
Match the given qualifier annotations against the candidate bean definition.
isQualifier
protected boolean isQualifier(Class<? extends Annotation> annotationType)
Checks whether the given annotation type is a recognized qualifier type.
checkQualifier
protected boolean checkQualifier(BeanDefinitionHolder bdHolder, Annotation annotation, TypeConverter typeConverter)
Match the given qualifier annotation against the candidate bean definition.
getQualifiedElementAnnotation
@Nullable protected Annotation getQualifiedElementAnnotation(RootBeanDefinition bd, Class<? extends Annotation> type)
getFactoryMethodAnnotation
@Nullable protected Annotation getFactoryMethodAnnotation(RootBeanDefinition bd, Class<? extends Annotation> type)
isRequired
public boolean isRequired(DependencyDescriptor descriptor)
Determine whether the given dependency declares an autowired annotation, checking its required flag.- 指定者:
isRequired
在接口中AutowireCandidateResolver
- 覆盖:
isRequired
在类中SimpleAutowireCandidateResolver
- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- whether the descriptor is marked as required or possibly indicating non-required status some other way (e.g. through a parameter annotation)
- 另请参阅:
Autowired.required()
hasQualifier
public boolean hasQualifier(DependencyDescriptor descriptor)
Determine whether the given dependency declares a qualifier annotation.- 指定者:
hasQualifier
在接口中AutowireCandidateResolver
- 覆盖:
hasQualifier
在类中SimpleAutowireCandidateResolver
- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- whether the descriptor declares a qualifier, narrowing the candidate status beyond the type match
- 另请参阅:
isQualifier(Class)
,Qualifier
getSuggestedValue
@Nullable public Object getSuggestedValue(DependencyDescriptor descriptor)
Determine whether the given dependency declares a value annotation.- 指定者:
getSuggestedValue
在接口中AutowireCandidateResolver
- 覆盖:
getSuggestedValue
在类中SimpleAutowireCandidateResolver
- 参数:
descriptor
- the descriptor for the target method parameter or field- 返回:
- the value suggested (typically an expression String), or
null
if none found - 另请参阅:
Value
findValue
@Nullable protected Object findValue(Annotation[] annotationsToSearch)
Determine a suggested value from any of the given candidate annotations.
extractValue
protected Object extractValue(AnnotationAttributes attr)
Extract the value attribute from the given annotation.- 从以下版本开始:
- 4.3