1 16 17 package org.springframework.context.support; 18 19 import java.io.IOException ; 20 21 import org.springframework.beans.BeansException; 22 import org.springframework.beans.factory.support.DefaultListableBeanFactory; 23 import org.springframework.beans.factory.xml.ResourceEntityResolver; 24 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; 25 import org.springframework.context.ApplicationContext; 26 import org.springframework.core.io.Resource; 27 28 45 public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext { 46 47 50 public AbstractXmlApplicationContext() { 51 } 52 53 57 public AbstractXmlApplicationContext(ApplicationContext parent) { 58 super(parent); 59 } 60 61 67 protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException { 68 XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); 70 71 beanDefinitionReader.setResourceLoader(this); 74 beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); 75 76 initBeanDefinitionReader(beanDefinitionReader); 79 loadBeanDefinitions(beanDefinitionReader); 80 } 81 82 90 protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { 91 } 92 93 105 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException { 106 Resource[] configResources = getConfigResources(); 107 if (configResources != null) { 108 reader.loadBeanDefinitions(configResources); 109 } 110 String [] configLocations = getConfigLocations(); 111 if (configLocations != null) { 112 reader.loadBeanDefinitions(configLocations); 113 } 114 } 115 116 124 protected Resource[] getConfigResources() { 125 return null; 126 } 127 128 138 protected String [] getConfigLocations() { 139 return null; 140 } 141 142 } 143 | Popular Tags |