Examples of AnnotatedGenericBeanDefinition


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

   * (non-Javadoc)
   * @see org.springframework.beans.factory.support.BeanNameGenerator#generateBeanName(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)
   */
  public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {

    AnnotatedBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(getRepositoryInterfaceFrom(definition));
    return DELEGATE.generateBeanName(beanDefinition, registry);
  }
View Full Code Here

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

  public void registerBean(Class<?> annotatedClass, Class<? extends Annotation>... qualifiers) {
    registerBean(annotatedClass, null, qualifiers);
  }

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();

    if (ProfileHelper.isProfileAnnotationPresent(metadata)) {
      if (!this.environment.acceptsProfiles(ProfileHelper.getCandidateProfiles(metadata))) {
        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);
    definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
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);
    String className = metadata.getClassName();
    configBeanDef.setBeanClassName(className);
    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, Class<? extends Annotation>... qualifiers) {
    registerBean(annotatedClass, null, qualifiers);
  }

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();
    if (metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        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);
    definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
View Full Code Here

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

  public void testGenerateBeanNameWithNamedComponent() {
    MockControl control = MockControl.createControl(BeanDefinitionRegistry.class);
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) control.getMock();
    control.replay();

    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

  public void testGenerateBeanNameWithDefaultNamedComponent() {
    MockControl control = MockControl.createControl(BeanDefinitionRegistry.class);
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) control.getMock();
    control.replay();

    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

  public void testGenerateBeanNameWithNamedComponentWhereTheNameIsBlank() {
    MockControl control = MockControl.createControl(BeanDefinitionRegistry.class);
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) control.getMock();
    control.replay();

    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);
View Full Code Here

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

  public void testGenerateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
    MockControl control = MockControl.createControl(BeanDefinitionRegistry.class);
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) control.getMock();
    control.replay();

    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);
View Full Code Here

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

    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver();
  }


  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

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

  }


  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
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.