Search in sources :

Example 6 with AnnotatedBeanDefinition

use of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition in project spring-framework by spring-projects.

the class AnnotationScopeMetadataResolverTests method customRequestScopeViaAsm.

@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());
}
Also used : MetadataReaderFactory(org.springframework.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) MetadataReader(org.springframework.core.type.classreading.MetadataReader) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 7 with AnnotatedBeanDefinition

use of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition in project spring-framework by spring-projects.

the class AnnotationScopeMetadataResolverTests method customRequestScopeWithAttributeViaAsm.

@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());
}
Also used : MetadataReaderFactory(org.springframework.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) SimpleMetadataReaderFactory(org.springframework.core.type.classreading.SimpleMetadataReaderFactory) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) MetadataReader(org.springframework.core.type.classreading.MetadataReader) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 8 with AnnotatedBeanDefinition

use of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition in project spring-framework by spring-projects.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation.

@Test
public void resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithScopedProxy.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
Also used : AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 9 with AnnotatedBeanDefinition

use of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition in project spring-framework by spring-projects.

the class AnnotationScopeMetadataResolverTests method customRequestScopeWithAttribute.

@Test
public void customRequestScopeWithAttribute() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScopeWithAttributeOverride.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
Also used : AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Example 10 with AnnotatedBeanDefinition

use of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition in project spring-framework by spring-projects.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldApplyScopedProxyModeToPrototype.

@Test
public void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(INTERFACES);
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals(BeanDefinition.SCOPE_PROTOTYPE, scopeMetadata.getScopeName());
    assertEquals(INTERFACES, scopeMetadata.getScopedProxyMode());
}
Also used : AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.Test)

Aggregations

AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)24 Test (org.junit.Test)17 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)16 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)9 SimpleBeanDefinitionRegistry (org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry)9 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)4 MetadataReader (org.springframework.core.type.classreading.MetadataReader)3 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)2 MetadataReaderFactory (org.springframework.core.type.classreading.MetadataReaderFactory)2 SimpleMetadataReaderFactory (org.springframework.core.type.classreading.SimpleMetadataReaderFactory)2 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)1 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)1 ClassPathBeanDefinitionScanner (org.springframework.context.annotation.ClassPathBeanDefinitionScanner)1 ScopeMetadata (org.springframework.context.annotation.ScopeMetadata)1 ScopeMetadataResolver (org.springframework.context.annotation.ScopeMetadataResolver)1 AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)1 Order (org.springframework.core.annotation.Order)1