SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Removed the XSD enumeration restriction on the 'result-policy' attribute of the 'interestType' SDG XSD complex-type definition in order to allow users to specify an Interest Policy using concrete values or properly placeholders when registering client Region Interests.
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -51,6 +52,7 @@ import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.TransactionListener;
|
||||
import com.gemstone.gemfire.cache.TransactionWriter;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
@@ -82,6 +84,7 @@ import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<Cache>,
|
||||
InitializingBean, DisposableBean, PersistenceExceptionTranslator {
|
||||
|
||||
@@ -923,6 +926,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
beanFactory.registerCustomEditor(IndexMaintenancePolicyType.class, IndexMaintenancePolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(IndexType.class, IndexTypeConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestPolicy.class, InterestPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(InterestResultPolicy.class, InterestResultPolicyConverter.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.InterestPolicy
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -23,20 +23,26 @@ import org.springframework.util.Assert;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
|
||||
/**
|
||||
* Basic holder class for registering an interest. Useful for configuring Gemfire caches through XML
|
||||
* and or JavaBeans means.
|
||||
* The Interest class holds details for registering a client interest.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see com.gemstone.gemfire.cache.InterestResultPolicy
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Interest<K> implements InitializingBean {
|
||||
|
||||
private static final Constants constants = new Constants(InterestResultPolicy.class);
|
||||
|
||||
private K key;
|
||||
private InterestResultPolicy policy = InterestResultPolicy.DEFAULT;
|
||||
private boolean durable = false;
|
||||
private boolean receiveValues = true;
|
||||
|
||||
private InterestResultPolicy policy = InterestResultPolicy.DEFAULT;
|
||||
|
||||
private K key;
|
||||
|
||||
public Interest() {
|
||||
}
|
||||
|
||||
@@ -44,10 +50,6 @@ public class Interest<K> implements InitializingBean {
|
||||
this(key, InterestResultPolicy.DEFAULT, false);
|
||||
}
|
||||
|
||||
public Interest(K key, InterestResultPolicy policy) {
|
||||
this(key, policy, false);
|
||||
}
|
||||
|
||||
public Interest(K key, String policy) {
|
||||
this(key, policy, false);
|
||||
}
|
||||
@@ -60,6 +62,10 @@ public class Interest<K> implements InitializingBean {
|
||||
this(key, (InterestResultPolicy) constants.asObject(policy), durable, receiveValues);
|
||||
}
|
||||
|
||||
public Interest(K key, InterestResultPolicy policy) {
|
||||
this(key, policy, false);
|
||||
}
|
||||
|
||||
public Interest(K key, InterestResultPolicy policy, boolean durable) {
|
||||
this(key, policy, durable, true);
|
||||
}
|
||||
@@ -69,6 +75,7 @@ public class Interest<K> implements InitializingBean {
|
||||
this.policy = policy;
|
||||
this.durable = durable;
|
||||
this.receiveValues = receiveValues;
|
||||
|
||||
afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -81,7 +88,7 @@ public class Interest<K> implements InitializingBean {
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
protected K getKey() {
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -99,7 +106,7 @@ public class Interest<K> implements InitializingBean {
|
||||
*
|
||||
* @return the policy
|
||||
*/
|
||||
protected InterestResultPolicy getPolicy() {
|
||||
public InterestResultPolicy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
@@ -114,13 +121,12 @@ public class Interest<K> implements InitializingBean {
|
||||
if (policy instanceof InterestResultPolicy) {
|
||||
this.policy = (InterestResultPolicy) policy;
|
||||
}
|
||||
else if (policy instanceof String) {
|
||||
this.policy = (InterestResultPolicy) constants.asObject(String.valueOf(policy));
|
||||
}
|
||||
else {
|
||||
if (policy instanceof String) {
|
||||
this.policy = (InterestResultPolicy) constants.asObject((String) policy);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unknown argument type for property 'policy'" + policy);
|
||||
}
|
||||
throw new IllegalArgumentException(String.format("Unknown argument type (%1$s) for property 'policy'!",
|
||||
policy));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +135,7 @@ public class Interest<K> implements InitializingBean {
|
||||
*
|
||||
* @return the durable
|
||||
*/
|
||||
protected boolean isDurable() {
|
||||
public boolean isDurable() {
|
||||
return durable;
|
||||
}
|
||||
|
||||
@@ -147,7 +153,7 @@ public class Interest<K> implements InitializingBean {
|
||||
*
|
||||
* @return the receiveValues
|
||||
*/
|
||||
protected boolean isReceiveValues() {
|
||||
public boolean isReceiveValues() {
|
||||
return receiveValues;
|
||||
}
|
||||
|
||||
@@ -159,4 +165,5 @@ public class Interest<K> implements InitializingBean {
|
||||
public void setReceiveValues(boolean receiveValues) {
|
||||
this.receiveValues = receiveValues;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
|
||||
/**
|
||||
* The InterestResultPolicyConverter class is a Spring Converter and JavaBeans PropertyEditor capable of converting
|
||||
* a String into a GemFire InterestResultPolicyConverter.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport
|
||||
* @see com.gemstone.gemfire.cache.InterestResultPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestResultPolicyConverter extends AbstractPropertyEditorConverterSupport<InterestResultPolicy> {
|
||||
|
||||
/**
|
||||
* Converts the given String into an instance of GemFire InterestResultPolicy.
|
||||
*
|
||||
* @param source the String to convert into an InterestResultPolicy value.
|
||||
* @return a GemFire InterestResultPolicy value for the given String.
|
||||
* @throws java.lang.IllegalArgumentException if the String is not a valid GemFire InterestResultPolicy.
|
||||
* @see org.springframework.data.gemfire.client.InterestResultPolicyType#getInterestResultPolicy(InterestResultPolicyType)
|
||||
* @see org.springframework.data.gemfire.client.InterestResultPolicyType#valueOfIgnoreCase(String)
|
||||
* @see #assertConverted(String, Object, Class)
|
||||
* @see com.gemstone.gemfire.cache.InterestResultPolicy
|
||||
*/
|
||||
@Override
|
||||
public InterestResultPolicy convert(final String source) {
|
||||
return assertConverted(source, InterestResultPolicyType.getInterestResultPolicy(
|
||||
InterestResultPolicyType.valueOfIgnoreCase(source)), InterestResultPolicy.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
|
||||
/**
|
||||
* The InterestResultPolicyType enum is an enumeration of all client Register Interests (result) policy values.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.InterestResultPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum InterestResultPolicyType {
|
||||
KEYS(InterestResultPolicy.KEYS),
|
||||
KEYS_VALUES(InterestResultPolicy.KEYS_VALUES),
|
||||
NONE(InterestResultPolicy.NONE);
|
||||
|
||||
public static final InterestResultPolicyType DEFAULT = InterestResultPolicyType.valueOf(
|
||||
InterestResultPolicy.DEFAULT);
|
||||
|
||||
private final InterestResultPolicy interestResultPolicy;
|
||||
|
||||
InterestResultPolicyType(final InterestResultPolicy interestResultPolicy) {
|
||||
this.interestResultPolicy = interestResultPolicy;
|
||||
}
|
||||
|
||||
public static InterestResultPolicy getInterestResultPolicy(final InterestResultPolicyType interestResultPolicyType) {
|
||||
return (interestResultPolicyType != null ? interestResultPolicyType.getInterestResultPolicy() : null);
|
||||
}
|
||||
|
||||
public static InterestResultPolicyType valueOf(final InterestResultPolicy interestResultPolicy) {
|
||||
for (InterestResultPolicyType interestResultPolicyType : values()) {
|
||||
if (interestResultPolicyType.getInterestResultPolicy().equals(interestResultPolicy)) {
|
||||
return interestResultPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static InterestResultPolicyType valueOfIgnoreCase(final String name) {
|
||||
for (InterestResultPolicyType interestResultPolicyType : values()) {
|
||||
if (interestResultPolicyType.name().equalsIgnoreCase(name)) {
|
||||
return interestResultPolicyType;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public InterestResultPolicy getInterestResultPolicy() {
|
||||
return interestResultPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1106,10 +1106,10 @@ The RegionShortcut for this region. Allows easy initialization of the region bas
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="REPLICATE"/>
|
||||
<xsd:enumeration value="REPLICATE_PERSISTENT"/>
|
||||
<xsd:enumeration value="REPLICATE_OVERFLOW"/>
|
||||
<xsd:enumeration value="REPLICATE_PERSISTENT_OVERFLOW"/>
|
||||
<xsd:enumeration value="REPLICATE_HEAP_LRU"/>
|
||||
<xsd:enumeration value="REPLICATE_OVERFLOW"/>
|
||||
<xsd:enumeration value="REPLICATE_PERSISTENT"/>
|
||||
<xsd:enumeration value="REPLICATE_PERSISTENT_OVERFLOW"/>
|
||||
<xsd:enumeration value="REPLICATE_PROXY"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
@@ -1373,17 +1373,17 @@ The RegionShortcut for this region. Allows easy initialization of the region bas
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="PARTITION"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT"/>
|
||||
<xsd:enumeration value="PARTITION_PERSISTENT"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_PERSISTENT"/>
|
||||
<xsd:enumeration value="PARTITION_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_PERSISTENT_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_PERSISTENT_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_HEAP_LRU"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_HEAP_LRU"/>
|
||||
<xsd:enumeration value="PARTITION_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_PERSISTENT"/>
|
||||
<xsd:enumeration value="PARTITION_PERSISTENT_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_PROXY"/>
|
||||
<xsd:enumeration value="PARTITION_PROXY_REDUNDANT"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_HEAP_LRU"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_OVERFLOW"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_PERSISTENT"/>
|
||||
<xsd:enumeration value="PARTITION_REDUNDANT_PERSISTENT_OVERFLOW"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
@@ -1514,9 +1514,9 @@ The RegionShortcut for this region. Allows easy initialization of the region bas
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="LOCAL"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT"/>
|
||||
<xsd:enumeration value="LOCAL_HEAP_LRU"/>
|
||||
<xsd:enumeration value="LOCAL_OVERFLOW"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT"/>
|
||||
<xsd:enumeration value="LOCAL_PERSISTENT_OVERFLOW"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
@@ -1822,8 +1822,7 @@ to any key in this region in the CacheServer to be pushed to the client.
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="interestType">
|
||||
<xsd:sequence minOccurs="0" maxOccurs="1">
|
||||
<xsd:any namespace="##other" processContents="skip"
|
||||
minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Inner bean definition of the client key interest.
|
||||
@@ -1831,8 +1830,7 @@ Inner bean definition of the client key interest.
|
||||
</xsd:annotation>
|
||||
</xsd:any>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="key-ref" type="xsd:string"
|
||||
use="optional">
|
||||
<xsd:attribute name="key-ref" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the client key interest bean referred by this declaration. Used as a convenience method. If no reference exists,
|
||||
@@ -2006,35 +2004,14 @@ The port number of the connection (between 1 and 65535 inclusive).
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:complexType name="interestType" abstract="true">
|
||||
<xsd:attribute name="durable" type="xsd:string" use="optional"
|
||||
default="false">
|
||||
<xsd:attribute name="durable" type="xsd:string" use="optional" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates whether or not the registered interest is durable or not. Default is false.
|
||||
Indicates whether the Registered Interest is durable or not. Default is false.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="result-policy" use="optional"
|
||||
default="KEYS_VALUES">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The result policy for this interest. Can be one of 'KEYS' or 'KEYS_VALUES' (the default) or 'NONE'.
|
||||
|
||||
KEYS - Initializes the local cache with the keys satisfying the request.
|
||||
KEYS-VALUES - initializes the local cache with the keys and current values satisfying the request.
|
||||
NONE - Does not initialize the local cache.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="KEYS" />
|
||||
<xsd:enumeration value="KEYS_VALUES" />
|
||||
<xsd:enumeration value="NONE" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="receive-values" type="xsd:string"
|
||||
use="optional" default="true">
|
||||
<xsd:attribute name="receive-values" type="xsd:string" use="optional" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates whether values are received with create and update events on keys of interest (true)
|
||||
@@ -2043,6 +2020,17 @@ Default is true.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="result-policy" type="xsd:string" use="optional" default="KEYS_VALUES">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The result policy for this interest. Can be one of 'KEYS', 'KEYS_VALUES' (the default) or 'NONE'.
|
||||
|
||||
KEYS - Initializes the local Cache with the keys satisfying the request.
|
||||
KEYS_VALUES - Initializes the local Cache with the keys and current values satisfying the request.
|
||||
NONE - Does not initialize the local Cache.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:element name="pool">
|
||||
@@ -2134,8 +2122,7 @@ The client subscription configuration that is used to control a clients use of s
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="eviction-type" use="optional"
|
||||
default="NONE">
|
||||
<xsd:attribute name="eviction-type" use="optional" default="NONE">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="NONE" />
|
||||
|
||||
Reference in New Issue
Block a user