From 1f36a55fafbef390d40d0508a354802cfbe9bea4 Mon Sep 17 00:00:00 2001 From: Lyndon Adams Date: Tue, 12 Mar 2013 16:39:39 +0000 Subject: [PATCH 1/4] Current changes for region subscriptions. --- .../gemfire/config/AbstractRegionParser.java | 1 + .../data/gemfire/config/ParsingUtils.java | 31 +++++ .../SubscriptionAttributesFactoryBean.java | 102 +++++++++++++++++ .../data/gemfire/config/SubscriptionType.java | 26 +++++ .../gemfire/config/spring-gemfire-1.3.xsd | 106 +++++++++++++++++- .../gemfire/config/CacheSubscriptionTest.java | 43 +++++++ .../data/gemfire/basic-region.xml | 1 + .../data/gemfire/client/client-cache.xml | 2 +- .../data/gemfire/config/subscription-ns.xml | 23 ++++ 9 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/springframework/data/gemfire/config/SubscriptionAttributesFactoryBean.java create mode 100644 src/main/java/org/springframework/data/gemfire/config/SubscriptionType.java create mode 100644 src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java create mode 100644 src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml diff --git a/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java index daee69bb..144a06db 100644 --- a/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java +++ b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java @@ -119,6 +119,7 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser { } ParsingUtils.parseExpiration(parserContext, element, attrBuilder); + ParsingUtils.parseSubscription(parserContext, element, attrBuilder); ParsingUtils.parseEviction(parserContext, element, attrBuilder); ParsingUtils.parseMembershipAttributes(parserContext, element, attrBuilder); diff --git a/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java b/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java index 8170e1de..fdfb591e 100644 --- a/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java +++ b/src/main/java/org/springframework/data/gemfire/config/ParsingUtils.java @@ -48,6 +48,7 @@ import com.gemstone.gemfire.cache.Scope; * * @author Costin Leau * @author David Turanski + * @author Lyndon Adams */ abstract class ParsingUtils { @@ -256,6 +257,36 @@ abstract class ParsingUtils { attrBuilder.addPropertyValue("evictionAttributes", evictionDefBuilder.getBeanDefinition()); return true; } + + /** + * Parses the subscription sub-element. Populates the given attribute factory + * with the proper attributes. + * + * @author Lyndon Adams + * @param parserContext + * @param element + * @param attrBuilder + * @return true if parsing actually occured, false otherwise + */ + static boolean parseSubscription(ParserContext parserContext, Element element, BeanDefinitionBuilder attrBuilder) { + Element subscriptionElement = DomUtils.getChildElementByTagName(element, "subscription"); + + if (subscriptionElement == null) + return false; + + BeanDefinitionBuilder subscriptionDefBuilder = BeanDefinitionBuilder + .genericBeanDefinition(SubscriptionAttributesFactoryBean.class); + + // do manual conversion since the enum is not public + String attr = subscriptionElement.getAttribute("type"); + if (StringUtils.hasText(attr)) { + subscriptionDefBuilder.addPropertyValue("type", SubscriptionType.valueOf(attr.toUpperCase())); + } + + attrBuilder.addPropertyValue("subscriptionAttributes", subscriptionDefBuilder.getBeanDefinition()); + return true; + } + static void parseTransportFilters(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { Element transportFilterElement = DomUtils.getChildElementByTagName(element, "transport-filter"); diff --git a/src/main/java/org/springframework/data/gemfire/config/SubscriptionAttributesFactoryBean.java b/src/main/java/org/springframework/data/gemfire/config/SubscriptionAttributesFactoryBean.java new file mode 100644 index 00000000..474cf12d --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/config/SubscriptionAttributesFactoryBean.java @@ -0,0 +1,102 @@ +/* + * Copyright 2010-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.gemfire.config; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; + +import com.gemstone.gemfire.cache.InterestPolicy; +import com.gemstone.gemfire.cache.SubscriptionAttributes; + +/** + * Simple utility class used for defining nested factory-method like definitions w/o polluting the container with useless beans. + * + * @author Lyndon Adams + * @since 12 March 2013 + */ +public class SubscriptionAttributesFactoryBean implements FactoryBean, InitializingBean { + + SubscriptionAttributes subscriptionAttri; + InterestPolicy policy; + SubscriptionType type = SubscriptionType.ALL; + + + /* (non-Javadoc) + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + if( policy == null ){ + policy = InterestPolicy.DEFAULT; + } + subscriptionAttri = createAttributes(); + } + + private SubscriptionAttributes createAttributes(){ + switch( type ){ + case ALL : + policy = InterestPolicy.ALL; + break; + case CACHE_CONTENT : + policy = InterestPolicy.CACHE_CONTENT; + break; + default : + policy = InterestPolicy.DEFAULT; + } + return new SubscriptionAttributes( policy ); + } + + + /* (non-Javadoc) + * @see org.springframework.beans.factory.FactoryBean#getObject() + */ + @Override + public SubscriptionAttributes getObject() throws Exception { + return subscriptionAttri; + } + + /* (non-Javadoc) + * @see org.springframework.beans.factory.FactoryBean#getObjectType() + */ + @Override + public Class getObjectType() { + return ( subscriptionAttri != null ) ? subscriptionAttri.getClass() : SubscriptionAttributes.class; + } + + /* (non-Javadoc) + * @see org.springframework.beans.factory.FactoryBean#isSingleton() + */ + @Override + public boolean isSingleton() { + return true; + } + + public InterestPolicy getPolicy() { + return policy; + } + + public SubscriptionType getType() { + return type; + } + + public void setPolicy(InterestPolicy policy) { + this.policy = policy; + } + + public void setType(SubscriptionType type) { + this.type = type; + } +} diff --git a/src/main/java/org/springframework/data/gemfire/config/SubscriptionType.java b/src/main/java/org/springframework/data/gemfire/config/SubscriptionType.java new file mode 100644 index 00000000..83cc8439 --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/config/SubscriptionType.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.gemfire.config; + +/** + * Simple enumeration for the various GemFire subscription types. + * + * @author Lyndon Adams + * + */ +enum SubscriptionType { + ALL, CACHE_CONTENT; +} \ No newline at end of file diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd index c9aad6bc..7959fc29 100755 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd @@ -974,6 +974,24 @@ up to date copy of the data. + + + + + + + + + + + + @@ -1075,6 +1093,24 @@ Defines a GemFire local region instance. Each local region is scoped only to the + + + + + + + + + + + + @@ -1226,6 +1262,24 @@ Specifies the number of buckets to allocate to the fixed partition + + + + + + + + + + + + @@ -1249,7 +1303,25 @@ The action to take when performing eviction. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java new file mode 100644 index 00000000..12bee4a6 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.gemfire.config; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.test.GemfireTestRunner; +import org.springframework.test.context.ContextConfiguration; + +/** + * @author Lyndon Adams + */ +@RunWith(GemfireTestRunner.class) +@ContextConfiguration("/org/springframework/data/gemfire/config/subscription-ns.xml") +public class CacheSubscriptionTest{ + @Autowired ApplicationContext ctx; + + @Test + public void testRRSubscription() throws Exception { + + } + + @Test + public void testPRSubscription() throws Exception { + + } +} diff --git a/src/test/resources/org/springframework/data/gemfire/basic-region.xml b/src/test/resources/org/springframework/data/gemfire/basic-region.xml index 508a0f39..9b457c76 100644 --- a/src/test/resources/org/springframework/data/gemfire/basic-region.xml +++ b/src/test/resources/org/springframework/data/gemfire/basic-region.xml @@ -12,4 +12,5 @@ + diff --git a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml index b0a76411..29eecb6b 100644 --- a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml +++ b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml @@ -9,5 +9,5 @@ - + diff --git a/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml new file mode 100644 index 00000000..56c2322c --- /dev/null +++ b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file From 7f1d84e5984a19e8a24df03000c88d9b08f19918 Mon Sep 17 00:00:00 2001 From: Lyndon Adams Date: Tue, 12 Mar 2013 19:26:10 +0000 Subject: [PATCH 2/4] Additional changes for SGF-160 --- maven.gradle | 5 + .../gemfire/config/spring-gemfire-1.3.xsd | 4815 ++++++++--------- .../data/gemfire/config/subscription-ns.xml | 19 +- 3 files changed, 2394 insertions(+), 2445 deletions(-) diff --git a/maven.gradle b/maven.gradle index c80dcce7..577a73f6 100644 --- a/maven.gradle +++ b/maven.gradle @@ -64,6 +64,11 @@ def customizePom(pom, gradleProject) { name = 'Oliver Gierke' email = 'ogierke@vmware.com' } + developer { + id = 'ladams' + name = 'Lyndon Adams' + email = 'ladams@vmware.com' + } } } } diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd index 7959fc29..ae9ae4a9 100755 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd @@ -1,199 +1,195 @@ - - - - - - + + + + + + - - - - - - - + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + - - - - + + + + - - - + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + namespace and its 'properties' element. ]]> - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + + - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + + - - - - - - - + + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - + + + + + + - - - - - - - + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - - - - + + + + + + - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + - - - - - - + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - + + + + + - - - - - - + + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + - - - - - - + + + + + - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + - - - - - - - - + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - + + - - - - - - - - - - + + + + + + + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - + + + + - - - - - - + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + - - - - - - - - - - + + + + + + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + - - - - - - - + + + + + + - - - - - - + + + + + + + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:gfe="http://www.springframework.org/schema/gemfire" + xmlns:p="http://www.springframework.org/schema/p" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" default-lazy-init="true"> - - + + @@ -17,7 +18,7 @@ - + \ No newline at end of file From bb9072bed15217b584bc1dbe599623b91ed83f57 Mon Sep 17 00:00:00 2001 From: David Turanski Date: Tue, 12 Mar 2013 17:19:45 -0400 Subject: [PATCH 3/4] fixed xsd problems --- .../gemfire/config/spring-gemfire-1.3.xsd | 125 +++--------------- .../gemfire/config/CacheSubscriptionTest.java | 4 +- .../data/gemfire/config/subscription-ns.xml | 14 +- 3 files changed, 24 insertions(+), 119 deletions(-) diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd index ae9ae4a9..9f5f4037 100755 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd @@ -947,39 +947,24 @@ up to date copy of the data. - - - + - + ]]> + - - - - - - - - - + - - + - @@ -995,8 +980,7 @@ The action to take when performing eviction. - - + @@ -1074,29 +1058,6 @@ Defines a GemFire local region instance. Each local region is scoped only to the - - - - - - - - - - - - - - - - - - - + @@ -1217,7 +1178,7 @@ is created or any bucket in a partitioned region becomes primary @@ -1226,7 +1187,7 @@ is created or any bucket in a partitioned region becomes primary @@ -1235,7 +1196,7 @@ Specifies the fixed partition name @@ -1243,7 +1204,7 @@ Specifies if this member is primary for this partition @@ -1252,22 +1213,11 @@ Specifies the number of buckets to allocate to the fixed partition - +Subscription policy for the partitioned region. + ]]> + - - - - - - - - - + @@ -1291,27 +1241,6 @@ The action to take when performing eviction. - - - - - - - - - - - - - - - - @@ -1561,30 +1490,6 @@ reclaim memory. - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java index 12bee4a6..08c5a88c 100644 --- a/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java @@ -20,13 +20,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.data.gemfire.test.GemfireTestRunner; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Lyndon Adams */ -@RunWith(GemfireTestRunner.class) +@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/org/springframework/data/gemfire/config/subscription-ns.xml") public class CacheSubscriptionTest{ @Autowired ApplicationContext ctx; diff --git a/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml index 2ffea490..87ccc857 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml @@ -1,20 +1,20 @@ + default-lazy-init="true" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> - - + + - + + From 8b46b94344cbfc645289291e695a9099e572d18a Mon Sep 17 00:00:00 2001 From: Lyndon Adams Date: Wed, 13 Mar 2013 11:39:03 +0000 Subject: [PATCH 4/4] Additional changes for SGF-160 --- .../gemfire/config/CacheSubscriptionTest.java | 43 +++++++++++++++++-- .../data/gemfire/config/subscription-ns.xml | 24 ++++++----- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java index 08c5a88c..adb57af0 100644 --- a/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/CacheSubscriptionTest.java @@ -16,28 +16,65 @@ package org.springframework.data.gemfire.config; +import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.RegionFactoryBean; +import org.springframework.data.gemfire.TestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.gemstone.gemfire.cache.InterestPolicy; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.SubscriptionAttributes; + /** + * Test to ensure subscription policy can be applied to server regions. + * * @author Lyndon Adams + * @since 13 March 2013 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/org/springframework/data/gemfire/config/subscription-ns.xml") public class CacheSubscriptionTest{ - @Autowired ApplicationContext ctx; + @Autowired ApplicationContext context; + + @SuppressWarnings("rawtypes") @Test - public void testRRSubscription() throws Exception { + public void testRRSubscriptionAllPolicy() throws Exception { + assertTrue(context.containsBean("replicALL")); + RegionFactoryBean fb = context.getBean("&replicALL", RegionFactoryBean.class); + RegionAttributes attrs = TestUtils.readField("attributes", fb); + SubscriptionAttributes sa = attrs.getSubscriptionAttributes(); + assertEquals(InterestPolicy.ALL, sa.getInterestPolicy() ); } + @SuppressWarnings("rawtypes") @Test - public void testPRSubscription() throws Exception { + public void testPRSubscriptionCacheContentPolicy() throws Exception { + assertTrue(context.containsBean("partCACHE_CONTENT")); + RegionFactoryBean fb = context.getBean("&partCACHE_CONTENT", RegionFactoryBean.class); + RegionAttributes attrs = TestUtils.readField("attributes", fb); + SubscriptionAttributes sa = attrs.getSubscriptionAttributes(); + assertEquals(InterestPolicy.CACHE_CONTENT, sa.getInterestPolicy() ); } + + @SuppressWarnings("rawtypes") + @Test + public void testPRSubscriptionDefaultPolicy() throws Exception { + assertTrue(context.containsBean("partDEFAULT")); + RegionFactoryBean fb = context.getBean("&partDEFAULT", RegionFactoryBean.class); + RegionAttributes attrs = TestUtils.readField("attributes", fb); + + SubscriptionAttributes sa = attrs.getSubscriptionAttributes(); + assertEquals(InterestPolicy.ALL, sa.getInterestPolicy() ); + } + } diff --git a/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml index 87ccc857..aa35ba0a 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/subscription-ns.xml @@ -2,23 +2,25 @@ + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd + http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd"> - - - + + + - - - + + + - - - + + + + \ No newline at end of file