Examples of BeanDefinitionReader


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

      ConfigurableApplicationContext context = moduleLoader.newApplicationContext(parent, definition, classLoader);
      ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
      addBeanPostProcessors(definition, beanFactory);
     
      BeanDefinitionReader reader = moduleLoader.newBeanDefinitionReader(context, definition);

      if (reader != null) {
        //if this is null, then we assume moduleLoader or refresh takes care of this
       
        if (reader instanceof AbstractBeanDefinitionReader) {
          ((AbstractBeanDefinitionReader) reader).setBeanClassLoader(classLoader);
        }
 
        final Resource[] resources = moduleLoader.getSpringConfigResources(definition, classLoader);
        reader.loadBeanDefinitions(resources);
      }

      moduleLoader.handleRefresh(context);
      return context;
    }
View Full Code Here

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

      String resource = entry.getKey();
      Class<?> readerClass = entry.getValue();
      if (!readerInstanceCache.containsKey(readerClass)) {
        try {
          // Instantiate the specified BeanDefinitionReader
          BeanDefinitionReader readerInstance = (BeanDefinitionReader)
              readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry);

          // Delegate the current ResourceLoader to it if possible
          if (readerInstance instanceof AbstractBeanDefinitionReader) {
            ((AbstractBeanDefinitionReader)readerInstance).setResourceLoader(this.resourceLoader);
          }

          readerInstanceCache.put(readerClass, readerInstance);
        }
        catch (Exception ex) {
          throw new IllegalStateException("Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
        }
      }
      BeanDefinitionReader reader = readerInstanceCache.get(readerClass);
      // TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
      reader.loadBeanDefinitions(resource);
    }
  }
View Full Code Here

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

      if (!existingResourceList.contains(resource)) {
        toAddList.add(resource);
      }
    }

    BeanDefinitionReader beanDefinitionReader = moduleLoader.newBeanDefinitionReader(parentContext,
        newRootDefinition);
    beanDefinitionReader.loadBeanDefinitions(toAddList.toArray(new Resource[toAddList.size()]));

    return true;
  }
View Full Code Here

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

      String resource = entry.getKey();
      Class<? extends BeanDefinitionReader> readerClass = entry.getValue();
      if (!readerInstanceCache.containsKey(readerClass)) {
        try {
          // Instantiate the specified BeanDefinitionReader
          BeanDefinitionReader readerInstance =
              readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry);
          // Delegate the current ResourceLoader to it if possible
          if (readerInstance instanceof AbstractBeanDefinitionReader) {
            AbstractBeanDefinitionReader abdr = ((AbstractBeanDefinitionReader) readerInstance);
            abdr.setResourceLoader(this.resourceLoader);
            abdr.setEnvironment(this.environment);
          }
          readerInstanceCache.put(readerClass, readerInstance);
        }
        catch (Exception ex) {
          throw new IllegalStateException("Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
        }
      }
      BeanDefinitionReader reader = readerInstanceCache.get(readerClass);
      // TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
      reader.loadBeanDefinitions(resource);
    }
  }
View Full Code Here

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

  }

  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

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

      "classpath:org/springframework/beans/factory/annotation/customAutowireConfigurer.xml";


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

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

      "classpath:org/springframework/beans/factory/xml/qualifierAnnotationTests.xml";


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

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

    }
  }

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

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

    assertEquals("Larry", person.getName());
  }

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

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

    assertEquals("LarryBean", person.getName());
  }

  public void testQualifiedByAlias() {
    StaticApplicationContext context = new StaticApplicationContext();
    BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
    reader.loadBeanDefinitions(CONFIG_LOCATION);
    context.registerSingleton("testBean", QualifiedByAliasTestBean.class);
    context.refresh();
    QualifiedByAliasTestBean testBean = (QualifiedByAliasTestBean) context.getBean("testBean");
    Person person = testBean.getStooge();
    assertEquals("LarryBean", person.getName());   
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.