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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user