Spring Framework XmlBeanDefinitionReader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework XmlBeanDefinitionReader class.

This code example shows how to use the following methods:setEntityResolver, setValidating, XmlBeanDefinitionReader.loadBeanDefinitions, loadBeanDefinitions, setEnvironment
	 * @see #loadBeanDefinitions 
	 */ 
	@Override 
	protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
		// Create a new XmlBeanDefinitionReader for the given BeanFactory. 
		XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
 
		// Configure the bean definition reader with this context's 
		// resource loading environment. 
		beanDefinitionReader.setEnvironment(this.getEnvironment());
		beanDefinitionReader.setResourceLoader(this);
		beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
		// Allow a subclass to provide custom initialization of the reader, 
		// then proceed with actually loading the bean definitions. 
		initBeanDefinitionReader(beanDefinitionReader);
		loadBeanDefinitions(beanDefinitionReader);
	} 
 
	/** 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setEntityResolver, setEnvironment, setResourceLoader
	 * @see #loadBeanDefinitions 
	 */ 
	@Override 
	protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
		// Create a new XmlBeanDefinitionReader for the given BeanFactory. 
		XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
 
		// Configure the bean definition reader with this context's 
		// resource loading environment. 
		beanDefinitionReader.setEnvironment(this.getEnvironment());
		beanDefinitionReader.setResourceLoader(this);
		beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
 
		// Allow a subclass to provide custom initialization of the reader, 
		// then proceed with actually loading the bean definitions. 
		initBeanDefinitionReader(beanDefinitionReader);
		loadBeanDefinitions(beanDefinitionReader);
	} 
 
	/** 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadBeanDefinitions
		String[] scopeNames = beanFactory.getRegisteredScopeNames();
		assertEquals(1, scopeNames.length);
		assertEquals("myScope", scopeNames[0]);
		assertSame(scope, beanFactory.getRegisteredScope("myScope"));
 
		XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(beanFactory);
		xbdr.loadBeanDefinitions(CONTEXT);
	} 
 
	@Test
	public void testCanGetScopedObject() { 
		TestBean tb1 = (TestBean) beanFactory.getBean("usesScope");
		TestBean tb2 = (TestBean) beanFactory.getBean("usesScope");
		assertNotSame(tb1, tb2);
		TestBean tb3 = (TestBean) beanFactory.getBean("usesScope");
		assertSame(tb3, tb1);
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadBeanDefinitions
	 * @see AbstractGenericWebContextLoader#loadBeanDefinitions 
	 */ 
	@Override 
	protected void loadBeanDefinitions(GenericWebApplicationContext context,
			WebMergedContextConfiguration webMergedConfig) {
		new XmlBeanDefinitionReader(context).loadBeanDefinitions(webMergedConfig.getLocations());
	} 
 
	/** 
	 * Returns {@code "-context.xml"} in order to support detection of a 
	 * default XML config file. 
	 */ 
	@Override 
	protected String getResourceSuffix() {
		return "-context.xml"; 
	} 
 
	/** 
	 * Ensure that the supplied {@link WebMergedContextConfiguration} does not 
	 * contain {@link MergedContextConfiguration#getClasses() classes}. 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setProblemReporter
 
	@Before 
	public void setUp() { 
		this.problemReporter = new CollatingProblemReporter();
		this.beanFactory = new DefaultListableBeanFactory();
		this.reader = new XmlBeanDefinitionReader(this.beanFactory);
		this.reader.setProblemReporter(this.problemReporter);
	} 
 
	@Test
	public void testErrorsAreCollated() { 
		this.reader.loadBeanDefinitions(CONTEXT);
		assertEquals("Incorrect number of errors collated", 4, this.problemReporter.getErrors().length);
 
		TestBean bean = (TestBean) this.beanFactory.getBean("validBean");
		assertNotNull(bean);
	} 
 
 
	private static class CollatingProblemReporter implements ProblemReporter {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	private BeanFactory beanFactory;
 
	@Before 
	public void setUp() throws Exception {
		this.beanFactory = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
	} 
 
	/** 
	 * Test that multiple invocations of the prototype bean will result 
	 * in no change to visible state, as a new instance is used. 
	 * With the singleton, there will be change. 
	 */ 
	@Test
	public void testPrototypeAndSingletonBehaveDifferently() { 
		SideEffectBean singleton = (SideEffectBean) beanFactory.getBean("singleton");
		assertEquals(INITIAL_COUNT, singleton.getCount() );
		singleton.doWork();
		assertEquals(INITIAL_COUNT + 1, singleton.getCount() );
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadBeanDefinitions
	} 
 
	protected DefaultListableBeanFactory getBeanFactory() {
 
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
		reader.loadBeanDefinitions(new ClassPathResource("auditing/" + getConfigFile()));
 
		return beanFactory;
	} 
 
	@Test
	public void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() throws Exception {
 
		processor.postProcessBeanFactory(beanFactory);
 
		assertThat(beanFactory.isBeanNameInUse(AuditingBeanFactoryPostProcessor.BEAN_CONFIGURER_ASPECT_BEAN_NAME), is(true));
	} 
 
	/** 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	 * Create a new {@link XmlBeanDefinitionReader}. 
	 * @return a new {@code XmlBeanDefinitionReader} 
	 */ 
	@Override 
	protected BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context) {
		return new XmlBeanDefinitionReader(context);
	} 
 
	/** 
	 * Returns {@code "-context.xml"} in order to support detection of a 
	 * default XML config file. 
	 */ 
	@Override 
	protected String getResourceSuffix() {
		return "-context.xml"; 
	} 
 
	/** 
	 * Ensure that the supplied {@link MergedContextConfiguration} does not 
	 * contain {@link MergedContextConfiguration#getClasses() classes}. 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadBeanDefinitions
This code example shows how to use the following methods:loadBeanDefinitions, setDocumentReaderClass
            getLogger().info("Creating new lazily initialized GenericApplicationContext for the portal"); 
 
            final long startTime = System.currentTimeMillis(); 
 
            final GenericApplicationContext genericApplicationContext = new GenericApplicationContext(); 
            final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(genericApplicationContext); 
            reader.setDocumentReaderClass(LazyInitByDefaultBeanDefinitionDocumentReader.class); 
            reader.loadBeanDefinitions("/properties/contexts/*.xml"); 
 
            genericApplicationContext.refresh(); 
            genericApplicationContext.registerShutdownHook(); 
 
            directCreatorThrowable = new Throwable(); 
            directCreatorThrowable.fillInStackTrace(); 
            getLogger().info("Created new lazily initialized GenericApplicationContext for the portal in " 
                    + (System.currentTimeMillis() - startTime) + "ms"); 
 
            return genericApplicationContext; 
        } 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework XmlBeanDefinitionReader Methods: