public class

QualifierAnnotationAutowireCandidateResolver

extends Object
implements BeanFactoryAware AutowireCandidateResolver
java.lang.Object
   ↳ org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver

Class Overview

AutowireCandidateResolver implementation that matches bean definition qualifiers against qualifier annotations 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.

Summary

Public Constructors
QualifierAnnotationAutowireCandidateResolver()
Create a new QualifierAnnotationAutowireCandidateResolver for Spring's standard Qualifier 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.
Public Methods
void addQualifierType(Class<? extends Annotation> qualifierType)
Register the given type to be used as a qualifier when autowiring.
Object getSuggestedValue(DependencyDescriptor descriptor)
Determine whether the given dependency carries a value annotation.
boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
Determine whether the provided bean definition is an autowire candidate.
void setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
void setValueAnnotationType(Class<? extends Annotation> valueAnnotationType)
Set the 'value' annotation type, to be used on fields, method parameters and constructor parameters.
Protected Methods
boolean checkQualifier(BeanDefinitionHolder bdHolder, Annotation annotation, TypeConverter typeConverter)
Match the given qualifier annotation against the candidate bean definition.
boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch)
Match the given qualifier annotations against the candidate bean definition.
Object findValue(Annotation[] annotationsToSearch)
Determine a suggested value from any of the given candidate annotations.
boolean isQualifier(Class<? extends Annotation> annotationType)
Checks whether the given annotation type is a recognized qualifier type.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.BeanFactoryAware
From interface org.springframework.beans.factory.support.AutowireCandidateResolver

Public Constructors

public QualifierAnnotationAutowireCandidateResolver ()

Also: SpringBeans

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

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

public QualifierAnnotationAutowireCandidateResolver (Class<? extends Annotation> qualifierType)

Also: SpringBeans

Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation type.

Parameters
qualifierType the qualifier annotation to look for

public QualifierAnnotationAutowireCandidateResolver (Set<Class<? extends Annotation>> qualifierTypes)

Also: SpringBeans

Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation types.

Parameters
qualifierTypes the qualifier annotations to look for

Public Methods

public void addQualifierType (Class<? extends Annotation> qualifierType)

Also: SpringBeans

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.

Parameters
qualifierType the annotation type to register

public Object getSuggestedValue (DependencyDescriptor descriptor)

Also: SpringBeans

Determine whether the given dependency carries a value annotation.

Parameters
descriptor the descriptor for the target method parameter or field
Returns
  • the value suggested (typically an expression String), or null if none found
See Also

public boolean isAutowireCandidate (BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)

Also: SpringBeans

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.

Parameters
bdHolder the bean definition including bean name and aliases
descriptor the descriptor for the target method parameter or field
Returns
  • whether the bean definition qualifies as autowire candidate
See Also

public void setBeanFactory (BeanFactory beanFactory)

Also: SpringBeans

Callback that supplies the owning factory to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as afterPropertiesSet() or a custom init-method.

Parameters
beanFactory owning BeanFactory (never null). The bean can immediately call methods on the factory.

public void setValueAnnotationType (Class<? extends Annotation> valueAnnotationType)

Also: SpringBeans

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.

Protected Methods

protected boolean checkQualifier (BeanDefinitionHolder bdHolder, Annotation annotation, TypeConverter typeConverter)

Also: SpringBeans

Match the given qualifier annotation against the candidate bean definition.

protected boolean checkQualifiers (BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch)

Also: SpringBeans

Match the given qualifier annotations against the candidate bean definition.

protected Object findValue (Annotation[] annotationsToSearch)

Also: SpringBeans

Determine a suggested value from any of the given candidate annotations.

protected boolean isQualifier (Class<? extends Annotation> annotationType)

Also: SpringBeans

Checks whether the given annotation type is a recognized qualifier type.