public abstract class BeanFactoryAnnotationUtils
extends java.lang.Object
@Qualifier annotation.BeanFactoryUtils| Constructor and Description |
|---|
BeanFactoryAnnotationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isQualifierMatch(java.util.function.Predicate<java.lang.String> qualifier,
java.lang.String beanName,
BeanFactory beanFactory)
Check whether the named bean declares a qualifier of the given name.
|
static <T> T |
qualifiedBeanOfType(BeanFactory beanFactory,
java.lang.Class<T> beanType,
java.lang.String qualifier)
Obtain a bean of type
T from the given BeanFactory declaring a
qualifier (e.g. |
static <T> java.util.Map<java.lang.String,T> |
qualifiedBeansOfType(ListableBeanFactory beanFactory,
java.lang.Class<T> beanType,
java.lang.String qualifier)
Retrieve all bean of type
T from the given BeanFactory declaring a
qualifier (e.g. |
public static <T> java.util.Map<java.lang.String,T> qualifiedBeansOfType(ListableBeanFactory beanFactory, java.lang.Class<T> beanType, java.lang.String qualifier) throws BeansException
T from the given BeanFactory declaring a
qualifier (e.g. via <qualifier> or @Qualifier) matching the given
qualifier, or having a bean name matching the given qualifier.beanFactory - the factory to get the target beans from (also searching ancestors)beanType - the type of beans to retrievequalifier - the qualifier for selecting among all type matchesTBeansException - if any of the matching beans could not be createdBeanFactoryUtils.beansOfTypeIncludingAncestors(ListableBeanFactory, Class)public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, java.lang.Class<T> beanType, java.lang.String qualifier) throws BeansException
T from the given BeanFactory declaring a
qualifier (e.g. via <qualifier> or @Qualifier) matching the given
qualifier, or having a bean name matching the given qualifier.beanFactory - the factory to get the target bean from (also searching ancestors)beanType - the type of bean to retrievequalifier - the qualifier for selecting between multiple bean matchesT (never null)NoUniqueBeanDefinitionException - if multiple matching beans of type T foundNoSuchBeanDefinitionException - if no matching bean of type T foundBeansException - if the bean could not be createdBeanFactoryUtils.beanOfTypeIncludingAncestors(ListableBeanFactory, Class)public static boolean isQualifierMatch(java.util.function.Predicate<java.lang.String> qualifier,
java.lang.String beanName,
@Nullable
BeanFactory beanFactory)
qualifier - the qualifier to matchbeanName - the name of the candidate beanbeanFactory - the factory from which to retrieve the named beantrue if either the bean definition (in the XML case)
or the bean's factory method (in the @Bean case) defines a matching
qualifier value (through <qualifier> or @Qualifier)