当前位置: 首页>>代码示例>>Java>>正文


Java MetadataReader.getClassMetadata方法代码示例

本文整理汇总了Java中org.springframework.core.type.classreading.MetadataReader.getClassMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java MetadataReader.getClassMetadata方法的具体用法?Java MetadataReader.getClassMetadata怎么用?Java MetadataReader.getClassMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.type.classreading.MetadataReader的用法示例。


在下文中一共展示了MetadataReader.getClassMetadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMangoDaoClasses

import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
private List<Class<?>> findMangoDaoClasses(String packages) {
    try {
        List<Class<?>> daos = new ArrayList<Class<?>>();
        ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
        for (String locationPattern : getLocationPattern(packages)) {
            Resource[] rs = resourcePatternResolver.getResources(locationPattern);
            for (Resource r : rs) {
                MetadataReader reader = metadataReaderFactory.getMetadataReader(r);
                AnnotationMetadata annotationMD = reader.getAnnotationMetadata();
                if (annotationMD.hasAnnotation(DB.class.getName())) {
                    ClassMetadata clazzMD = reader.getClassMetadata();
                    daos.add(Class.forName(clazzMD.getClassName()));
                }
            }
        }
        return daos;
    } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:jfaster,项目名称:mango-spring-boot-starter,代码行数:22,代码来源:MangoDaoAutoCreator.java

示例2: getClasses

import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
protected List<String> getClasses(Resource[] resources) {
    List<String> classNames = new ArrayList<>();

    for (Resource resource : resources) {
        if (resource.isReadable()) {
            MetadataReader metadataReader;
            try {
                metadataReader = metadataReaderFactory.getMetadataReader(resource);
            } catch (IOException e) {
                throw new RuntimeException("Unable to read metadata resource", e);
            }

            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (annotationMetadata.isAnnotated(com.haulmont.chile.core.annotations.MetaClass.class.getName())
                    || annotationMetadata.isAnnotated(MappedSuperclass.class.getName())
                    || annotationMetadata.isAnnotated(Entity.class.getName())) {
                ClassMetadata classMetadata = metadataReader.getClassMetadata();
                classNames.add(classMetadata.getClassName());
            }
        }
    }
    return classNames;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:CubaClientTestCase.java

示例3: findConfigInterfaces

import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
protected Set<Class> findConfigInterfaces() {
    if (interfacesCache == null) {
        synchronized (this) {
            if (interfacesCache == null) {
                log.trace("Locating config interfaces");
                Set<String> cache = new HashSet<>();
                for (String rootPackage : metadata.getRootPackages()) {
                    String packagePrefix = rootPackage.replace(".", "/") + "/**/*.class";
                    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + packagePrefix;
                    Resource[] resources;
                    try {
                        resources = resourcePatternResolver.getResources(packageSearchPath);
                        for (Resource resource : resources) {
                            if (resource.isReadable()) {
                                MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
                                ClassMetadata classMetadata = metadataReader.getClassMetadata();
                                if (classMetadata.isInterface()) {
                                    for (String intf : classMetadata.getInterfaceNames()) {
                                        if (Config.class.getName().equals(intf)) {
                                            cache.add(classMetadata.getClassName());
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    } catch (IOException e) {
                        throw new RuntimeException("Error searching for Config interfaces", e);
                    }
                }
                log.trace("Found config interfaces: {}", cache);
                interfacesCache = cache;
            }
        }
    }
    return interfacesCache.stream()
            .map(ReflectionHelper::getClass)
            .collect(Collectors.toSet());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:40,代码来源:AppPropertiesLocator.java


注:本文中的org.springframework.core.type.classreading.MetadataReader.getClassMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。