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

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

Introduction

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

Prototype

public void setProperties(Properties properties) 

Source Link

Document

Returns a reference to Pivotal GemFire/Apache Geode Properties used to configure the cache.

Usage

From source file:example.app.config.gemfire.GemFireConfiguration.java

@Bean
public CacheFactoryBean gemfireCache() {
    CacheFactoryBean gemfireCache = new CacheFactoryBean();

    gemfireCache.setClose(true);//  w  ww.  j a  v a 2  s  . c  o m
    gemfireCache.setProperties(gemfireProperties());

    return gemfireCache;
}

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()));
            }/*from  w  ww  .jav a 2s . c  o  m*/
        }

        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);
    }
}