DefaultListableBeanFactory.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:lams 作者:
/**
 * Find a {@link Annotation} of {@code annotationType} on the specified
 * bean, traversing its interfaces and super classes if no annotation can be
 * found on the given class itself, as well as checking its raw bean class
 * if not found on the exposed bean reference (e.g. in case of a proxy).
 */
@Override
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
        throws NoSuchBeanDefinitionException{

    A ann = null;
    Class<?> beanType = getType(beanName);
    if (beanType != null) {
        ann = AnnotationUtils.findAnnotation(beanType, annotationType);
    }
    if (ann == null && containsBeanDefinition(beanName)) {
        BeanDefinition bd = getMergedBeanDefinition(beanName);
        if (bd instanceof AbstractBeanDefinition) {
            AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
            if (abd.hasBeanClass()) {
                ann = AnnotationUtils.findAnnotation(abd.getBeanClass(), annotationType);
            }
        }
    }
    return ann;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号