Examples of AnnotatedGenericBeanDefinition


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

  @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

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

  /**
   * Register the {@link Configuration} class itself as a bean definition.
   */
  private void registerBeanDefinitionForImportedConfigurationClass(ConfigurationClass configClass) {
    AnnotationMetadata metadata = configClass.getMetadata();
    BeanDefinition configBeanDef = new AnnotatedGenericBeanDefinition(metadata);
    if (ConfigurationClassUtils.checkConfigurationClassCandidate(configBeanDef, this.metadataReaderFactory)) {
      String configBeanName = this.importBeanNameGenerator.generateBeanName(configBeanDef, this.registry);
      this.registry.registerBeanDefinition(configBeanName, configBeanDef);
      configClass.setBeanName(configBeanName);
      if (logger.isDebugEnabled()) {
View Full Code Here

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

  }

  public void registerBean(Class<?> annotatedClass, String name,
      @SuppressWarnings("unchecked") Class<? extends Annotation>... qualifiers) {

    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) {
      return;
    }

    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
    abd.setScope(scopeMetadata.getScopeName());
    String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, this.registry));
    AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
    if (qualifiers != null) {
      for (Class<? extends Annotation> qualifier : qualifiers) {
        if (Primary.class.equals(qualifier)) {
          abd.setPrimary(true);
        }
        else if (Lazy.class.equals(qualifier)) {
          abd.setLazyInit(true);
        }
        else {
          abd.addQualifier(new AutowireCandidateQualifier(qualifier));
        }
      }
    }

    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd, beanName);
View Full Code Here

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


  @Test
  public void generateBeanNameWithNamedComponent() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertNotNull("The generated beanName must *never* be null.", beanName);
    assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
    assertEquals("walden", beanName);
  }
View Full Code Here

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

  }

  @Test
  public void generateBeanNameWithDefaultNamedComponent() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(DefaultNamedComponent.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertNotNull("The generated beanName must *never* be null.", beanName);
    assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
    assertEquals("thoreau", beanName);
  }
View Full Code Here

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

  }

  @Test
  public void generateBeanNameWithNamedComponentWhereTheNameIsBlank() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithBlankName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertNotNull("The generated beanName must *never* be null.", beanName);
    assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertEquals(expectedGeneratedBeanName, beanName);
View Full Code Here

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

  }

  @Test
  public void generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnonymousComponent.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertNotNull("The generated beanName must *never* be null.", beanName);
    assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertEquals(expectedGeneratedBeanName, beanName);
View Full Code Here

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

  }

  @Test
  public void generateBeanNameFromMetaComponentWithStringValue() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromStringMeta.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertEquals("henry", beanName);
  }
View Full Code Here

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

  }

  @Test
  public void generateBeanNameFromMetaComponentWithNonStringValue() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromNonStringMeta.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertEquals("annotationBeanNameGeneratorTests.ComponentFromNonStringMeta", beanName);
  }
View Full Code Here

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

   * @see https://jira.spring.io/browse/SPR-11360
   */
  @Test
  public void generateBeanNameFromComposedControllerAnnotationWithoutName() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithoutName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertEquals(expectedGeneratedBeanName, beanName);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.