use of org.springframework.core.type.classreading.MetadataReader in project spring-boot by spring-projects.
the class AbstractConfigurationClassTests method findConfigurationClasses.
private Set<AnnotationMetadata> findConfigurationClasses() throws IOException {
Set<AnnotationMetadata> configurationClasses = new HashSet<>();
Resource[] resources = this.resolver.getResources("classpath*:" + getClass().getPackage().getName().replace('.', '/') + "/**/*.class");
for (Resource resource : resources) {
if (!isTestClass(resource)) {
MetadataReader metadataReader = new SimpleMetadataReaderFactory().getMetadataReader(resource);
AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
if (annotationMetadata.getAnnotationTypes().contains(Configuration.class.getName())) {
configurationClasses.add(annotationMetadata);
}
}
}
return configurationClasses;
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationMetadataTests method multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor.
/**
* https://jira.spring.io/browse/SPR-11649
*/
@Test
public void multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedAnnotationsClass.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationMetadataTests method composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor.
/**
* https://jira.spring.io/browse/SPR-11649
*/
@Test
public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationClass.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationMetadataTests method asmAnnotationMetadataForAnnotation.
@Test
public void asmAnnotationMetadataForAnnotation() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(Component.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
doTestMetadataForAnnotationClass(metadata);
}
use of org.springframework.core.type.classreading.MetadataReader in project spring-framework by spring-projects.
the class AnnotationMetadataTests method metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor.
@Test
public void metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(ComposedConfigurationWithAttributeOverridesClass.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
assertMetaAnnotationOverrides(metadata);
}
Aggregations