Search in sources :

Example 1 with ResourceEntityResolver

use of org.springframework.beans.factory.xml.ResourceEntityResolver in project spring-framework by spring-projects.

the class XmlWebApplicationContext method loadBeanDefinitions.

/**
	 * Loads the bean definitions via an XmlBeanDefinitionReader.
	 * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
	 * @see #initBeanDefinitionReader
	 * @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(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);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) ResourceEntityResolver(org.springframework.beans.factory.xml.ResourceEntityResolver)

Example 2 with ResourceEntityResolver

use of org.springframework.beans.factory.xml.ResourceEntityResolver in project spring-framework by spring-projects.

the class AbstractXmlApplicationContext method loadBeanDefinitions.

/**
	 * Loads the bean definitions via an XmlBeanDefinitionReader.
	 * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
	 * @see #initBeanDefinitionReader
	 * @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);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) ResourceEntityResolver(org.springframework.beans.factory.xml.ResourceEntityResolver)

Example 3 with ResourceEntityResolver

use of org.springframework.beans.factory.xml.ResourceEntityResolver in project spring-framework by spring-projects.

the class XmlViewResolver method initFactory.

/**
	 * Initialize the view bean factory from the XML file.
	 * Synchronized because of access by parallel threads.
	 * @throws BeansException in case of initialization errors
	 */
protected synchronized BeanFactory initFactory() throws BeansException {
    if (this.cachedFactory != null) {
        return this.cachedFactory;
    }
    Resource actualLocation = this.location;
    if (actualLocation == null) {
        actualLocation = getApplicationContext().getResource(DEFAULT_LOCATION);
    }
    // Create child ApplicationContext for views.
    GenericWebApplicationContext factory = new GenericWebApplicationContext();
    factory.setParent(getApplicationContext());
    factory.setServletContext(getServletContext());
    // Load XML resource with context-aware entity resolver.
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
    reader.setEnvironment(getApplicationContext().getEnvironment());
    reader.setEntityResolver(new ResourceEntityResolver(getApplicationContext()));
    reader.loadBeanDefinitions(actualLocation);
    factory.refresh();
    if (isCache()) {
        this.cachedFactory = factory;
    }
    return factory;
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) Resource(org.springframework.core.io.Resource) ResourceEntityResolver(org.springframework.beans.factory.xml.ResourceEntityResolver) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext)

Example 4 with ResourceEntityResolver

use of org.springframework.beans.factory.xml.ResourceEntityResolver in project cxf by apache.

the class BusApplicationContext method loadBeanDefinitions.

@Override
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException {
    // Create a new XmlBeanDefinitionReader for the given BeanFactory.
    XmlBeanDefinitionReader beanDefinitionReader = new ControlledValidationXmlBeanDefinitionReader(beanFactory);
    beanDefinitionReader.setNamespaceHandlerResolver(nsHandlerResolver);
    // Configure the bean definition reader with this context's
    // resource loading environment.
    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);
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) ResourceEntityResolver(org.springframework.beans.factory.xml.ResourceEntityResolver)

Aggregations

ResourceEntityResolver (org.springframework.beans.factory.xml.ResourceEntityResolver)4 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)4 Resource (org.springframework.core.io.Resource)1 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)1