本文整理汇总了Java中org.springframework.core.type.classreading.MetadataReader.getAnnotationMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java MetadataReader.getAnnotationMetadata方法的具体用法?Java MetadataReader.getAnnotationMetadata怎么用?Java MetadataReader.getAnnotationMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.type.classreading.MetadataReader
的用法示例。
在下文中一共展示了MetadataReader.getAnnotationMetadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: findConfigurationClasses
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
private Set<AnnotationMetadata> findConfigurationClasses() throws IOException {
Set<AnnotationMetadata> configurationClasses = new HashSet<AnnotationMetadata>();
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;
}
示例3: customRequestScopeViaAsm
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void customRequestScopeViaAsm() throws IOException {
MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScope.class.getName());
AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
assertEquals("request", scopeMetadata.getScopeName());
assertEquals(NO, scopeMetadata.getScopedProxyMode());
}
示例4: customRequestScopeWithAttributeViaAsm
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void customRequestScopeWithAttributeViaAsm() throws IOException {
MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttributeOverride.class.getName());
AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
assertEquals("request", scopeMetadata.getScopeName());
assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
示例5: asmAnnotationMetadata
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void asmAnnotationMetadata() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponent.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
doTestAnnotationInfo(metadata);
doTestMethodAnnotationInfo(metadata);
}
示例6: asmAnnotationMetadataForSubclass
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void asmAnnotationMetadataForSubclass() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponentSubClass.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
doTestSubClassAnnotationInfo(metadata);
}
示例7: asmAnnotationMetadataForInterface
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void asmAnnotationMetadataForInterface() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotationMetadata.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
doTestMetadataForInterfaceClass(metadata);
}
示例8: asmAnnotationMetadataForAnnotation
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void asmAnnotationMetadataForAnnotation() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(Component.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
doTestMetadataForAnnotationClass(metadata);
}
示例9: metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
@Test
public void metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(ComposedConfigurationWithAttributeOverridesClass.class.getName());
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
assertMetaAnnotationOverrides(metadata);
}
示例10: multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
/**
* 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);
}
示例11: composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
/**
* 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);
}
示例12: ConfigurationClass
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
/**
* Create a new {@link ConfigurationClass} with the given name.
* @param metadataReader reader used to parse the underlying {@link Class}
* @param beanName must not be {@code null}
* @throws IllegalArgumentException if beanName is null (as of Spring 3.1.1)
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
*/
public ConfigurationClass(MetadataReader metadataReader, String beanName) {
Assert.hasText(beanName, "bean name must not be null");
this.metadata = metadataReader.getAnnotationMetadata();
this.resource = metadataReader.getResource();
this.beanName = beanName;
this.importedBy = null;
}
示例13: ConfigurationClass
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
/**
* Create a new {@link ConfigurationClass} with the given name.
* @param metadataReader reader used to parse the underlying {@link Class}
* @param beanName must not be {@code null}
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
*/
public ConfigurationClass(MetadataReader metadataReader, String beanName) {
Assert.hasText(beanName, "Bean name must not be null");
this.metadata = metadataReader.getAnnotationMetadata();
this.resource = metadataReader.getResource();
this.beanName = beanName;
}
示例14: ScannedGenericBeanDefinition
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
/**
* Create a new ScannedGenericBeanDefinition for the class that the
* given MetadataReader describes.
* @param metadataReader the MetadataReader for the scanned target class
*/
public ScannedGenericBeanDefinition(MetadataReader metadataReader) {
Assert.notNull(metadataReader, "MetadataReader must not be null");
this.metadata = metadataReader.getAnnotationMetadata();
setBeanClassName(this.metadata.getClassName());
}
示例15: getAnnotationMetadata
import org.springframework.core.type.classreading.MetadataReader; //导入方法依赖的package包/类
protected AnnotationMetadata getAnnotationMetadata(String classname) throws IOException
{
MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(classname);
AnnotationMetadata annotationMetaData = metadataReader.getAnnotationMetadata();
return annotationMetaData;
}