diff --git a/src/main/java/org/springframework/data/gemfire/config/ClientRegionParser.java b/src/main/java/org/springframework/data/gemfire/config/ClientRegionParser.java index dc6d9062..a59d5901 100644 --- a/src/main/java/org/springframework/data/gemfire/config/ClientRegionParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/ClientRegionParser.java @@ -17,11 +17,13 @@ package org.springframework.data.gemfire.config; import java.util.List; +import java.util.concurrent.ConcurrentMap; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.data.gemfire.RegionAttributesFactory; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; import org.springframework.data.gemfire.client.Interest; import org.springframework.data.gemfire.client.RegexInterest; @@ -29,6 +31,9 @@ import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.Scope; /** @@ -59,10 +64,42 @@ class ClientRegionParser extends AbstractSingleBeanDefinitionParser { ParsingUtils.setPropertyValue(element, builder, "name", "name"); ParsingUtils.setPropertyValue(element, builder, "pool-name", "poolName"); - String attr = element.getAttribute("cache-ref"); + // set the persistent policy + String attr = element.getAttribute("persistent"); + + boolean frozenDataPolicy = false; + + if (Boolean.parseBoolean(attr)) { + // check first for GemFire 6.5 + if (ConcurrentMap.class.isAssignableFrom(Region.class)) { + builder.addPropertyValue("dataPolicy", DataPolicy.PERSISTENT_REPLICATE); + frozenDataPolicy = true; + } + else { + parserContext.getReaderContext().error( + "Can define persistent partitions only from GemFire 6.5 onwards - current version is [" + + CacheFactory.getVersion() + "]", element); + } + } + + attr = element.getAttribute("cache-ref"); // add cache reference (fallback to default if nothing is specified) builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfire-cache")); + // eviction + overflow attributes + // client attributes + BeanDefinitionBuilder attrBuilder = BeanDefinitionBuilder.genericBeanDefinition(RegionAttributesFactory.class); + + ParsingUtils.parseEviction(parserContext, element, attrBuilder); + ParsingUtils.parseDiskStorage(element, attrBuilder); + + if (!frozenDataPolicy) { + builder.addPropertyValue("dataPolicy", DataPolicy.NORMAL); + } + + // add partition/overflow settings as attributes + builder.addPropertyValue("attributes", attrBuilder.getBeanDefinition()); + ManagedList interests = new ManagedList(); // parse nested declarations diff --git a/src/main/java/org/springframework/data/gemfire/config/PartitionedRegionParser.java b/src/main/java/org/springframework/data/gemfire/config/PartitionedRegionParser.java index 413f508c..fdf06ab4 100644 --- a/src/main/java/org/springframework/data/gemfire/config/PartitionedRegionParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/PartitionedRegionParser.java @@ -148,7 +148,7 @@ class PartitionedRegionParser extends AbstractSingleBeanDefinitionParser { // add partition attributes attributes attrBuilder.addPropertyValue("partitionAttributes", parAttrBuilder.getBeanDefinition()); - + // add partition/overflow settings as attributes builder.addPropertyValue("attributes", attrBuilder.getBeanDefinition()); } diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.0.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.0.xsd index cc6ed13b..72fd64af 100644 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.0.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.0.xsd @@ -179,8 +179,29 @@ use inner bean declarations. - + + + + + + + + + + + @@ -217,28 +238,7 @@ arbitrarily pick one. - - - - - - - - - - @@ -600,8 +600,8 @@ which it receives its data. The client can hold some data locally or forward all - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file