Examples of SimpleBeanDefinitionRegistry


Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

    assertEquals("walden", beanName);
  }

  @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.support.SimpleBeanDefinitionRegistry

    assertEquals("thoreau", beanName);
  }

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

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

    assertEquals(expectedGeneratedBeanName, beanName);
  }

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

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

    assertEquals(expectedGeneratedBeanName, beanName);
  }

  @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.support.SimpleBeanDefinitionRegistry

    assertEquals("henry", beanName);
  }

  @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.support.SimpleBeanDefinitionRegistry

   * @since 4.0.1
   * @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

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

   * @since 4.0.1
   * @see https://jira.spring.io/browse/SPR-11360
   */
  @Test
  public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
    assertEquals(expectedGeneratedBeanName, beanName);
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

   * @since 4.0.1
   * @see https://jira.spring.io/browse/SPR-11360
   */
  @Test
  public void generateBeanNameFromComposedControllerAnnotationWithStringValue() {
    BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(
      ComposedControllerAnnotationWithStringValue.class);
    String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
    assertEquals("restController", beanName);
  }
View Full Code Here

Examples of org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry

        // Disable xml validation
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setValidating(false);

        // Read configuration
        BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
        reader.setNamespaceAware(true);
        reader.loadBeanDefinitions(new ClassPathResource(connection.getPath()));

        Properties props = connection.getProperties();
        Class<? extends LocalSessionFactoryBean> beanClass = LocalSessionFactoryBean.class;

        String beanName = props.getProperty("bean", null);
        String beanClassName = props.getProperty("beanClass", null);

        if (beanClassName != null) {
            beanClass = findClass(beanClassName, beanClass);
        }

        if (beanName == null) {
            throw new IllegalStateException("A 'bean' name is required, matching a '" + beanClassName + "' definition in '" + connection.getPath() + "'.");
        }

        BeanDefinition beanDef = registry.getBeanDefinition(beanName);
        if (beanDef == null) {
            throw new IllegalStateException("A bean named '" + beanName + "' could not be found in '" + connection.getPath() + "'.");
        }

        MutablePropertyValues properties = beanDef.getPropertyValues();
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.