Jsr330ScopeMetadataResolver.java 文件源码

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

项目:class-guard 作者:
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
    if (definition instanceof AnnotatedBeanDefinition) {
        AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
        Set<String> annTypes = annDef.getMetadata().getAnnotationTypes();
        String found = null;
        for (String annType : annTypes) {
            Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType);
            if (metaAnns.contains("javax.inject.Scope")) {
                if (found != null) {
                    throw new IllegalStateException("Found ambiguous scope annotations on bean class [" +
                            definition.getBeanClassName() + "]: " + found + ", " + annType);
                }
                found = annType;
                String scopeName = resolveScopeName(annType);
                if (scopeName == null) {
                    throw new IllegalStateException(
                            "Unsupported scope annotation - not mapped onto Spring scope name: " + annType);
                }
                metadata.setScopeName(scopeName);
            }
        }
    }
    return metadata;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号