Class BeanFactoryAnnotationUtils
- java.lang.Object
- org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils
public abstract class BeanFactoryAnnotationUtils extends Object
Convenience methods performing bean lookups related to annotations, for example Spring's@Qualifier
annotation.- Since:
- 3.1.2
- Author:
- Juergen Hoeller, Chris Beams
- See Also:
BeanFactoryUtils
Constructor Summary
Constructors Constructor Description BeanFactoryAnnotationUtils()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier)
Obtain a bean of typeT
from the givenBeanFactory
declaring a qualifier (e.g.
Constructor Detail
BeanFactoryAnnotationUtils
public BeanFactoryAnnotationUtils()
Method Detail
qualifiedBeanOfType
public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) throws BeansException
Obtain a bean of typeT
from the givenBeanFactory
declaring a qualifier (e.g. via<qualifier>
or@Qualifier
) matching the given qualifier, or having a bean name matching the given qualifier.- Parameters:
beanFactory
- the BeanFactory to get the target bean frombeanType
- the type of bean to retrievequalifier
- the qualifier for selecting between multiple bean matches- Returns:
- the matching bean of type
T
(nevernull
) - Throws:
NoUniqueBeanDefinitionException
- if multiple matching beans of typeT
foundNoSuchBeanDefinitionException
- if no matching bean of typeT
foundBeansException
- if the bean could not be created- See Also:
BeanFactory.getBean(Class)