Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.BeanDefinitionReader.loadBeanDefinitions()


  }

  public void testQualifiedByCustomValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByCustomValueTestBean.class);
    context.refresh();
    QualifiedByCustomValueTestBean testBean = (QualifiedByCustomValueTestBean) context.getBean("testBean");
    Person person = testBean.getCurly();
    assertEquals("Curly", person.getName());
View Full Code Here


  }

  public void testQualifiedByAnnotationValue() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAnnotationValueTestBean.class);
    context.refresh();
    QualifiedByAnnotationValueTestBean testBean = (QualifiedByAnnotationValueTestBean) context.getBean("testBean");
    Person person = testBean.getLarry();
    assertEquals("LarrySpecial", person.getName());
View Full Code Here

  }

  public void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAttributesTestBean.class);
    try {
      context.refresh();
      fail("should have thrown a BeanCreationException");
    }
View Full Code Here

  }

  public void testQualifiedByAttributesWithCustomQualifierRegistered() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    QualifierAnnotationAutowireCandidateResolver resolver = (QualifierAnnotationAutowireCandidateResolver)
        context.getDefaultListableBeanFactory().getAutowireCandidateResolver();
    resolver.addQualifierType(MultipleAttributeQualifier.class);
    context.registerSingleton("testBean", QualifiedByAttributesTestBean.class);
    context.refresh();
View Full Code Here

      List resources = new ArrayList();
      for (int j = 0; j < resourceURLs.length; j++) {
        resources.add(new UrlResource(resourceURLs[j]));
      }

      count += reader.loadBeanDefinitions((Resource[]) resources
          .toArray(new Resource[resources.size()]));
    }

    if (log.isDebugEnabled()) {
      log.debug("loaded beans count: [" + count + "]");
View Full Code Here

        // Communicate mule context to parsers
        try
        {
            currentMuleContext.set(muleContext);
            beanDefinitionReader.loadBeanDefinitions(springResources);
        }
        finally
        {
            currentMuleContext.remove();
        }
View Full Code Here

  @Test
  public void testCustomResolver() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
    reader.loadBeanDefinitions(CONTEXT);
    CustomAutowireConfigurer cac = new CustomAutowireConfigurer();
    CustomResolver customResolver = new CustomResolver();
    bf.setAutowireCandidateResolver(customResolver);
    cac.postProcessBeanFactory(bf);
    TestBean testBean = (TestBean) bf.getBean("testBean");
View Full Code Here

              "Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
        }
      }

      // TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
      reader.loadBeanDefinitions(resource);
    }
  }

  private void loadBeanDefinitionsFromRegistrars(Map<ImportBeanDefinitionRegistrar, AnnotationMetadata> registrars) {
    for (Map.Entry<ImportBeanDefinitionRegistrar, AnnotationMetadata> entry : registrars.entrySet()) {
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    this.beanFactory = new DefaultListableBeanFactory();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
    reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass()));
  }

  public void testMergeList() throws Exception {
    TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
    List list = bean.getSomeList();
View Full Code Here

  @Test
  public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
    GenericWebApplicationContext ac = new GenericWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(ac);
    reader.loadBeanDefinitions(new ClassPathResource("view.properties", getClass()));
    ac.refresh();

    AbstractJasperReportsView view = (AbstractJasperReportsView) ac.getBean("report");
    String encoding = (String) view.getConvertedExporterParameters().get(JRHtmlExporterParameter.CHARACTER_ENCODING);
    assertEquals("UTF-8", encoding);
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.