public class BeanFactoryAnnotationUtils
extends java.lang.Object
@Qualifier
annotation.BeanFactoryUtils
Constructor and Description |
---|
BeanFactoryAnnotationUtils() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
isQualifierMatch(java.lang.String qualifier,
java.lang.String beanName,
ConfigurableListableBeanFactory bf)
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. |
private static <T> T |
qualifiedBeanOfType(ConfigurableListableBeanFactory bf,
java.lang.Class<T> beanType,
java.lang.String qualifier)
Obtain a bean of type
T from the given BeanFactory declaring a qualifier
(e.g. |
public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, java.lang.Class<T> beanType, java.lang.String qualifier)
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 BeanFactory to get the target bean frombeanType
- the type of bean to retrievequalifier
- the qualifier for selecting between multiple bean matchesT
(never null
)NoSuchBeanDefinitionException
- if no matching bean of type T
foundprivate static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, java.lang.Class<T> beanType, java.lang.String qualifier)
T
from the given BeanFactory
declaring a qualifier
(e.g. <qualifier>
or @Qualifier
) matching the given qualifier).bf
- the BeanFactory to get the target bean frombeanType
- the type of bean to retrievequalifier
- the qualifier for selecting between multiple bean matchesT
(never null
)NoSuchBeanDefinitionException
- if no matching bean of type T
foundprivate static boolean isQualifierMatch(java.lang.String qualifier, java.lang.String beanName, ConfigurableListableBeanFactory bf)
qualifier
- the qualifier to matchbeanName
- the name of the candidate beanbf
- the BeanFactory
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
)