spring-framework / org.springframework.beans.factory.annotation / QualifierAnnotationAutowireCandidateResolver

QualifierAnnotationAutowireCandidateResolver

open class QualifierAnnotationAutowireCandidateResolver : GenericTypeAwareAutowireCandidateResolver

AutowireCandidateResolver implementation that matches bean definition qualifiers against Qualifier on the field or parameter to be autowired. Also supports suggested expression values through a Value annotation.

Also supports JSR-330's javax.inject.Qualifier annotation, if available.

Author
Mark Fisher

Author
Juergen Hoeller

Author
Stephane Nicoll

Since
2.5

See Also
AutowireCandidateQualifierQualifierValue

Constructors

<init>

QualifierAnnotationAutowireCandidateResolver()

Create a new QualifierAnnotationAutowireCandidateResolver for Spring's standard Qualifier annotation.

Also supports JSR-330's javax.inject.Qualifier annotation, if available.

QualifierAnnotationAutowireCandidateResolver(qualifierType: Class<out Annotation>)

Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation type.

QualifierAnnotationAutowireCandidateResolver(qualifierTypes: MutableSet<Class<out Annotation>>)

Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation types.

Functions

addQualifierType

open fun addQualifierType(qualifierType: Class<out Annotation>): Unit

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.

getSuggestedValue

open fun getSuggestedValue(descriptor: DependencyDescriptor): Any

Determine whether the given dependency declares a value annotation.

isAutowireCandidate

open fun isAutowireCandidate(bdHolder: BeanDefinitionHolder, descriptor: DependencyDescriptor): Boolean

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.

isRequired

open fun isRequired(descriptor: DependencyDescriptor): Boolean

Determine whether the given dependency declares an autowired annotation, checking its required flag.

setValueAnnotationType

open fun setValueAnnotationType(valueAnnotationType: Class<out Annotation>): Unit

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.

Inherited Functions

setBeanFactory

open fun setBeanFactory(beanFactory: BeanFactory): Unit

Inheritors

ContextAnnotationAutowireCandidateResolver

open class ContextAnnotationAutowireCandidateResolver : QualifierAnnotationAutowireCandidateResolver

Complete implementation of the org.springframework.beans.factory.support.AutowireCandidateResolver strategy interface, providing support for qualifier annotations as well as for lazy resolution driven by the Lazy annotation in the context.annotation package.