Package org.springframework.beans.factory.annotation

Examples of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition


  }


  public void testThatResolveScopeMetadataDoesApplyScopedProxyModeToAPrototype() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(ScopedProxyMode.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(ScopedProxyMode.INTERFACES, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here


public class SitemapNodeNameGenerator implements BeanNameGenerator {

    public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        if (definition instanceof AnnotatedBeanDefinition) {
            AnnotatedBeanDefinition annotatedBeanDefinition = (AnnotatedBeanDefinition) definition;
            Map<String, Object> annotationAttributes = annotatedBeanDefinition.getMetadata().getAnnotationAttributes(
                    Node.class.getName());

            if (annotationAttributes == null || annotationAttributes.get("name") == null) {
                return null;
            }
View Full Code Here

  }


  @Test
  public void testThatResolveScopeMetadataDoesNotApplyScopedProxyModeToASingleton() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithSingletonScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals(BeanDefinition.SCOPE_SINGLETON, scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

  }

  @Test
  public void testThatResolveScopeMetadataDoesApplyScopedProxyModeToAPrototype() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(ScopedProxyMode.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(ScopedProxyMode.INTERFACES, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

  }

  @Test
  public void testThatResolveScopeMetadataDoesReadScopedProxyModeFromTheAnnotation() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithScopedProxy.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

    assertEquals(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
  }

  @Test
  public void testCustomRequestScope() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

  @Test
  public void testCustomRequestScopeViaAsm() 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(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

    assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
  }

  @Test
  public void testCustomRequestScopeWithAttribute() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScopeWithAttribute.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
    assertEquals("request", scopeMetadata.getScopeName());
    assertEquals(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

  @Test
  public void testCustomRequestScopeWithAttributeViaAsm() throws IOException {
    MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
    MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttribute.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(ScopedProxyMode.TARGET_CLASS, scopeMetadata.getScopedProxyMode());
  }
View Full Code Here

    scanner.setScopeMetadataResolver(new ScopeMetadataResolver() {
      @Override
      public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
        ScopeMetadata metadata = new ScopeMetadata();
        if (definition instanceof AnnotatedBeanDefinition) {
          AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
          for (String type : annDef.getMetadata().getAnnotationTypes()) {
            if (type.equals(javax.inject.Singleton.class.getName())) {
              metadata.setScopeName(BeanDefinition.SCOPE_SINGLETON);
              break;
            }
            else if (annDef.getMetadata().getMetaAnnotationTypes(type).contains(javax.inject.Scope.class.getName())) {
              metadata.setScopeName(type.substring(type.length() - 13, type.length() - 6).toLowerCase());
              metadata.setScopedProxyMode(scopedProxyMode);
              break;
            }
            else if (type.startsWith("javax.inject")) {
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.annotation.AnnotatedBeanDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.