Example usage for org.springframework.util CollectionUtils mergePropertiesIntoMap

List of usage examples for org.springframework.util CollectionUtils mergePropertiesIntoMap

Introduction

In this page you can find the example usage for org.springframework.util CollectionUtils mergePropertiesIntoMap.

Prototype

@SuppressWarnings("unchecked")
public static <K, V> void mergePropertiesIntoMap(@Nullable Properties props, Map<K, V> map) 

Source Link

Document

Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over.

Usage

From source file:org.solmix.runtime.support.spring.ContainerEntityResolver.java

public ContainerEntityResolver(ClassLoader loader, EntityResolver dr, EntityResolver sr) {
    super(dr, sr);
    classLoader = loader;//from w  w w  . j a  va 2s  . c om
    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:gov.nyc.doitt.gis.geoclient.parser.configuration.ParserConfig.java

@Bean(name = "boroughNamesToBoroughMap")
public Map<String, String> boroughNamesToBoroughMap() {
    Map<String, String> map = new TreeMap<>();
    CollectionUtils.mergePropertiesIntoMap(boroughNameProperties, map);
    return map;//from  w w  w . j  a v  a  2  s. c  om
}

From source file:gov.nyc.doitt.gis.geoclient.parser.configuration.ParserConfig.java

@Bean(name = "cityNamesToBoroughMap")
public Map<String, String> cityNamesToBoroughMap() {
    Map<String, String> map = new TreeMap<>();
    CollectionUtils.mergePropertiesIntoMap(cityNameProperties, map);
    return map;/*ww  w.ja  v a2 s  .co  m*/
}

From source file:net.alpha.velocity.spring.support.VelocityEngineFactory.java

/**
 * Set Velocity properties, like "file.resource.loader.path".
 * Can be used to override values in a Velocity config file,
 * or to specify all necessary properties locally.
 * <p>Note that the Velocity resource loader path also be set to any
 * Spring resource location via the "resourceLoaderPath" property.
 * Setting it here is just necessary when using a non-file-based
 * resource loader.// w  w w. ja v a 2  s.  c  om
 *
 * @see #setVelocityPropertiesMap
 * @see #setConfigLocation
 * @see #setResourceLoaderPath
 */
public void setVelocityProperties(Properties velocityProperties) {
    CollectionUtils.mergePropertiesIntoMap(velocityProperties, this.velocityProperties);
}

From source file:org.metis.cassandra.ClientMapper.java

/**
 * Map URL paths to handler bean names. This is the typical way of
 * configuring this HandlerMapping.//from  www  .  j av  a  2 s.c o  m
 * <p>
 * Supports direct URL matches and Ant-style pattern matches. For syntax
 * details, see the {@link org.springframework.util.AntPathMatcher} javadoc.
 * 
 * @param mappings
 *            properties with URLs as keys and bean names as values
 * @see #setUrlMap
 */
public void setMappings(Properties mappings) {
    CollectionUtils.mergePropertiesIntoMap(mappings, this.urlMap);
}

From source file:com.sfxie.extension.spring4.properties.SwitchPropertiesLoaderSupport.java

/**
 * Return a merged Properties instance containing both the
 * loaded properties and properties set on this FactoryBean.
 *//*from www. ja v a 2 s. c  o  m*/
protected Properties mergeProperties() throws IOException {
    Properties result = new Properties();

    if (this.localOverride) {
        // Load properties from file upfront, to let local properties override.
        loadProperties(result);
    }

    if (this.localProperties != null) {
        for (Properties localProp : this.localProperties) {
            CollectionUtils.mergePropertiesIntoMap(localProp, result);
        }
    }

    if (!this.localOverride) {
        // Load properties from file afterwards, to let those properties override.
        loadProperties(result);
    }

    return result;
}

From source file:com.brienwheeler.lib.spring.beans.PropertyPlaceholderConfigurer.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties properties)
        throws BeansException {
    ContextData contextData;//from ww w.  j a v a  2s .  co m
    synchronized (contextDataMap) {
        contextData = contextDataMap.get(beanFactoryToProcess);
        if (contextData == null) {
            contextData = new ContextData();
            contextDataMap.put(beanFactoryToProcess, contextData);
        }
    }

    int ppcCount = beanFactoryToProcess.getBeanNamesForType(PropertyPlaceholderConfigurer.class, true,
            false).length;
    synchronized (contextData) {
        /*
         * Spring calls all placeholder configurers according to their Order value.
         * We want to aggregate all placeholder definitions at the same Order value and
         * resolve them at the sane time, to ease inter-file dependency management.
         */

        /*
         * First we check to see if we have previously aggregated properties for a
         * different order value.  If so, resolve the previously aggregated properties
         * and clear out the aggregation before proceeding. 
         */
        Integer previousOrder = contextData.isOrderChanging(getOrder());
        if (previousOrder != null) {
            if (!quiet)
                log.info("Processing merged context properties of order " + previousOrder);
            processProperties(contextData.getProperties(), placeholderPrefix, placeholderSuffix);
            contextData.clearProperties();
        }

        /*
         * Now we just merge these definitions into the current Order level aggregation.
         * We'll process them when we hit another placeholder configurer with a different
         * Order value, or when we hit the last placeholder configurer in the context.
         */
        CollectionUtils.mergePropertiesIntoMap(properties, contextData.getProperties());

        /*
         * Finally, if this is the last placeholder configurer in the context we need
         * to resolve the aggregated properties and call Spring to process these into
         * bean defintions, et al.
         */
        if (contextData.incrementPpcCount() == ppcCount) {
            if (!quiet)
                log.info("Processing merged context properties of order " + getOrder());
            processProperties(contextData.getProperties(), placeholderPrefix, placeholderSuffix);
            contextData.clearProperties();
            log.info("Resolving context placeholders");
            super.processProperties(beanFactoryToProcess, contextData.getProperties());
        }
    }
}

From source file:com.ibm.tap.trails.framework.PropertiesLoaderSupport.java

/**
 * Return a merged Properties instance containing both the loaded properties
 * and properties set on this FactoryBean.
 *///  w  w w.j a v a 2s  .  co  m
protected Properties mergeProperties() throws IOException {
    Properties result = new Properties();

    if (this.localOverride) {
        // Load properties from file upfront, to let local properties
        // override.
        loadProperties(result);
    }

    if (this.localProperties != null) {
        for (Properties localProp : this.localProperties) {
            CollectionUtils.mergePropertiesIntoMap(localProp, result);
        }
    }

    if (!this.localOverride) {
        // Load properties from file afterwards, to let those properties
        // override.
        loadProperties(result);
    }

    return result;
}

From source file:org.data.support.beans.factory.xml.SchemaResolver.java

/**
 * Load the specified schema mappings lazily.
 *//* w ww . j  a v  a2s. co 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:com.berwickheights.spring.utils.CustomTilesConfigurer.java

/**
 * Set Tiles properties (equivalent to the ServletContext init-params in
 * the Tiles documentation), overriding the default settings.
 *///from www .j a v  a 2  s .co  m
public void setTilesProperties(Properties tilesProperties) {
    CollectionUtils.mergePropertiesIntoMap(tilesProperties, this.tilesPropertyMap);
}