Class BeanFactoryAnnotationUtils
java.lang.Object
org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils
Convenience methods performing bean lookups related to Spring-specific annotations,
 for example Spring's 
@Qualifier annotation.- Since:
- 3.1.2
- Author:
- Juergen Hoeller, Chris Beams
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringgetQualifierValue(AnnotatedElement annotatedElement) Determine thequalifier valuefor the given annotated element.static booleanisQualifierMatch(Predicate<String> qualifier, String beanName, BeanFactory beanFactory) Check whether the named bean declares a qualifier of the given name.static <T> TqualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) Obtain a bean of typeTfrom the givenBeanFactorydeclaring a qualifier (for example, via<qualifier>or@Qualifier) matching the given qualifier, or having a bean name matching the given qualifier.qualifiedBeansOfType(ListableBeanFactory beanFactory, Class<T> beanType, String qualifier) Retrieve all beans of typeTfrom the givenBeanFactorydeclaring a qualifier (for example, via<qualifier>or@Qualifier) matching the given qualifier, or having a bean name matching the given qualifier.
- 
Constructor Details- 
BeanFactoryAnnotationUtilspublic BeanFactoryAnnotationUtils()
 
- 
- 
Method Details- 
qualifiedBeansOfTypepublic static <T> Map<String,T> qualifiedBeansOfType(ListableBeanFactory beanFactory, Class<T> beanType, String qualifier) throws BeansException Retrieve all beans of typeTfrom the givenBeanFactorydeclaring a qualifier (for example, via<qualifier>or@Qualifier) matching the given qualifier, or having a bean name matching the given qualifier.- Parameters:
- beanFactory- the factory to get the target beans from (also searching ancestors)
- beanType- the type of beans to retrieve
- qualifier- the qualifier for selecting among all type matches
- Returns:
- the matching beans of type T
- Throws:
- BeansException- if any of the matching beans could not be created
- Since:
- 5.1.1
- See Also:
 
- 
qualifiedBeanOfTypepublic static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) throws BeansException Obtain a bean of typeTfrom the givenBeanFactorydeclaring a qualifier (for example, via<qualifier>or@Qualifier) matching the given qualifier, or having a bean name matching the given qualifier.- Parameters:
- beanFactory- the factory to get the target bean from (also searching ancestors)
- beanType- the type of bean to retrieve
- qualifier- the qualifier for selecting between multiple bean matches
- Returns:
- the matching bean of type T(nevernull)
- Throws:
- NoUniqueBeanDefinitionException- if multiple matching beans of type- Tfound
- NoSuchBeanDefinitionException- if no matching bean of type- Tfound
- BeansException- if the bean could not be created
- See Also:
 
- 
getQualifierValueDetermine thequalifier valuefor the given annotated element.- Parameters:
- annotatedElement- the class, method or parameter to introspect
- Returns:
- the associated qualifier value, or nullif none
- Since:
- 6.2
 
- 
isQualifierMatchpublic static boolean isQualifierMatch(Predicate<String> qualifier, String beanName, @Nullable BeanFactory beanFactory) Check whether the named bean declares a qualifier of the given name.- Parameters:
- qualifier- the qualifier to match
- beanName- the name of the candidate bean
- beanFactory- the factory from which to retrieve the named bean
- Returns:
- trueif either the bean definition (in the XML case) or the bean's factory method (in the- @Beancase) defines a matching qualifier value (through- <qualifier>or- @Qualifier)
- Since:
- 5.0
 
 
-