本文整理汇总了Java中org.springframework.core.type.classreading.SimpleMetadataReaderFactory类的典型用法代码示例。如果您正苦于以下问题:Java SimpleMetadataReaderFactory类的具体用法?Java SimpleMetadataReaderFactory怎么用?Java SimpleMetadataReaderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleMetadataReaderFactory类属于org.springframework.core.type.classreading包,在下文中一共展示了SimpleMetadataReaderFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: selectImports
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void selectImports() throws Exception {
assertThat(imports.selectImports(metadata).length, is(0));
when(metadata.getAnnotationAttributes(EnableContextPropagation.class.getName(), true)).thenReturn(null);
assertThat(imports.selectImports(metadata).length, is(0));
assertThat(imports.selectImports(metadata).length, is(0));
List<String> actual = Arrays.asList(imports.selectImports(new SimpleMetadataReaderFactory().getMetadataReader(Annotated.class.getName()).getAnnotationMetadata()));
assertThat(actual, Matchers.containsInAnyOrder(
PreservesHeadersInboundHttpRequestStrategy.class.getName(),
PreservesHttpHeadersFeignStrategy.class.getName(),
PreservesExecutionContextExecutorStrategy.class.getName(),
PreservesHttpHeadersZuulStrategy.class.getName(),
PreservesExecutionContextHystrixStrategy.class.getName(),
PreservesJmsMessagePropertiesStrategy.class.getName(),
PreservesStompHeadersStrategy.class.getName()
));
}
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:21,代码来源:ExecutionContextPropagationImportTest.java
示例2: getContextCustomizerShouldAddExcludeFilters
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void getContextCustomizerShouldAddExcludeFilters() throws Exception {
ContextCustomizer customizer = this.factory
.createContextCustomizer(WithExcludeFilters.class, null);
customizer.customizeContext(this.context, this.mergedContextConfiguration);
this.context.refresh();
TypeExcludeFilter filter = this.context.getBean(TypeExcludeFilter.class);
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
MetadataReader metadataReader = metadataReaderFactory
.getMetadataReader(NoAnnotation.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isFalse();
metadataReader = metadataReaderFactory
.getMetadataReader(SimpleExclude.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
metadataReader = metadataReaderFactory
.getMetadataReader(TestClassAwareExclude.class.getName());
assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:TypeExcludeFiltersContextCustomizerFactoryTests.java
示例3: defaultServletConfiguration
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void defaultServletConfiguration() throws IOException {
ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(
new SimpleMetadataReaderFactory()
.getMetadataReader(DefaultConfigurationServlet.class.getName()));
this.handler.handle(scanned, this.registry);
BeanDefinition servletRegistrationBean = this.registry
.getBeanDefinition(DefaultConfigurationServlet.class.getName());
MutablePropertyValues propertyValues = servletRegistrationBean
.getPropertyValues();
assertThat(propertyValues.get("asyncSupported")).isEqualTo(false);
assertThat(((Map<String, String>) propertyValues.get("initParameters")))
.isEmpty();
assertThat((Integer) propertyValues.get("loadOnStartup")).isEqualTo(-1);
assertThat(propertyValues.get("name"))
.isEqualTo(DefaultConfigurationServlet.class.getName());
assertThat((String[]) propertyValues.get("urlMappings")).isEmpty();
assertThat(propertyValues.get("servlet")).isEqualTo(scanned);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:WebServletHandlerTests.java
示例4: defaultFilterConfiguration
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void defaultFilterConfiguration() throws IOException {
ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(
new SimpleMetadataReaderFactory()
.getMetadataReader(DefaultConfigurationFilter.class.getName()));
this.handler.handle(scanned, this.registry);
BeanDefinition filterRegistrationBean = this.registry
.getBeanDefinition(DefaultConfigurationFilter.class.getName());
MutablePropertyValues propertyValues = filterRegistrationBean.getPropertyValues();
assertThat(propertyValues.get("asyncSupported")).isEqualTo(false);
assertThat((EnumSet<DispatcherType>) propertyValues.get("dispatcherTypes"))
.containsExactly(DispatcherType.REQUEST);
assertThat(((Map<String, String>) propertyValues.get("initParameters")))
.isEmpty();
assertThat((String[]) propertyValues.get("servletNames")).isEmpty();
assertThat((String[]) propertyValues.get("urlPatterns")).isEmpty();
assertThat(propertyValues.get("name"))
.isEqualTo(DefaultConfigurationFilter.class.getName());
assertThat(propertyValues.get("filter")).isEqualTo(scanned);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:WebFilterHandlerTests.java
示例5: findConfigurationClasses
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的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;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:AbstractConfigurationClassTests.java
示例6: defaultServletConfiguration
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void defaultServletConfiguration() throws IOException {
ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(
new SimpleMetadataReaderFactory()
.getMetadataReader(DefaultConfigurationServlet.class.getName()));
this.handler.handle(scanned, this.registry);
BeanDefinition servletRegistrationBean = this.registry
.getBeanDefinition(DefaultConfigurationServlet.class.getName());
MutablePropertyValues propertyValues = servletRegistrationBean
.getPropertyValues();
assertThat(propertyValues.get("asyncSupported"), is((Object) false));
assertThat(((Map<String, String>) propertyValues.get("initParameters")).size(),
is(0));
assertThat((Integer) propertyValues.get("loadOnStartup"), is(-1));
assertThat(propertyValues.get("name"),
is((Object) DefaultConfigurationServlet.class.getName()));
assertThat((String[]) propertyValues.get("urlMappings"), is(arrayWithSize(0)));
assertThat(propertyValues.get("servlet"), is(equalTo((Object) scanned)));
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:WebServletHandlerTests.java
示例7: defaultFilterConfiguration
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void defaultFilterConfiguration() throws IOException {
ScannedGenericBeanDefinition scanned = new ScannedGenericBeanDefinition(
new SimpleMetadataReaderFactory()
.getMetadataReader(DefaultConfigurationFilter.class.getName()));
this.handler.handle(scanned, this.registry);
BeanDefinition filterRegistrationBean = this.registry
.getBeanDefinition(DefaultConfigurationFilter.class.getName());
MutablePropertyValues propertyValues = filterRegistrationBean.getPropertyValues();
assertThat(propertyValues.get("asyncSupported"), is((Object) false));
assertThat((EnumSet<DispatcherType>) propertyValues.get("dispatcherTypes"),
is(EnumSet.of(DispatcherType.REQUEST)));
assertThat(((Map<String, String>) propertyValues.get("initParameters")).size(),
is(0));
assertThat((String[]) propertyValues.get("servletNames"), is(arrayWithSize(0)));
assertThat((String[]) propertyValues.get("urlPatterns"), is(arrayWithSize(0)));
assertThat(propertyValues.get("name"),
is((Object) DefaultConfigurationFilter.class.getName()));
assertThat(propertyValues.get("filter"), is(equalTo((Object) scanned)));
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:22,代码来源:WebFilterHandlerTests.java
示例8: testClassesInFileSystem
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
public void testClassesInFileSystem() throws IOException{
PathMatchingResourcePatternResolver pr = new PathMatchingResourcePatternResolver() ;
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(pr);
Resource[] rs = pr.getResources("classpath*:nu/xom/*.class") ;
System.out.println(rs.length) ;
for(Resource r : rs){
if(r.isReadable()){
try{
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(r);
String className = metadataReader.getClassMetadata().getClassName() ;
System.out.println(className) ;
}catch(Exception e){
//Not a class
System.out.println("file:" + r.getURL().toString()) ;
}
}else{
System.out.println("no read:" + r.getFile().getAbsolutePath()) ;
}
}
}
开发者ID:ryanwli,项目名称:guzz,代码行数:24,代码来源:PackageScanTest.java
示例9: postProcessBeanFactory
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
String resolvedPath = resolvePackageToScan();
logger.debug("Scanning '{}' for JSON-RPC service interfaces.", resolvedPath);
try {
for (Resource resource : applicationContext.getResources(resolvedPath)) {
if (resource.isReadable()) {
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
ClassMetadata classMetadata = metadataReader.getClassMetadata();
AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
String jsonRpcPathAnnotation = JsonRpcService.class.getName();
if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
String className = classMetadata.getClassName();
String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
logger.debug("Found JSON-RPC service to proxy [{}] on path '{}'.", className, path);
registerJsonProxyBean(defaultListableBeanFactory, className, path);
}
}
}
} catch (IOException e) {
throw new IllegalStateException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
}
}
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:26,代码来源:AutoJsonRpcClientProxyCreator.java
示例10: postProcessBeanFactory
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory;
String resolvedPath = resolvePackageToScan();
LOG.debug(format("Scanning '%s' for JSON-RPC service interfaces.", resolvedPath));
try {
for (Resource resource : applicationContext.getResources(resolvedPath)) {
if (resource.isReadable()) {
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
ClassMetadata classMetadata = metadataReader.getClassMetadata();
AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
String jsonRpcPathAnnotation = JsonRpcService.class.getName();
if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
String className = classMetadata.getClassName();
String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
boolean useNamedParams = (Boolean) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("useNamedParams");
LOG.debug(format("Found JSON-RPC service to proxy [%s] on path '%s'.", className, path));
registerJsonProxyBean(dlbf, className, path, useNamedParams);
}
}
}
} catch (IOException e) {
throw new RuntimeException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
}
}
开发者ID:esz,项目名称:jsonrpc,代码行数:26,代码来源:AutoJsonRpcClientProxyCreator.java
示例11: MemberConditions
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
MemberConditions(ConditionContext context, String className) {
this.context = context;
this.readerFactory = new SimpleMetadataReaderFactory(
context.getResourceLoader());
String[] members = getMetadata(className).getMemberClassNames();
this.memberConditions = getMemberConditions(members);
}
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:8,代码来源:AbstractNestedCondition.java
示例12: customRequestScopeViaAsm
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的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());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationScopeMetadataResolverTests.java
示例13: customRequestScopeWithAttributeViaAsm
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的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());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationScopeMetadataResolverTests.java
示例14: testDirectAnnotationMatch
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testDirectAnnotationMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeComponent";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
assertTrue(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationTypeFilterTests.java
示例15: testInheritedAnnotationFromInterfaceDoesNotMatch
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testInheritedAnnotationFromInterfaceDoesNotMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubClassOfSomeComponentInterface";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
// Must fail as annotation on interfaces should not be considered a match
assertFalse(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:AnnotationTypeFilterTests.java
示例16: testInheritedAnnotationFromBaseClassDoesMatch
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testInheritedAnnotationFromBaseClassDoesMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubClassOfSomeComponent";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
assertTrue(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationTypeFilterTests.java
示例17: testNonInheritedAnnotationDoesNotMatch
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testNonInheritedAnnotationDoesNotMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(NonInheritedAnnotation.class);
// Must fail as annotation isn't inherited
assertFalse(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:AnnotationTypeFilterTests.java
示例18: testNonAnnotatedClassDoesntMatch
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testNonAnnotatedClassDoesntMatch() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeNonCandidateClass";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(Component.class);
assertFalse(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationTypeFilterTests.java
示例19: testMatchesInterfacesIfConfigured
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的package包/类
@Test
public void testMatchesInterfacesIfConfigured() throws Exception {
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeComponentInterface";
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);
AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class, false, true);
assertTrue(filter.match(metadataReader, metadataReaderFactory));
ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AnnotationTypeFilterTests.java
示例20: asmAnnotationMetadata
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; //导入依赖的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);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AnnotationMetadataTests.java
注:本文中的org.springframework.core.type.classreading.SimpleMetadataReaderFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论