1 package org.riotfamily.common.web.servlet; 2 3 import java.io.IOException ; 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import org.springframework.beans.factory.BeanDefinitionStoreException; 8 import org.springframework.beans.factory.support.DefaultListableBeanFactory; 9 import org.springframework.beans.factory.xml.ResourceEntityResolver; 10 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; 11 import org.springframework.core.io.Resource; 12 import org.springframework.web.context.support.XmlWebApplicationContext; 13 import org.xml.sax.InputSource ; 14 15 22 public class ResourceAwareContext extends XmlWebApplicationContext { 23 24 private ArrayList configResources; 25 26 protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) 27 throws IOException { 28 29 configResources = new ArrayList (); 30 31 XmlBeanDefinitionReader beanDefinitionReader = 32 new XmlBeanDefinitionReader(beanFactory) { 33 34 protected int doLoadBeanDefinitions(InputSource inputSource, 35 Resource resource) throws BeanDefinitionStoreException { 36 37 configResources.add(resource); 38 return super.doLoadBeanDefinitions(inputSource, resource); 39 } 40 }; 41 42 beanDefinitionReader.setResourceLoader(this); 43 beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); 44 initBeanDefinitionReader(beanDefinitionReader); 45 loadBeanDefinitions(beanDefinitionReader); 46 } 47 48 public List getConfigResources() { 49 return configResources; 50 } 51 52 } 53 | Popular Tags |