Example usage for org.springframework.data.gemfire CacheFactoryBean setCacheXml

List of usage examples for org.springframework.data.gemfire CacheFactoryBean setCacheXml

Introduction

In this page you can find the example usage for org.springframework.data.gemfire CacheFactoryBean setCacheXml.

Prototype

public void setCacheXml(Resource cacheXml) 

Source Link

Document

Sets a reference to the Pivotal GemFire/Apache Geode native cache.xml Resource .

Usage

From source file:org.grails.datastore.mapping.gemfire.GemfireDatastore.java

public void afterPropertiesSet() throws Exception {
    CacheFactoryBean cacheFactory = new CacheFactoryBean();
    if (connectionDetails != null) {
        if (connectionDetails.containsKey(SETTING_CACHE_XML)) {
            Object entry = connectionDetails.remove(SETTING_CACHE_XML);
            if (entry instanceof Resource) {
                cacheFactory.setCacheXml((Resource) entry);
            } else {
                cacheFactory.setCacheXml(new ClassPathResource(entry.toString()));
            }//w w w  .jav a  2 s  .com
        }

        if (connectionDetails.containsKey(SETTING_PROPERTIES)) {
            Object entry = connectionDetails.get(SETTING_PROPERTIES);
            if (entry instanceof Properties) {
                cacheFactory.setProperties((Properties) entry);
            } else if (entry instanceof Map) {
                final Properties props = new Properties();
                props.putAll((Map) entry);
                cacheFactory.setProperties(props);
            }
        }
    }

    try {
        if (gemfireCache == null) {
            cacheFactory.afterPropertiesSet();
            gemfireCache = cacheFactory.getObject();
        }
        initializeRegions(gemfireCache, mappingContext);
        initializeConverters(mappingContext);
    } catch (Exception e) {
        throw new DatastoreConfigurationException(
                "Failed to configure Gemfire cache and regions: " + e.getMessage(), e);
    }
}