org.springframework.beans.factory.annotation
Class QualifierAnnotationAutowireCandidateResolver

java.lang.Object
  extended by org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
All Implemented Interfaces:
AutowireCandidateResolver

public class QualifierAnnotationAutowireCandidateResolver
extends Object
implements AutowireCandidateResolver

AutowireCandidateResolver implementation that matches bean definition qualifiers against qualifier annotations on the field or parameter to be autowired.

Since:
2.5
Author:
Mark Fisher, Juergen Hoeller
See Also:
AutowireCandidateQualifier, Qualifier

Constructor Summary
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.
 
Method Summary
 void addQualifierType(Class<? extends Annotation> qualifierType)
          Register the given type to be used as a qualifier when autowiring.
 boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor)
          Determine if the provided bean definition is an autowire candidate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QualifierAnnotationAutowireCandidateResolver

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


QualifierAnnotationAutowireCandidateResolver

public QualifierAnnotationAutowireCandidateResolver(Class<? extends Annotation> qualifierType)
Create a new QualifierAnnotationAutowireCandidateResolver for the given qualifier annotation type.

Parameters:
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.

Parameters:
qualifierTypes - the qualifier annotations to look for
Method Detail

addQualifierType

public void addQualifierType(Class<? extends Annotation> qualifierType)
Register the given type to be used as a qualifier when autowiring.

This implementation only supports annotations as qualifier types.

Parameters:
qualifierType - the annotation type to register

isAutowireCandidate

public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder,
                                   DependencyDescriptor descriptor)
Determine if 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.

Specified by:
isAutowireCandidate in interface AutowireCandidateResolver
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


Copyright © 2002-2008 The Spring Framework.