List of usage examples for org.springframework.beans.factory.xml XmlBeanDefinitionReader getResourceLoader
@Override
@Nullable
public ResourceLoader getResourceLoader()
From source file:com.trigonic.utils.spring.beans.ImportHelper.java
private static void importAbsoluteResource(XmlBeanDefinitionReader reader, String location, Set<Resource> actualResources) { ResourceLoader resourceLoader = reader.getResourceLoader(); if (resourceLoader == null) { throw new BeanDefinitionStoreException( "Cannot import bean definitions from location [" + location + "]: no ResourceLoader available"); }//from w w w . j a v a2 s . c o m if (resourceLoader instanceof ResourcePatternResolver) { importAbsoluteResourcePattern(reader, location, actualResources, (ResourcePatternResolver) resourceLoader); } else { importSingleAbsoluteResource(reader, location, actualResources, resourceLoader); } }
From source file:org.kuali.rice.krad.datadictionary.validator.Validator.java
/** * Loads the Spring Beans from a list of xml files * * @param xmlFiles/*www . j a v a2s .c om*/ * @return The Spring Bean Factory for the provided list of xml files */ public DefaultListableBeanFactory loadBeans(String[] xmlFiles) { LOG.info("Starting XML File Load"); DefaultListableBeanFactory beans = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(beans); DataDictionary.setupProcessor(beans); ArrayList<String> coreFiles = new ArrayList<String>(); ArrayList<String> testFiles = new ArrayList<String>(); for (int i = 0; i < xmlFiles.length; i++) { if (xmlFiles[i].contains("classpath")) { coreFiles.add(xmlFiles[i]); } else { testFiles.add(xmlFiles[i]); } } String core[] = new String[coreFiles.size()]; coreFiles.toArray(core); String test[] = new String[testFiles.size()]; testFiles.toArray(test); try { xmlReader.loadBeanDefinitions(core); } catch (Exception e) { LOG.error("Error loading bean definitions", e); throw new DataDictionaryException("Error loading bean definitions: " + e.getLocalizedMessage(), e); } try { xmlReader.loadBeanDefinitions(getResources(test)); } catch (Exception e) { LOG.error("Error loading bean definitions", e); throw new DataDictionaryException("Error loading bean definitions: " + e.getLocalizedMessage(), e); } UifBeanFactoryPostProcessor factoryPostProcessor = new UifBeanFactoryPostProcessor(); factoryPostProcessor.postProcessBeanFactory(beans); tracerTemp = new ValidationTrace(xmlFiles, xmlReader.getResourceLoader()); LOG.info("Completed XML File Load"); return beans; }