PropertyMappingContextCustomizer.java 文件源码

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

项目:https-github.com-g0t4-jenkins2-course-spring-boot 作者:
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
        throws BeansException {
    Class<?> beanClass = bean.getClass();
    Set<Class<?>> components = new LinkedHashSet<Class<?>>();
    Set<Class<?>> propertyMappings = new LinkedHashSet<Class<?>>();
    while (beanClass != null) {
        for (Annotation annotation : AnnotationUtils.getAnnotations(beanClass)) {
            if (isAnnotated(annotation, Component.class)) {
                components.add(annotation.annotationType());
            }
            if (isAnnotated(annotation, PropertyMapping.class)) {
                propertyMappings.add(annotation.annotationType());
            }
        }
        beanClass = beanClass.getSuperclass();
    }
    if (!components.isEmpty() && !propertyMappings.isEmpty()) {
        throw new IllegalStateException("The @PropertyMapping "
                + getAnnotationsDescription(propertyMappings)
                + " cannot be used in combination with the @Component "
                + getAnnotationsDescription(components));
    }
    return bean;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号