本文整理汇总了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);
}
}
示例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;
}
示例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());
}