List of usage examples for org.springframework.core.io.support PropertiesLoaderUtils loadAllProperties
public static Properties loadAllProperties(String resourceName, @Nullable ClassLoader classLoader) throws IOException
From source file:org.solmix.runtime.support.spring.ContainerEntityResolver.java
public ContainerEntityResolver(ClassLoader loader, EntityResolver dr, EntityResolver sr) { super(dr, sr); classLoader = loader;// w w w . ja v a 2 s. co m dtdResolver = dr; schemaResolver = sr; try { Properties mappings = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.schemas", classLoader); schemaMappings = new ConcurrentHashMap<String, String>(mappings.size()); CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings); } catch (IOException e) { //ignore } }
From source file:org.xmatthew.spy2servers.config.IntegrationNamespaceHandler.java
@SuppressWarnings("unchecked") private Map<String, Class<? extends BeanDefinitionParser>> loadAdapterParserMappings() { Map<String, Class<? extends BeanDefinitionParser>> parserMappings = new HashMap<String, Class<? extends BeanDefinitionParser>>(); ClassLoader classLoader = getClass().getClassLoader(); try {/*from w ww . j av a 2 s . com*/ Properties mappings = PropertiesLoaderUtils.loadAllProperties(ADAPTER_PARSER_MAPPINGS_LOCATION, classLoader); if (logger.isDebugEnabled()) { logger.debug("Loaded parser mappings [" + mappings + "]"); } Enumeration<?> propertyNames = mappings.propertyNames(); while (propertyNames.hasMoreElements()) { String name = (String) propertyNames.nextElement(); String classname = mappings.getProperty(name); Class<?> parserClass = ClassUtils.forName(classname, classLoader); if (!BeanDefinitionParser.class.isAssignableFrom(parserClass)) { throw new IllegalStateException("Expected class of type BeanDefinitionParser, but '" + name + "' was of type '" + parserClass.getSimpleName() + "'"); } parserMappings.put(name, (Class<? extends BeanDefinitionParser>) parserClass); } return parserMappings; } catch (IOException e) { throw new IllegalStateException("Unable to load BeanDefinitionParser mappings from location [" + ADAPTER_PARSER_MAPPINGS_LOCATION + "]. Root cause: " + e); } catch (ClassNotFoundException e) { throw new IllegalStateException("Failed to load BeanDefinitionParser.", e); } }
From source file:com.knitml.core.xml.PluggableSchemaResolver.java
protected String getSchemaMapping(String systemId) { if (this.schemaMappings == null) { if (logger.isDebugEnabled()) { logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]"); }// ww w .ja va 2 s .co m try { this.schemaMappings = PropertiesLoaderUtils.loadAllProperties(this.schemaMappingsLocation, this.classLoader); if (logger.isDebugEnabled()) { logger.debug("Loaded schema mappings: " + this.schemaMappings); } } catch (IOException ex) { throw new FatalBeanException( "Unable to load schema mappings from location [" + this.schemaMappingsLocation + "]", ex); } } return this.schemaMappings.getProperty(systemId); }
From source file:org.data.support.beans.factory.xml.SchemaResolver.java
/** * Load the specified schema mappings lazily. *//* w w w . ja v a 2s. c o m*/ private Map<String, String> getSchemaMappings() { if (this.schemaMappings == null) { synchronized (this) { if (this.schemaMappings == null) { if (logger.isDebugEnabled()) { logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]"); } try { Properties mappings = PropertiesLoaderUtils.loadAllProperties(this.schemaMappingsLocation, this.classLoader); if (logger.isDebugEnabled()) { logger.debug("Loaded schema mappings: " + mappings); } Map<String, String> schemaMappings = new ConcurrentHashMap<String, String>(); CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings); this.schemaMappings = schemaMappings; } catch (IOException ex) { throw new IllegalStateException("Unable to load schema mappings from location [" + this.schemaMappingsLocation + "]", ex); } } } } return this.schemaMappings; }
From source file:org.codice.ddf.platform.util.properties.PropertiesLoader.java
/** Try loading properties using Spring and a provided class loader. */ @VisibleForTesting/*from www .j a v a2 s .co m*/ static Properties attemptLoadWithSpringAndClassLoader(String propertiesFile, ClassLoader classLoader) { Properties properties = new Properties(); try { LOGGER.debug( "Attempting to load properties from {} with Spring PropertiesLoaderUtils with class loader.", propertiesFile); if (classLoader != null) { properties = PropertiesLoaderUtils.loadAllProperties(propertiesFile, classLoader); } else { properties = PropertiesLoaderUtils.loadAllProperties(propertiesFile, PropertiesLoader.class.getClassLoader()); } } catch (IOException e) { LOGGER.debug("Unable to load properties using default Spring properties loader.", e); } return properties; }
From source file:org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.java
/** * Load the specified NamespaceHandler mappings lazily. *//*from w ww. ja va 2 s. com*/ private Map<String, Object> getHandlerMappings() { Map<String, Object> handlerMappings = this.handlerMappings; if (handlerMappings == null) { synchronized (this) { handlerMappings = this.handlerMappings; if (handlerMappings == null) { try { Properties mappings = PropertiesLoaderUtils.loadAllProperties(this.handlerMappingsLocation, this.classLoader); if (logger.isDebugEnabled()) { logger.debug("Loaded NamespaceHandler mappings: " + mappings); } Map<String, Object> mappingsToUse = new ConcurrentHashMap<>(mappings.size()); CollectionUtils.mergePropertiesIntoMap(mappings, mappingsToUse); handlerMappings = mappingsToUse; this.handlerMappings = handlerMappings; } catch (IOException ex) { throw new IllegalStateException("Unable to load NamespaceHandler mappings from location [" + this.handlerMappingsLocation + "]", ex); } } } } return handlerMappings; }
From source file:org.springframework.beans.factory.xml.PluggableSchemaResolver.java
/** * Load the specified schema mappings lazily. *//*w w w . ja va2 s .com*/ private Map<String, String> getSchemaMappings() { Map<String, String> schemaMappings = this.schemaMappings; if (schemaMappings == null) { synchronized (this) { schemaMappings = this.schemaMappings; if (schemaMappings == null) { if (logger.isDebugEnabled()) { logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]"); } try { Properties mappings = PropertiesLoaderUtils.loadAllProperties(this.schemaMappingsLocation, this.classLoader); if (logger.isDebugEnabled()) { logger.debug("Loaded schema mappings: " + mappings); } Map<String, String> mappingsToUse = new ConcurrentHashMap<>(mappings.size()); CollectionUtils.mergePropertiesIntoMap(mappings, mappingsToUse); schemaMappings = mappingsToUse; this.schemaMappings = schemaMappings; } catch (IOException ex) { throw new IllegalStateException("Unable to load schema mappings from location [" + this.schemaMappingsLocation + "]", ex); } } } } return schemaMappings; }