1 16 17 package org.springframework.web.portlet.context; 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 26 61 public class XmlPortletApplicationContext extends AbstractRefreshablePortletApplicationContext { 62 63 64 public static final String DEFAULT_CONFIG_LOCATION = "/WEB-INF/applicationContext.xml"; 65 66 67 public static final String DEFAULT_CONFIG_LOCATION_PREFIX = "/WEB-INF/"; 68 69 70 public static final String DEFAULT_CONFIG_LOCATION_SUFFIX = ".xml"; 71 72 73 79 protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException { 80 XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); 82 83 beanDefinitionReader.setResourceLoader(this); 86 beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); 87 88 initBeanDefinitionReader(beanDefinitionReader); 91 loadBeanDefinitions(beanDefinitionReader); 92 } 93 94 103 protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { 104 } 105 106 119 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException { 120 String [] configLocations = getConfigLocations(); 121 if (configLocations != null) { 122 for (int i = 0; i < configLocations.length; i++) { 123 reader.loadBeanDefinitions(configLocations[i]); 124 } 125 } 126 } 127 128 133 protected String [] getDefaultConfigLocations() { 134 if (getNamespace() != null) { 135 return new String [] {DEFAULT_CONFIG_LOCATION_PREFIX + getNamespace() + DEFAULT_CONFIG_LOCATION_SUFFIX}; 136 } 137 else { 138 return new String [] {DEFAULT_CONFIG_LOCATION}; 139 } 140 } 141 142 } 143 | Popular Tags |