List of usage examples for org.springframework.beans.factory.xml XmlBeanDefinitionReader setDocumentLoader
public void setDocumentLoader(@Nullable DocumentLoader documentLoader)
From source file:edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils.java
/** * Loads a set of spring configuration resources into a given application context. * /*from w w w . j av a 2s .co m*/ * @param beanRegistry registry of spring beans to be populated with information from the given configurations * @param configurationResources list of spring configuration resources * * @throws ResourceException thrown if there is a problem reading the spring configuration resources into the * registry */ public static void populateRegistry(BeanDefinitionRegistry beanRegistry, List<Resource> configurationResources) throws ResourceException { XmlBeanDefinitionReader configReader = new XmlBeanDefinitionReader(beanRegistry); configReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); configReader.setDocumentLoader(new SpringDocumentLoader()); int numOfResources = configurationResources.size(); Resource configurationResource; org.springframework.core.io.Resource[] configSources = new org.springframework.core.io.Resource[numOfResources]; for (int i = 0; i < numOfResources; i++) { configurationResource = configurationResources.get(i); if (configurationResource != null && configurationResource.exists()) { configSources[i] = new InputStreamResource(configurationResources.get(i).getInputStream(), configurationResource.getLocation()); } else { log.warn("Configuration resource not loaded because it does not exist: {}", configurationResource.getLocation()); } } try { configReader.loadBeanDefinitions(configSources); } catch (BeanDefinitionStoreException e) { throw new ResourceException("Unable to load Spring bean registry with configuration resources", e); } }