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

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

Introduction

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

Prototype

@Override
public void afterPropertiesSet() throws Exception 

Source Link

Document

Initializes this CacheFactoryBean after properties have been set by the Spring container.

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()));
            }/*from  w ww .j  a  va 2 s.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);
    }
}