Added WAN support modifications for GF 7 and general cleanup of test code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.3.2.201003220227-RELEASE]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[3.0.0.201207050701-M3]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
|
||||
@@ -16,6 +16,7 @@ repositories {
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
maven { url "http://repo.springsource.org/plugins-release" }
|
||||
maven { url "http://repo1.maven.org/maven2" }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ slf4jVersion = 1.6.4
|
||||
|
||||
# Common libraries
|
||||
springVersion = 3.1.1.RELEASE
|
||||
springDataCommonsVersion = 1.3.0.BUILD-SNAPSHOT
|
||||
gemfireVersion = 6.6.3
|
||||
springDataCommonsVersion = 1.3.2.BUILD-SNAPSHOT
|
||||
#gemfireVersion = 6.6.3
|
||||
gemfireVersion = 7.0
|
||||
|
||||
# Testing
|
||||
junitVersion = 4.8.1
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -28,6 +27,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.AttributesFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
@@ -39,11 +39,12 @@ import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionFactory;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating generic GemFire {@link Region}s. Will try to first
|
||||
* locate the region (by name) and, in case none if found, proceed to creating
|
||||
* one using the given settings.
|
||||
* Base class for FactoryBeans used to create GemFire {@link Region}s. Will try
|
||||
* to first locate the region (by name) and, in case none if found, proceed to
|
||||
* creating one using the given settings.
|
||||
*
|
||||
* Note that this factory bean allows for very flexible creation of GemFire
|
||||
* {@link Region}. For "client" regions however, see
|
||||
@@ -69,20 +70,26 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
|
||||
|
||||
private CacheWriter<K, V> cacheWriter;
|
||||
|
||||
private GatewaySender gatewaySenders[];
|
||||
|
||||
private AsyncEventQueue asyncEventQueues[];
|
||||
|
||||
private RegionAttributes<K, V> attributes;
|
||||
|
||||
private Scope scope;
|
||||
|
||||
private boolean persistent;
|
||||
|
||||
private Boolean enableGateway;
|
||||
|
||||
private String hubId;
|
||||
|
||||
private String diskStoreName;
|
||||
|
||||
private String dataPolicyName;
|
||||
|
||||
private Region<K, V> region;
|
||||
|
||||
private List<Region<?, ?>> subRegions;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.afterPropertiesSet();
|
||||
@@ -102,12 +109,39 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
|
||||
final RegionFactory<K, V> regionFactory = (attributes != null ? c.createRegionFactory(attributes) : c
|
||||
.<K, V> createRegionFactory());
|
||||
|
||||
if (hubId != null) {
|
||||
enableGateway = enableGateway == null ? true : enableGateway;
|
||||
Assert.isTrue(enableGateway, "hubId requires the enableGateway property to be true");
|
||||
|
||||
regionFactory.setGatewayHubId(hubId);
|
||||
}
|
||||
if (enableGateway != null) {
|
||||
if (enableGateway) {
|
||||
Assert.notNull(hubId, "enableGateway requires the hubId property to be true");
|
||||
}
|
||||
regionFactory.setEnableGateway(enableGateway);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(cacheListeners)) {
|
||||
for (CacheListener<K, V> listener : cacheListeners) {
|
||||
regionFactory.addCacheListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(gatewaySenders)) {
|
||||
Assert.isTrue(
|
||||
hubId == null,
|
||||
"It is invalid to configure a region with both a hubId and gatewaySenders. Note that the enableGateway and hubId properties are deprecated since Gemfire 7.0");
|
||||
for (GatewaySender gatewaySender : gatewaySenders) {
|
||||
regionFactory.addGatewaySender(gatewaySender);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(asyncEventQueues)) {
|
||||
for (AsyncEventQueue asyncEventQueue : asyncEventQueues) {
|
||||
regionFactory.addAsyncEventQueue(asyncEventQueue);
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheLoader != null) {
|
||||
regionFactory.setCacheLoader(cacheLoader);
|
||||
}
|
||||
@@ -256,11 +290,6 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
|
||||
this.cacheListeners = cacheListeners;
|
||||
}
|
||||
|
||||
public void setSubRegions(List<Region<?, ?>> subRegions) {
|
||||
log.info("setting subRegions");
|
||||
this.subRegions = subRegions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache loader used for the region used by this factory. Used only
|
||||
* when a new region is created.Overrides the settings specified through
|
||||
@@ -315,6 +344,22 @@ public abstract class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K,
|
||||
this.diskStoreName = diskStoreName;
|
||||
}
|
||||
|
||||
public void setGatewaySenders(GatewaySender[] gatewaySenders) {
|
||||
this.gatewaySenders = gatewaySenders;
|
||||
}
|
||||
|
||||
public void setAsyncEventQueues(AsyncEventQueue[] asyncEventQueues) {
|
||||
this.asyncEventQueues = asyncEventQueues;
|
||||
}
|
||||
|
||||
public void setEnableGateway(boolean enableGateway) {
|
||||
this.enableGateway = enableGateway;
|
||||
}
|
||||
|
||||
public void setHubId(String hubId) {
|
||||
this.hubId = hubId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region attributes used for the region used by this factory.
|
||||
* Allows maximum control in specifying the region settings. Used only when
|
||||
|
||||
@@ -23,7 +23,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedArray;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -117,28 +119,67 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
ParsingUtils.parseEviction(parserContext, element, attrBuilder);
|
||||
ParsingUtils.parseMembershipAttributes(parserContext, element, attrBuilder);
|
||||
|
||||
String enableGateway = element.getAttribute("enable-gateway");
|
||||
String hubId = element.getAttribute("hub-id");
|
||||
// Factory will enable gateway if it is not set and hub-id is set.
|
||||
if (StringUtils.hasText(enableGateway)) {
|
||||
if (ParsingUtils.GEMFIRE_VERSION.startsWith("7")) {
|
||||
log.warn("'enable-gateway' is deprecated since Gemfire 7.0");
|
||||
}
|
||||
}
|
||||
ParsingUtils.setPropertyValue(element, builder, "enable-gateway");
|
||||
|
||||
if (StringUtils.hasText(hubId)) {
|
||||
if (ParsingUtils.GEMFIRE_VERSION.startsWith("7")) {
|
||||
log.warn("'hub-id' is deprecated since Gemfire 7.0");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(element, "gateway-sender"))) {
|
||||
parserContext.getReaderContext().error("It is invalid to specify both 'hub-id' and 'gateway-sender'",
|
||||
element);
|
||||
}
|
||||
}
|
||||
ParsingUtils.setPropertyValue(element, builder, "hub-id");
|
||||
|
||||
// Parse child elements
|
||||
|
||||
parseCollectionOfCustomSubElements(parserContext, element, builder,
|
||||
"com.gemstone.gemfire.cache.wan.GatewaySender", "gateway-sender", "gatewaySenders");
|
||||
parseCollectionOfCustomSubElements(parserContext, element, builder,
|
||||
"com.gemstone.gemfire.cache.wan.AsyncEventQueue", "async-event-queue", "asyncEventQueues");
|
||||
|
||||
List<Element> subElements = DomUtils.getChildElements(element);
|
||||
|
||||
// parse nested elements
|
||||
for (Element subElement : subElements) {
|
||||
String name = subElement.getLocalName();
|
||||
|
||||
if ("cache-listener".equals(name)) {
|
||||
builder.addPropertyValue("cacheListeners", parseCacheListener(parserContext, subElement, builder));
|
||||
if (subElement.getLocalName().equals("cache-listener")) {
|
||||
builder.addPropertyValue("cacheListeners",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder));
|
||||
}
|
||||
|
||||
else if ("cache-loader".equals(name)) {
|
||||
builder.addPropertyValue("cacheLoader", parseCacheLoader(parserContext, subElement, builder));
|
||||
else if (subElement.getLocalName().equals("cache-loader")) {
|
||||
builder.addPropertyValue("cacheLoader",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder));
|
||||
}
|
||||
|
||||
else if ("cache-writer".equals(name)) {
|
||||
builder.addPropertyValue("cacheWriter", parseCacheWriter(parserContext, subElement, builder));
|
||||
else if (subElement.getLocalName().equals("cache-writer")) {
|
||||
builder.addPropertyValue("cacheWriter",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder));
|
||||
}
|
||||
// subregion
|
||||
else if (name.endsWith("region")) {
|
||||
else if (subElement.getLocalName().endsWith("region")) {
|
||||
doParseSubRegion(element, subElement, parserContext, builder, subRegion);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void parseCollectionOfCustomSubElements(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder, String className, String subElementName, String propertyName) {
|
||||
List<Element> subElements = DomUtils.getChildElementsByTagName(element, new String[] { subElementName,
|
||||
subElementName + "-ref" });
|
||||
if (!CollectionUtils.isEmpty(subElements)) {
|
||||
|
||||
ManagedArray array = new ManagedArray(className, subElements.size());
|
||||
for (Element subElement : subElements) {
|
||||
array.add(ParsingUtils.parseRefOrNestedCustomElement(parserContext, subElement, builder));
|
||||
}
|
||||
builder.addPropertyValue(propertyName, array);
|
||||
}
|
||||
}
|
||||
|
||||
private BeanDefinition parseSubRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
@@ -151,16 +192,4 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
String name = element.getAttribute(NAME_ATTRIBUTE);
|
||||
return StringUtils.hasText(name) ? name : element.getAttribute(ID_ATTRIBUTE);
|
||||
}
|
||||
|
||||
private Object parseCacheListener(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
|
||||
return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
|
||||
private Object parseCacheLoader(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
|
||||
return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
|
||||
private Object parseCacheWriter(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
|
||||
return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.gemstone.gemfire.internal.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return AsyncEventQueueFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
Element asyncEventListenerElement = DomUtils.getChildElementByTagName(element, "async-event-listener");
|
||||
Object asyncEventListener = ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext,
|
||||
asyncEventListenerElement, builder);
|
||||
String cacheName = StringUtils.isEmpty(element.getAttribute("cache-ref")) ? "gemfire-cache" : element
|
||||
.getAttribute("cache-ref");
|
||||
builder.addConstructorArgReference(cacheName);
|
||||
builder.addConstructorArgValue(asyncEventListener);
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-queue-memory");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
|
||||
ParsingUtils.setPropertyValue(element, builder, "persistent");
|
||||
ParsingUtils.setPropertyValue(element, builder, "parallel");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
|
||||
import org.springframework.data.gemfire.wan.GatewayProxy;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewayHubFactoryBean.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfire-cache"));
|
||||
ParsingUtils.setPropertyValue(element, builder, "bind-address");
|
||||
ParsingUtils.setPropertyValue(element, builder, "manual-start");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "startup-policy");
|
||||
List<Element> gatewayElements = DomUtils.getChildElementsByTagName(element, "gateway");
|
||||
if (!CollectionUtils.isEmpty(gatewayElements)) {
|
||||
ManagedList gateways = new ManagedList();
|
||||
for (Element gatewayElement : gatewayElements) {
|
||||
BeanDefinitionBuilder gatewayBuilder = BeanDefinitionBuilder.genericBeanDefinition(GatewayProxy.class);
|
||||
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "gateway-id", "id");
|
||||
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "concurrency-level");
|
||||
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-read-timeout");
|
||||
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(gatewayElement, gatewayBuilder, "order-policy");
|
||||
List<Element> endpointElements = DomUtils.getChildElementsByTagName(gatewayElement, "gateway-endpoint");
|
||||
if (!CollectionUtils.isEmpty(endpointElements)) {
|
||||
ManagedList endpoints = new ManagedList();
|
||||
for (Element endpointElement : endpointElements) {
|
||||
BeanDefinitionBuilder endpointBuilder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(GatewayProxy.GatewayEndpoint.class);
|
||||
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "host");
|
||||
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "port");
|
||||
ParsingUtils.setPropertyValue(endpointElement, endpointBuilder, "endpoint-id", "id");
|
||||
endpoints.add(endpointBuilder.getBeanDefinition());
|
||||
}
|
||||
gatewayBuilder.addPropertyValue("endpoints", endpoints);
|
||||
}
|
||||
|
||||
Element gatewayListenerElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-listener");
|
||||
if (gatewayListenerElement != null) {
|
||||
Object obj = ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, gatewayListenerElement,
|
||||
gatewayBuilder);
|
||||
gatewayBuilder.addPropertyValue("listeners", obj);
|
||||
}
|
||||
|
||||
Element gatewayQueueElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-queue");
|
||||
if (gatewayQueueElement != null) {
|
||||
BeanDefinitionBuilder queueBuilder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(GatewayProxy.GatewayQueue.class);
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "alert-threshold");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-size");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "batch-time-interval");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "maximum-queue-memory");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "persistent");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "disk-store-ref");
|
||||
ParsingUtils.setPropertyValue(gatewayQueueElement, queueBuilder, "enable-batch-conflation");
|
||||
gatewayBuilder.addPropertyValue("queue", queueBuilder.getBeanDefinition());
|
||||
}
|
||||
gateways.add(gatewayBuilder.getBeanDefinition());
|
||||
}
|
||||
builder.addPropertyValue("gateways", gateways);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser {
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewayReceiverFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfire-cache"));
|
||||
ParsingUtils.setPropertyValue(element, builder, "start-port");
|
||||
ParsingUtils.setPropertyValue(element, builder, "end-port");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-time-between-pings");
|
||||
ParsingUtils.setPropertyValue(element, builder, "bind-address");
|
||||
ParsingUtils.parseTransportFilters(element, parserContext, builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
class GatewaySenderParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewaySenderFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfire-cache"));
|
||||
ParsingUtils.setPropertyValue(element, builder, "alert-threshold");
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "batch-time-interval");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-synchronous");
|
||||
ParsingUtils.setPropertyValue(element, builder, "dispatcher-threads");
|
||||
ParsingUtils.setPropertyValue(element, builder, "enable-batch-conflation");
|
||||
ParsingUtils.setPropertyValue(element, builder, "manual-start");
|
||||
ParsingUtils.setPropertyValue(element, builder, "maximum-queue-memory");
|
||||
ParsingUtils.setPropertyValue(element, builder, "order-policy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "remote-distributed-system-id");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-read-timeout");
|
||||
ParsingUtils.setPropertyValue(element, builder, "persistent");
|
||||
ParsingUtils.setPropertyValue(element, builder, "parallel");
|
||||
|
||||
Element eventFilterElement = DomUtils.getChildElementByTagName(element, "event-filter");
|
||||
if (eventFilterElement != null) {
|
||||
builder.addPropertyValue("eventFilters",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, eventFilterElement, builder));
|
||||
}
|
||||
|
||||
ParsingUtils.parseTransportFilters(element, parserContext, builder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.data.gemfire.repository.config.GemfireRepositoryParser;
|
||||
|
||||
/**
|
||||
* Namespace handler for GemFire definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
*/
|
||||
class GemfireDataNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("repositories", new GemfireRepositoryParser());
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.data.gemfire.repository.config.GemfireRepositoryParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Namespace handler for GemFire definitions.
|
||||
@@ -26,12 +31,25 @@ import org.springframework.data.gemfire.repository.config.GemfireRepositoryParse
|
||||
* @author David Turanski
|
||||
*/
|
||||
class GemfireNamespaceHandler extends NamespaceHandlerSupport {
|
||||
static final List<String> GEMFIRE7_ELEMENTS = Arrays.asList("async-event-queue", "gateway-sender",
|
||||
"gateway-receiver");
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
|
||||
boolean v7ElementsPresent = GEMFIRE7_ELEMENTS.contains(element.getLocalName());
|
||||
|
||||
if (v7ElementsPresent) {
|
||||
ParsingUtils.throwExceptionIfNotGemfireV7(element.getLocalName(), null, parserContext);
|
||||
}
|
||||
|
||||
return super.parse(element, parserContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("cache", new CacheParser());
|
||||
registerBeanDefinitionParser("client-cache", new ClientCacheParser());
|
||||
|
||||
registerBeanDefinitionParser("lookup-region", new LookupRegionParser());
|
||||
registerBeanDefinitionParser("replicated-region", new ReplicatedRegionParser());
|
||||
registerBeanDefinitionParser("partitioned-region", new PartitionedRegionParser());
|
||||
@@ -43,6 +61,10 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport {
|
||||
registerBeanDefinitionParser("cache-server", new CacheServerParser());
|
||||
registerBeanDefinitionParser("transaction-manager", new TransactionManagerParser());
|
||||
registerBeanDefinitionParser("cq-listener-container", new GemfireListenerContainerParser());
|
||||
registerBeanDefinitionParser("repositories", new GemfireRepositoryParser());
|
||||
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
|
||||
registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser());
|
||||
registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser());
|
||||
// V6 WAN parsers
|
||||
registerBeanDefinitionParser("gateway-hub", new GatewayHubParser());
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ 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.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.LossAction;
|
||||
@@ -48,6 +49,8 @@ import com.gemstone.gemfire.cache.Scope;
|
||||
*/
|
||||
abstract class ParsingUtils {
|
||||
|
||||
final static String GEMFIRE_VERSION = CacheFactory.getVersion();
|
||||
|
||||
private static final String ALIASES_KEY = ParsingUtils.class.getName() + ":aliases";
|
||||
|
||||
static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attributeName,
|
||||
@@ -119,11 +122,14 @@ abstract class ParsingUtils {
|
||||
*/
|
||||
static Object parseRefOrNestedBeanDeclaration(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder) {
|
||||
return parseRefOrNestedBeanDeclaration(parserContext, element, builder, "ref");
|
||||
return parseRefOrNestedBeanDeclaration(parserContext, element, builder, "ref", false);
|
||||
}
|
||||
|
||||
static Object parseRefOrNestedBeanDeclaration(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder, String refAttrName) {
|
||||
static Object getBeanReference(ParserContext parserContext, Element element) {
|
||||
return getBeanReference(parserContext, element, "ref");
|
||||
}
|
||||
|
||||
static Object getBeanReference(ParserContext parserContext, Element element, String refAttrName) {
|
||||
String attr = element.getAttribute(refAttrName);
|
||||
boolean hasRef = StringUtils.hasText(attr);
|
||||
|
||||
@@ -138,18 +144,54 @@ abstract class ParsingUtils {
|
||||
}
|
||||
return new RuntimeBeanReference(attr);
|
||||
}
|
||||
|
||||
if (childElements.isEmpty()) {
|
||||
parserContext.getReaderContext().error(
|
||||
"specify either '" + refAttrName + "' attribute or a nested bean declaration for '"
|
||||
+ element.getLocalName() + "' element", element);
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Object parseRefOrNestedCustomElement(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder) {
|
||||
Object beanRef = ParsingUtils.getBeanReference(parserContext, element, "bean");
|
||||
if (beanRef != null) {
|
||||
return beanRef;
|
||||
}
|
||||
else {
|
||||
return parserContext.getDelegate().parseCustomElement(element, builder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
static Object parseRefOrSingleNestedBeanDeclaration(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder) {
|
||||
return parseRefOrNestedBeanDeclaration(parserContext, element, builder, "ref", true);
|
||||
}
|
||||
|
||||
static Object parseRefOrNestedBeanDeclaration(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder, String refAttrName) {
|
||||
return parseRefOrNestedBeanDeclaration(parserContext, element, builder, refAttrName, false);
|
||||
}
|
||||
|
||||
static Object parseRefOrNestedBeanDeclaration(ParserContext parserContext, Element element,
|
||||
BeanDefinitionBuilder builder, String refAttrName, boolean single) {
|
||||
Object beanRef = getBeanReference(parserContext, element, refAttrName);
|
||||
if (beanRef != null) {
|
||||
return beanRef;
|
||||
}
|
||||
|
||||
// check nested declarations
|
||||
List<Element> childElements = DomUtils.getChildElements(element);
|
||||
|
||||
// nested parse nested bean definition
|
||||
if (childElements.size() == 1) {
|
||||
return parserContext.getDelegate().parsePropertySubElement(childElements.get(0),
|
||||
builder.getRawBeanDefinition());
|
||||
}
|
||||
else {
|
||||
if (single) {
|
||||
parserContext.getReaderContext().error(
|
||||
"the element '" + element.getLocalName()
|
||||
+ "' does not support multiple nested bean definitions", element);
|
||||
}
|
||||
}
|
||||
|
||||
ManagedList<Object> list = new ManagedList<Object>();
|
||||
|
||||
@@ -199,6 +241,14 @@ abstract class ParsingUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void parseTransportFilters(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
Element transportFilterElement = DomUtils.getChildElementByTagName(element, "transport-filter");
|
||||
if (transportFilterElement != null) {
|
||||
builder.addPropertyValue("transportFilters",
|
||||
parseRefOrNestedBeanDeclaration(parserContext, transportFilterElement, builder));
|
||||
}
|
||||
}
|
||||
|
||||
static void parseStatistics(Element element, BeanDefinitionBuilder attrBuilder) {
|
||||
setPropertyValue(element, attrBuilder, "statistics", "statisticsEnabled");
|
||||
}
|
||||
@@ -276,6 +326,17 @@ abstract class ParsingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static void throwExceptionIfNotGemfireV7(String elementName, String attributeName, ParserContext parserContext) {
|
||||
boolean checkGemfireV7 = !GEMFIRE_VERSION.startsWith("7");
|
||||
if (checkGemfireV7) {
|
||||
String messagePrefix = (attributeName == null) ? "element '" + elementName + "'" : "attribute '"
|
||||
+ attributeName + " of element '" + elementName + "'";
|
||||
parserContext.getReaderContext().error(
|
||||
messagePrefix + " requires Gemfire version 7 or later. The current version is " + GEMFIRE_VERSION,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
static void parseScope(Element element, BeanDefinitionBuilder builder) {
|
||||
String scope = element.getAttribute("scope");
|
||||
if (StringUtils.hasText(scope)) {
|
||||
|
||||
@@ -42,11 +42,24 @@ public class GemfirePersistentProperty extends AnnotationBasedPersistentProperty
|
||||
super(field, propertyDescriptor, owner, simpleTypeHolder);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#createAssociation()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#
|
||||
* createAssociation()
|
||||
*/
|
||||
@Override
|
||||
protected Association<GemfirePersistentProperty> createAssociation() {
|
||||
return null;
|
||||
return new Association<GemfirePersistentProperty>(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAssociation() {
|
||||
return field.isAnnotationPresent(RegionRef.class) || super.isAssociation();
|
||||
}
|
||||
|
||||
public RegionRef geRegionRef() {
|
||||
return getField().getAnnotation(RegionRef.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.data.convert.EntityInstantiator;
|
||||
import org.springframework.data.convert.EntityInstantiators;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -37,21 +38,24 @@ import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
import com.gemstone.gemfire.pdx.PdxWriter;
|
||||
|
||||
/**
|
||||
* {@link PdxSerializer} implementation that uses a {@link GemfireMappingContext} to read and write entities.
|
||||
* {@link PdxSerializer} implementation that uses a
|
||||
* {@link GemfireMappingContext} to read and write entities.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAware {
|
||||
|
||||
private final GemfireMappingContext mappingContext;
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
private EntityInstantiators instantiators;
|
||||
|
||||
private SpELContext context;
|
||||
|
||||
/**
|
||||
* Creates a new {@link MappingPdxSerializer} using the given {@link GemfireMappingContext} and
|
||||
* {@link ConversionService}.
|
||||
* Creates a new {@link MappingPdxSerializer} using the given
|
||||
* {@link GemfireMappingContext} and {@link ConversionService}.
|
||||
*
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
* @param conversionService must not be {@literal null}.
|
||||
@@ -68,7 +72,16 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the {@link EntityInstantiator}s to be used to create the instances to be read.
|
||||
* Creates a new {@link MappingPdxSerializer} using the default
|
||||
* {@link GemfireMappingContext} and {@link DefaultConversionService}.
|
||||
*/
|
||||
public MappingPdxSerializer() {
|
||||
this(new GemfireMappingContext(), new DefaultConversionService());
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the {@link EntityInstantiator}s to be used to create the
|
||||
* instances to be read.
|
||||
*
|
||||
* @param gemfireInstantiators must not be {@literal null}.
|
||||
*/
|
||||
@@ -77,9 +90,12 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
this.instantiators = new EntityInstantiators(gemfireInstantiators);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.context.ApplicationContextAware#setApplicationContext
|
||||
* (org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
@@ -88,8 +104,11 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.pdx.PdxSerializer#fromData(java.lang.Class, com.gemstone.gemfire.pdx.PdxReader)
|
||||
*
|
||||
* @see com.gemstone.gemfire.pdx.PdxSerializer#fromData(java.lang.Class,
|
||||
* com.gemstone.gemfire.pdx.PdxReader)
|
||||
*/
|
||||
@Override
|
||||
public Object fromData(Class<?> type, final PdxReader reader) {
|
||||
|
||||
final GemfirePersistentEntity<?> entity = mappingContext.getPersistentEntity(type);
|
||||
@@ -102,9 +121,11 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
|
||||
Object instance = instantiator.createInstance(entity, provider);
|
||||
|
||||
final BeanWrapper<PersistentEntity<Object, ?>, Object> wrapper = BeanWrapper.create(instance, conversionService);
|
||||
final BeanWrapper<PersistentEntity<Object, ?>, Object> wrapper = BeanWrapper
|
||||
.create(instance, conversionService);
|
||||
|
||||
entity.doWithProperties(new PropertyHandler<GemfirePersistentProperty>() {
|
||||
@Override
|
||||
public void doWithPersistentProperty(GemfirePersistentProperty persistentProperty) {
|
||||
|
||||
if (entity.isConstructorArgument(persistentProperty)) {
|
||||
@@ -115,7 +136,8 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
|
||||
try {
|
||||
wrapper.setProperty(persistentProperty, value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException("Could not read value " + value.toString(), e);
|
||||
}
|
||||
}
|
||||
@@ -126,20 +148,25 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.pdx.PdxSerializer#toData(java.lang.Object, com.gemstone.gemfire.pdx.PdxWriter)
|
||||
*
|
||||
* @see com.gemstone.gemfire.pdx.PdxSerializer#toData(java.lang.Object,
|
||||
* com.gemstone.gemfire.pdx.PdxWriter)
|
||||
*/
|
||||
@Override
|
||||
public boolean toData(Object value, final PdxWriter writer) {
|
||||
|
||||
GemfirePersistentEntity<?> entity = mappingContext.getPersistentEntity(value.getClass());
|
||||
final BeanWrapper<PersistentEntity<Object, ?>, Object> wrapper = BeanWrapper.create(value, conversionService);
|
||||
|
||||
entity.doWithProperties(new PropertyHandler<GemfirePersistentProperty>() {
|
||||
@Override
|
||||
public void doWithPersistentProperty(GemfirePersistentProperty persistentProperty) {
|
||||
|
||||
try {
|
||||
Object value = wrapper.getProperty(persistentProperty);
|
||||
writer.writeObject(persistentProperty.getName(), value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException("Could not write value for property " + persistentProperty.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.mapping;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.data.annotation.Reference;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Documented
|
||||
@Reference
|
||||
public @interface RegionRef {
|
||||
String value() default "";
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.mapping;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -22,7 +23,6 @@ import java.util.Map;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Collections;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
@@ -33,10 +33,12 @@ import com.gemstone.gemfire.cache.Region;
|
||||
public class Regions implements Iterable<Region<?, ?>> {
|
||||
|
||||
private final Map<String, Region<?, ?>> regions;
|
||||
|
||||
private final MappingContext<? extends GemfirePersistentEntity<?>, ?> context;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Regions} wrapper for the given {@link Region}s and {@link MappingContext}.
|
||||
* Creates a new {@link Regions} wrapper for the given {@link Region}s and
|
||||
* {@link MappingContext}.
|
||||
*
|
||||
* @param regions must not be {@literal null}.
|
||||
* @param context must not be {@literal null}.
|
||||
@@ -58,8 +60,9 @@ public class Regions implements Iterable<Region<?, ?>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Region} the given type is mapped to. Will try to find a {@link Region} with the simple class
|
||||
* name in case no mapping information is found.
|
||||
* Returns the {@link Region} the given type is mapped to. Will try to find
|
||||
* a {@link Region} with the simple class name in case no mapping
|
||||
* information is found.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return the {@link Region} the given type is mapped to.
|
||||
@@ -89,6 +92,7 @@ public class Regions implements Iterable<Region<?, ?>> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -40,13 +40,15 @@ import org.springframework.util.Assert;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* {@link RepositoryFactorySupport} implementation creating repository proxies for Gemfire.
|
||||
* {@link RepositoryFactorySupport} implementation creating repository proxies
|
||||
* for Gemfire.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
private final MappingContext<? extends GemfirePersistentEntity<?>, GemfirePersistentProperty> context;
|
||||
|
||||
private final Regions regions;
|
||||
|
||||
/**
|
||||
@@ -66,7 +68,10 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
* #getEntityInformation(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -78,7 +83,11 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getTargetRepository(org.springframework.data.repository.core.RepositoryMetadata)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
* #getTargetRepository(org.springframework.data.repository.core.
|
||||
* RepositoryMetadata)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@@ -98,17 +107,21 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
Region<?, ?> region = regions.getRegion(domainClass);
|
||||
|
||||
if (region == null) {
|
||||
throw new IllegalStateException(String.format("No region '%s' found for domain class %s! Make sure you have "
|
||||
+ "configured a Gemfire region of that name in your application context!", entity.getRegionName(), domainClass));
|
||||
throw new IllegalStateException(String.format(
|
||||
"No region '%s' found for domain class %s! Make sure you have "
|
||||
+ "configured a Gemfire region of that name in your application context!",
|
||||
entity.getRegionName(), domainClass));
|
||||
}
|
||||
|
||||
Class<?> regionKeyType = region.getAttributes().getKeyConstraint();
|
||||
Class<?> entityIdType = metadata.getIdType();
|
||||
|
||||
if (regionKeyType != null && entity.getIdProperty() != null) {
|
||||
Assert.isTrue(regionKeyType.isAssignableFrom(entityIdType), String.format(
|
||||
"The region referenced only supports keys of type %s but the entity to be stored has an id of type %s!",
|
||||
regionKeyType, entityIdType));
|
||||
Assert.isTrue(
|
||||
regionKeyType.isAssignableFrom(entityIdType),
|
||||
String.format(
|
||||
"The region referenced only supports keys of type %s but the entity to be stored has an id of type %s!",
|
||||
regionKeyType, entityIdType));
|
||||
}
|
||||
|
||||
return new GemfireTemplate(region);
|
||||
@@ -116,7 +129,11 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getRepositoryBaseClass(org.springframework.data.repository.core.RepositoryMetadata)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
* #getRepositoryBaseClass(org.springframework.data.repository.core.
|
||||
* RepositoryMetadata)
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
|
||||
@@ -125,7 +142,11 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getQueryLookupStrategy(org.springframework.data.repository.query.QueryLookupStrategy.Key)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
* #getQueryLookupStrategy(org.springframework.data.repository.query.
|
||||
* QueryLookupStrategy.Key)
|
||||
*/
|
||||
@Override
|
||||
protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
|
||||
@@ -142,7 +163,8 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
String namedQueryName = queryMethod.getNamedQueryName();
|
||||
if (namedQueries.hasQuery(namedQueryName)) {
|
||||
return new StringBasedGemfireRepositoryQuery(namedQueries.getQuery(namedQueryName), queryMethod, template);
|
||||
return new StringBasedGemfireRepositoryQuery(namedQueries.getQuery(namedQueryName), queryMethod,
|
||||
template);
|
||||
}
|
||||
|
||||
return new PartTreeGemfireRepositoryQuery(queryMethod, template);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
|
||||
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Collections;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
@@ -38,20 +38,24 @@ import com.gemstone.gemfire.cache.Region;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GemfireRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> extends
|
||||
RepositoryFactoryBeanSupport<T, S, ID> implements ApplicationContextAware {
|
||||
RepositoryFactoryBeanSupport<T, S, ID> implements ApplicationContextAware {
|
||||
|
||||
private MappingContext<? extends GemfirePersistentEntity<?>, GemfirePersistentProperty> context;
|
||||
|
||||
private Iterable<Region<?, ?>> regions;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.context.ApplicationContextAware#setApplicationContext
|
||||
* (org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
Collection<Region> regions = applicationContext.getBeansOfType(Region.class).values();
|
||||
this.regions = Collections.unmodifiableCollection(regions);
|
||||
this.regions = (Iterable) Collections.unmodifiableCollection(regions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,13 +63,17 @@ RepositoryFactoryBeanSupport<T, S, ID> implements ApplicationContextAware {
|
||||
*
|
||||
* @param context the context to set
|
||||
*/
|
||||
public void setMappingContext(MappingContext<? extends GemfirePersistentEntity<?>, GemfirePersistentProperty> context) {
|
||||
public void setMappingContext(
|
||||
MappingContext<? extends GemfirePersistentEntity<?>, GemfirePersistentProperty> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport#createRepositoryFactory()
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport
|
||||
* #createRepositoryFactory()
|
||||
*/
|
||||
@Override
|
||||
protected RepositoryFactorySupport createRepositoryFactory() {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.gemstone.gemfire.cache.Region;
|
||||
public class SimpleGemfireRepository<T, ID extends Serializable> implements GemfireRepository<T, ID> {
|
||||
|
||||
private final GemfireTemplate template;
|
||||
|
||||
private final EntityInformation<T, ID> entityInformation;
|
||||
|
||||
/**
|
||||
@@ -43,8 +44,10 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#save(S)
|
||||
*/
|
||||
@Override
|
||||
public <U extends T> U save(U entity) {
|
||||
template.put(entityInformation.getId(entity), entity);
|
||||
return entity;
|
||||
@@ -52,8 +55,12 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Iterable)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.CrudRepository#save(java.lang.Iterable
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public <U extends T> Iterable<U> save(Iterable<U> entities) {
|
||||
List<U> result = new ArrayList<U>();
|
||||
for (U entity : entities) {
|
||||
@@ -64,8 +71,11 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.
|
||||
* Serializable)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T findOne(ID id) {
|
||||
Object object = template.get(id);
|
||||
@@ -74,18 +84,24 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#exists(java.io.Serializable)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#exists(java.io.
|
||||
* Serializable)
|
||||
*/
|
||||
@Override
|
||||
public boolean exists(ID id) {
|
||||
return findOne(id) != null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#findAll()
|
||||
*/
|
||||
@Override
|
||||
public Collection<T> findAll() {
|
||||
return template.execute(new GemfireCallback<Collection<T>>() {
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Collection<T> doInGemfire(Region region) {
|
||||
return region.values();
|
||||
@@ -93,9 +109,12 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#findAll(java.lang.Iterable)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.CrudRepository#findAll(java.lang.
|
||||
* Iterable)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -111,11 +130,15 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#count()
|
||||
*/
|
||||
@Override
|
||||
public long count() {
|
||||
return template.execute(new GemfireCallback<Long>() {
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
// TODO: Take into account keySetOnServer()
|
||||
public Long doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
|
||||
return Long.valueOf(region.keySet().size());
|
||||
}
|
||||
@@ -124,16 +147,24 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.CrudRepository#delete(java.lang.Object
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
template.remove(entityInformation.getId(entity));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public void delete(Iterable<? extends T> entities) {
|
||||
for (T entity : entities) {
|
||||
delete(entity);
|
||||
@@ -142,11 +173,14 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#deleteAll()
|
||||
*/
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
|
||||
template.execute(new GemfireCallback<Void>() {
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Void doInGemfire(Region region) {
|
||||
region.clear();
|
||||
@@ -157,15 +191,21 @@ public class SimpleGemfireRepository<T, ID extends Serializable> implements Gemf
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.io.
|
||||
* Serializable)
|
||||
*/
|
||||
@Override
|
||||
public void delete(ID id) {
|
||||
template.remove(id);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.gemfire.repository.GemfireRepository#save(org.springframework.data.gemfire.repository.Wrapper)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.gemfire.repository.GemfireRepository#save(org
|
||||
* .springframework.data.gemfire.repository.Wrapper)
|
||||
*/
|
||||
@Override
|
||||
public T save(Wrapper<T, ID> wrapper) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
|
||||
/**
|
||||
* Base class for Gemfire WAN Gateway component factory beans
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractWANComponentFactoryBean<T> implements FactoryBean<T>, InitializingBean, BeanNameAware,
|
||||
DisposableBean {
|
||||
protected Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
protected String name;
|
||||
|
||||
protected final Cache cache;
|
||||
|
||||
protected AbstractWANComponentFactoryBean(Cache cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(name, "Name cannot be null");
|
||||
Assert.notNull(cache, "Cache cannot be null");
|
||||
doInit();
|
||||
}
|
||||
|
||||
protected abstract void doInit();
|
||||
|
||||
@Override
|
||||
public abstract T getObject() throws Exception;
|
||||
|
||||
@Override
|
||||
public abstract Class<?> getObjectType();
|
||||
|
||||
@Override
|
||||
public final boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.AsyncEventQueueFactory;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
import com.gemstone.gemfire.cache.wan.AsyncEventListener;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating GemFire {@link AsyncEventQueue}s.
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class AsyncEventQueueFactoryBean extends AbstractWANComponentFactoryBean<AsyncEventQueue> {
|
||||
|
||||
public void setDiskStoreRef(String diskStoreRef) {
|
||||
this.diskStoreRef = diskStoreRef;
|
||||
}
|
||||
|
||||
private final AsyncEventListener asyncEventListener;
|
||||
|
||||
private AsyncEventQueue asyncEventQueue;
|
||||
|
||||
private Integer batchSize;
|
||||
|
||||
private Integer maximumQueueMemory;
|
||||
|
||||
private Boolean persistent;
|
||||
|
||||
private Boolean parallel;
|
||||
|
||||
private String diskStoreRef;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache the gemfire cache
|
||||
* @param asyncEventListener required {@link AsyncEventListener}
|
||||
*/
|
||||
public AsyncEventQueueFactoryBean(Cache cache, AsyncEventListener asyncEventListener) {
|
||||
super(cache);
|
||||
this.asyncEventListener = asyncEventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncEventQueue getObject() throws Exception {
|
||||
return asyncEventQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return AsyncEventQueue.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
Assert.notNull(asyncEventListener, "AsyncEventListener cannot be null");
|
||||
|
||||
AsyncEventQueueFactory asyncEventQueueFactory = cache.createAsyncEventQueueFactory();
|
||||
if (parallel != null) {
|
||||
asyncEventQueueFactory.setParallel(parallel);
|
||||
}
|
||||
if (persistent != null) {
|
||||
asyncEventQueueFactory.setPersistent(persistent);
|
||||
}
|
||||
if (batchSize != null) {
|
||||
asyncEventQueueFactory.setBatchSize(batchSize);
|
||||
}
|
||||
if (diskStoreRef != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
||||
asyncEventQueueFactory.setDiskStoreName(diskStoreRef);
|
||||
}
|
||||
|
||||
if (maximumQueueMemory != null) {
|
||||
asyncEventQueueFactory.setMaximumQueueMemory(maximumQueueMemory);
|
||||
}
|
||||
|
||||
asyncEventQueue = asyncEventQueueFactory.create(name, asyncEventListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
if (!cache.isClosed()) {
|
||||
try {
|
||||
asyncEventQueue.stop();
|
||||
asyncEventListener.close();
|
||||
}
|
||||
catch (CacheClosedException cce) {
|
||||
// nothing to see folks, move on.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBatchSize(Integer batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
|
||||
this.maximumQueueMemory = maximumQueueMemory;
|
||||
}
|
||||
|
||||
public void setPersistent(Boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public void setParallel(Boolean parallel) {
|
||||
this.parallel = parallel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.gemfire.wan.GatewayProxy.GatewayQueue;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating a GemFire {@link GatewayHub} (deprecated in Gemfire
|
||||
* 7)
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<GatewayHub> {
|
||||
private static List<String> validStartupPolicyValues = Arrays.asList("none", "primary", "secondary");
|
||||
|
||||
private static List<String> validOrderPolicyValues = Arrays.asList("KEY,PARTITION,THREAD");
|
||||
|
||||
private GatewayHub gatewayHub;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private String bindAddress;
|
||||
|
||||
private Integer maximumTimeBetweenPings;
|
||||
|
||||
private Integer socketBufferSize;
|
||||
|
||||
private String startupPolicy;
|
||||
|
||||
private Boolean manualStart;
|
||||
|
||||
private List<GatewayProxy> gateways;
|
||||
|
||||
/**
|
||||
* @param cache the Gemfire cache
|
||||
*/
|
||||
public GatewayHubFactoryBean(Cache cache) {
|
||||
super(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayHub getObject() throws Exception {
|
||||
return gatewayHub;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return GatewayHub.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
gatewayHub = cache.addGatewayHub(name, port == null ? GatewayHub.DEFAULT_PORT : port);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("added gateway hub " + name);
|
||||
}
|
||||
|
||||
Assert.notNull(cache.getGatewayHub(name));
|
||||
|
||||
if (bindAddress != null) {
|
||||
gatewayHub.setBindAddress(bindAddress);
|
||||
}
|
||||
if (manualStart != null) {
|
||||
gatewayHub.setManualStart(manualStart);
|
||||
}
|
||||
if (socketBufferSize != null) {
|
||||
gatewayHub.setSocketBufferSize(socketBufferSize);
|
||||
}
|
||||
if (startupPolicy != null) {
|
||||
Assert.isTrue(validStartupPolicyValues.contains(startupPolicy), "The value of startup policy:'"
|
||||
+ startupPolicy + "' is invalid");
|
||||
gatewayHub.setStartupPolicy(startupPolicy);
|
||||
}
|
||||
if (maximumTimeBetweenPings != null) {
|
||||
gatewayHub.setMaximumTimeBetweenPings(maximumTimeBetweenPings);
|
||||
}
|
||||
for (GatewayProxy gateway : gateways) {
|
||||
Gateway gw = gatewayHub.addGateway(
|
||||
gateway.getId(),
|
||||
gateway.getConcurrencyLevel() == null ? Gateway.DEFAULT_CONCURRENCY_LEVEL : gateway
|
||||
.getConcurrencyLevel());
|
||||
if (!CollectionUtils.isEmpty(gateway.getEndpoints())) {
|
||||
for (GatewayProxy.GatewayEndpoint endpoint : gateway.getEndpoints()) {
|
||||
gw.addEndpoint(endpoint.getId(), endpoint.getHost(), endpoint.getPort());
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(gateway.getListeners())) {
|
||||
for (GatewayEventListener listener : gateway.getListeners()) {
|
||||
gw.addListener(listener);
|
||||
}
|
||||
}
|
||||
if (gateway.getOrderPolicy() != null) {
|
||||
Assert.isTrue(validOrderPolicyValues.contains(gateway.getOrderPolicy()), "The value of order policy:'"
|
||||
+ gateway.getOrderPolicy() + "' is invalid");
|
||||
gw.setOrderPolicy(OrderPolicy.valueOf(gateway.getOrderPolicy()));
|
||||
}
|
||||
if (gateway.getSocketBufferSize() != null) {
|
||||
gw.setSocketBufferSize(gateway.getSocketBufferSize());
|
||||
}
|
||||
if (gateway.getSocketReadTimeout() != null) {
|
||||
gw.setSocketReadTimeout(gateway.getSocketReadTimeout());
|
||||
}
|
||||
|
||||
if (gateway.getQueue() != null) {
|
||||
GatewayQueue queue = gateway.getQueue();
|
||||
GatewayQueueAttributes queueAttributes = gw.getQueueAttributes();
|
||||
if (queue.getAlertThreshold() != null) {
|
||||
queueAttributes.setAlertThreshold(queue.getAlertThreshold());
|
||||
}
|
||||
if (queue.getEnableBatchConflation() != null) {
|
||||
queueAttributes.setBatchConflation(queue.getEnableBatchConflation());
|
||||
}
|
||||
if (queue.getBatchSize() != null) {
|
||||
queueAttributes.setBatchSize(queue.getBatchSize());
|
||||
}
|
||||
if (queue.getBatchTimeInterval() != null) {
|
||||
queueAttributes.setBatchTimeInterval(queue.getBatchTimeInterval());
|
||||
}
|
||||
|
||||
if (queue.getDiskStoreRef() != null) {
|
||||
boolean persistent = (queue.getPersistent() == null) ? Boolean.TRUE : queue.getPersistent();
|
||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
||||
queueAttributes.setDiskStoreName(queue.getDiskStoreRef());
|
||||
}
|
||||
|
||||
if (queue.getPersistent() != null) {
|
||||
queueAttributes.setEnablePersistence(queue.getPersistent());
|
||||
}
|
||||
|
||||
if (queue.getMaximumQueueMemory() != null) {
|
||||
queueAttributes.setMaximumQueueMemory(queue.getMaximumQueueMemory());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void setBindAddress(String bindAddress) {
|
||||
this.bindAddress = bindAddress;
|
||||
}
|
||||
|
||||
public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) {
|
||||
this.maximumTimeBetweenPings = maximumTimeBetweenPings;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
|
||||
public void setStartupPolicy(String startupPolicy) {
|
||||
this.startupPolicy = startupPolicy;
|
||||
}
|
||||
|
||||
public void setManualStart(Boolean manualStart) {
|
||||
this.manualStart = manualStart;
|
||||
}
|
||||
|
||||
public void setGateways(List<GatewayProxy> gateways) {
|
||||
this.gateways = gateways;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
|
||||
/**
|
||||
* This class used to allow decoupling of 'gateway' parsing from 'gateway-hub'
|
||||
* parsing
|
||||
*
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewayProxy {
|
||||
|
||||
private List<GatewayEndpoint> endpoints;
|
||||
|
||||
private Integer concurrencyLevel;
|
||||
|
||||
private String id;
|
||||
|
||||
private List<GatewayEventListener> listeners;
|
||||
|
||||
private String orderPolicy;
|
||||
|
||||
private int socketBufferSize;
|
||||
|
||||
private int socketReadTimeout;
|
||||
|
||||
private GatewayQueue queue;
|
||||
|
||||
public void setEndpoints(List<GatewayEndpoint> endpoints) {
|
||||
this.endpoints = endpoints;
|
||||
}
|
||||
|
||||
public void setListeners(List<GatewayEventListener> listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
public void setQueue(GatewayQueue queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
public GatewayQueue getQueue() {
|
||||
return this.queue;
|
||||
}
|
||||
|
||||
public Integer getConcurrencyLevel() {
|
||||
return this.concurrencyLevel;
|
||||
}
|
||||
|
||||
public List<GatewayEndpoint> getEndpoints() {
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<GatewayEventListener> getListeners() {
|
||||
return this.listeners;
|
||||
}
|
||||
|
||||
public String getOrderPolicy() {
|
||||
return this.orderPolicy;
|
||||
}
|
||||
|
||||
public Integer getSocketBufferSize() {
|
||||
return this.socketBufferSize;
|
||||
}
|
||||
|
||||
public Integer getSocketReadTimeout() {
|
||||
return this.socketReadTimeout;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setOrderPolicy(String orderPolicy) {
|
||||
this.orderPolicy = orderPolicy;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(int socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
|
||||
}
|
||||
|
||||
public void setSocketReadTimeout(int socketReadTimeout) {
|
||||
this.socketReadTimeout = socketReadTimeout;
|
||||
}
|
||||
|
||||
public static class GatewayEndpoint {
|
||||
private String host;
|
||||
|
||||
private String id;
|
||||
|
||||
private int port;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GatewayQueue {
|
||||
private Integer alertThreshold;
|
||||
|
||||
private Boolean enableBatchConflation;
|
||||
|
||||
private Integer batchTimeInterval;
|
||||
|
||||
private Integer batchSize;
|
||||
|
||||
private Boolean persistent;
|
||||
|
||||
private String diskStoreRef;
|
||||
|
||||
private Integer maximumQueueMemory;
|
||||
|
||||
public Integer getAlertThreshold() {
|
||||
return alertThreshold;
|
||||
}
|
||||
|
||||
public void setAlertThreshold(Integer alertThreshold) {
|
||||
this.alertThreshold = alertThreshold;
|
||||
}
|
||||
|
||||
public Boolean getEnableBatchConflation() {
|
||||
return enableBatchConflation;
|
||||
}
|
||||
|
||||
public void setEnableBatchConflation(Boolean enableBatchConflation) {
|
||||
this.enableBatchConflation = enableBatchConflation;
|
||||
}
|
||||
|
||||
public Integer getBatchTimeInterval() {
|
||||
return batchTimeInterval;
|
||||
}
|
||||
|
||||
public void setBatchTimeInterval(Integer batchTimeInterval) {
|
||||
this.batchTimeInterval = batchTimeInterval;
|
||||
}
|
||||
|
||||
public Integer getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(Integer batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public Boolean getPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
|
||||
public void setPersistent(Boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public String getDiskStoreRef() {
|
||||
return diskStoreRef;
|
||||
}
|
||||
|
||||
public void setDiskStoreRef(String diskStoreRef) {
|
||||
this.diskStoreRef = diskStoreRef;
|
||||
}
|
||||
|
||||
public Integer getMaximumQueueMemory() {
|
||||
return maximumQueueMemory;
|
||||
}
|
||||
|
||||
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
|
||||
this.maximumQueueMemory = maximumQueueMemory;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating a GemFire {@link GatewayReceiver}.
|
||||
*
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewayReceiverFactoryBean extends AbstractWANComponentFactoryBean<GatewayReceiver> {
|
||||
private GatewayReceiver gatewayReceiver;
|
||||
|
||||
private List<GatewayTransportFilter> transportFilters;
|
||||
|
||||
private Integer startPort;
|
||||
|
||||
private Integer endPort;
|
||||
|
||||
private Integer maximumTimeBetweenPings;
|
||||
|
||||
private Integer socketBufferSize;
|
||||
|
||||
private String bindAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache
|
||||
*/
|
||||
public GatewayReceiverFactoryBean(Cache cache) {
|
||||
super(cache);
|
||||
// Bean name not required.
|
||||
this.name = "gateway-receiver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayReceiver getObject() throws Exception {
|
||||
return gatewayReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return GatewayReceiver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
|
||||
if (!CollectionUtils.isEmpty(transportFilters)) {
|
||||
for (GatewayTransportFilter transportFilter : transportFilters) {
|
||||
gatewayReceiverFactory.addGatewayTransportFilter(transportFilter);
|
||||
}
|
||||
}
|
||||
int minPort = (startPort == null) ? GatewayReceiver.DEFAULT_START_PORT : startPort;
|
||||
int maxPort = (endPort == null) ? GatewayReceiver.DEFAULT_END_PORT : endPort;
|
||||
Assert.isTrue(minPort <= maxPort, "startPort must be less then or equal to " + maxPort);
|
||||
gatewayReceiverFactory.setStartPort(minPort);
|
||||
gatewayReceiverFactory.setEndPort(maxPort);
|
||||
if (socketBufferSize != null) {
|
||||
gatewayReceiverFactory.setSocketBufferSize(socketBufferSize);
|
||||
}
|
||||
if (maximumTimeBetweenPings != null) {
|
||||
gatewayReceiverFactory.setMaximumTimeBetweenPings(maximumTimeBetweenPings);
|
||||
}
|
||||
if (bindAddress != null) {
|
||||
gatewayReceiverFactory.setBindAddress(bindAddress);
|
||||
}
|
||||
|
||||
gatewayReceiver = gatewayReceiverFactory.create();
|
||||
}
|
||||
|
||||
public void setGatewayReceiver(GatewayReceiver gatewayReceiver) {
|
||||
this.gatewayReceiver = gatewayReceiver;
|
||||
}
|
||||
|
||||
public void setTransportFilters(List<GatewayTransportFilter> transportFilters) {
|
||||
this.transportFilters = transportFilters;
|
||||
}
|
||||
|
||||
public void setStartPort(Integer startPort) {
|
||||
this.startPort = startPort;
|
||||
}
|
||||
|
||||
public void setEndPort(Integer endPort) {
|
||||
this.endPort = endPort;
|
||||
}
|
||||
|
||||
public void setMaximumTimeBetweenPings(Integer maximumTimeBetweenPings) {
|
||||
this.maximumTimeBetweenPings = maximumTimeBetweenPings;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
|
||||
public void setBindAddress(String bindAddress) {
|
||||
this.bindAddress = bindAddress;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.wan;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* FactoryBean for creating a GemFire {@link GatewaySender}.
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GatewaySenderFactoryBean extends AbstractWANComponentFactoryBean<GatewaySender> {
|
||||
private static List<String> validOrderPolicyValues = Arrays.asList("KEY", "PARTITION", "THREAD");
|
||||
|
||||
private GatewaySender gatewaySender;
|
||||
|
||||
private int remoteDistributedSystemId;
|
||||
|
||||
private List<GatewayEventFilter> eventFilters;
|
||||
|
||||
private List<GatewayTransportFilter> transportFilters;
|
||||
|
||||
private Integer alertThreshold;
|
||||
|
||||
private Boolean enableBatchConflation;
|
||||
|
||||
private Integer batchSize;
|
||||
|
||||
private Integer batchTimeInterval;
|
||||
|
||||
private String diskStoreRef;
|
||||
|
||||
private Boolean diskSynchronous;
|
||||
|
||||
private Integer dispatcherThreads;
|
||||
|
||||
private Boolean manualStart;
|
||||
|
||||
private Integer maximumQueueMemory;
|
||||
|
||||
private String orderPolicy;
|
||||
|
||||
private Boolean parallel;
|
||||
|
||||
private Boolean persistent;
|
||||
|
||||
private Integer socketBufferSize;
|
||||
|
||||
private Integer socketReadTimeout;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cache the Gemfire cache
|
||||
*/
|
||||
public GatewaySenderFactoryBean(Cache cache) {
|
||||
super(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewaySender getObject() throws Exception {
|
||||
return gatewaySender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return GatewaySender.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
|
||||
if (diskStoreRef != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
||||
gatewaySenderFactory.setDiskStoreName(diskStoreRef);
|
||||
}
|
||||
|
||||
if (diskSynchronous != null) {
|
||||
persistent = (persistent == null) ? Boolean.TRUE : persistent;
|
||||
Assert.isTrue(persistent, "specifying a disk synchronous requires persistent property to be true");
|
||||
gatewaySenderFactory.setDiskSynchronous(diskSynchronous);
|
||||
}
|
||||
|
||||
if (persistent != null) {
|
||||
gatewaySenderFactory.setPersistenceEnabled(persistent);
|
||||
}
|
||||
|
||||
parallel = (parallel == null) ? Boolean.FALSE : parallel;
|
||||
|
||||
gatewaySenderFactory.setParallel(parallel);
|
||||
|
||||
if (orderPolicy != null) {
|
||||
Assert.isTrue(parallel, "specifying an order policy requires the parallel property to be true");
|
||||
|
||||
Assert.isTrue(validOrderPolicyValues.contains(orderPolicy.toUpperCase()), "The value of order policy:'"
|
||||
+ orderPolicy + "' is invalid");
|
||||
gatewaySenderFactory.setOrderPolicy(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(eventFilters)) {
|
||||
for (GatewayEventFilter eventFilter : eventFilters) {
|
||||
gatewaySenderFactory.addGatewayEventFilter(eventFilter);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(transportFilters)) {
|
||||
for (GatewayTransportFilter transportFilter : transportFilters) {
|
||||
gatewaySenderFactory.addGatewayTransportFilter(transportFilter);
|
||||
}
|
||||
}
|
||||
if (alertThreshold != null) {
|
||||
gatewaySenderFactory.setAlertThreshold(alertThreshold);
|
||||
}
|
||||
if (enableBatchConflation != null) {
|
||||
gatewaySenderFactory.setBatchConflationEnabled(enableBatchConflation);
|
||||
}
|
||||
if (batchSize != null) {
|
||||
gatewaySenderFactory.setBatchSize(batchSize);
|
||||
}
|
||||
if (batchTimeInterval != null) {
|
||||
gatewaySenderFactory.setBatchTimeInterval(batchTimeInterval);
|
||||
}
|
||||
if (dispatcherThreads != null) {
|
||||
gatewaySenderFactory.setDispatcherThreads(dispatcherThreads);
|
||||
}
|
||||
if (manualStart != null) {
|
||||
gatewaySenderFactory.setManualStart(manualStart);
|
||||
}
|
||||
if (maximumQueueMemory != null) {
|
||||
gatewaySenderFactory.setMaximumQueueMemory(maximumQueueMemory);
|
||||
}
|
||||
if (socketBufferSize != null) {
|
||||
gatewaySenderFactory.setSocketBufferSize(socketBufferSize);
|
||||
}
|
||||
if (socketReadTimeout != null) {
|
||||
gatewaySenderFactory.setSocketReadTimeout(socketReadTimeout);
|
||||
}
|
||||
gatewaySender = gatewaySenderFactory.create(name, remoteDistributedSystemId);
|
||||
}
|
||||
|
||||
public void setGatewaySender(GatewaySender gatewaySender) {
|
||||
this.gatewaySender = gatewaySender;
|
||||
}
|
||||
|
||||
public void setRemoteDistributedSystemId(int remoteDistributedSystemId) {
|
||||
this.remoteDistributedSystemId = remoteDistributedSystemId;
|
||||
}
|
||||
|
||||
public void setEventFilters(List<GatewayEventFilter> gatewayEventFilters) {
|
||||
this.eventFilters = gatewayEventFilters;
|
||||
}
|
||||
|
||||
public void setTransportFilters(List<GatewayTransportFilter> gatewayTransportFilters) {
|
||||
this.transportFilters = gatewayTransportFilters;
|
||||
}
|
||||
|
||||
public void setAlertThreshold(Integer alertThreshold) {
|
||||
this.alertThreshold = alertThreshold;
|
||||
}
|
||||
|
||||
public void setEnableBatchConflation(Boolean enableBatchConflation) {
|
||||
this.enableBatchConflation = enableBatchConflation;
|
||||
}
|
||||
|
||||
public void setBatchSize(Integer batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public void setBatchTimeInterval(Integer batchTimeInterval) {
|
||||
this.batchTimeInterval = batchTimeInterval;
|
||||
}
|
||||
|
||||
public void setDiskStoreRef(String diskStoreRef) {
|
||||
this.diskStoreRef = diskStoreRef;
|
||||
}
|
||||
|
||||
public void setDiskSynchronous(Boolean diskSynchronous) {
|
||||
this.diskSynchronous = diskSynchronous;
|
||||
}
|
||||
|
||||
public void setDispatcherThreads(Integer dispatcherThreads) {
|
||||
this.dispatcherThreads = dispatcherThreads;
|
||||
}
|
||||
|
||||
public void setManualStart(Boolean manualStart) {
|
||||
this.manualStart = manualStart;
|
||||
}
|
||||
|
||||
public void setMaximumQueueMemory(Integer maximumQueueMemory) {
|
||||
this.maximumQueueMemory = maximumQueueMemory;
|
||||
}
|
||||
|
||||
public void setOrderPolicy(String orderPolicy) {
|
||||
this.orderPolicy = orderPolicy;
|
||||
}
|
||||
|
||||
public void setParallel(Boolean parallel) {
|
||||
this.parallel = parallel;
|
||||
}
|
||||
|
||||
public void setPersistent(Boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
|
||||
public void setSocketReadTimeout(Integer socketReadTimeout) {
|
||||
this.socketReadTimeout = socketReadTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
http\://www.springframework.org/schema/gemfire=org.springframework.data.gemfire.config.GemfireNamespaceHandler
|
||||
http\://www.springframework.org/schema/gemfire=org.springframework.data.gemfire.config.GemfireNamespaceHandler
|
||||
http\://www.springframework.org/schema/data/gemfire=org.springframework.data.gemfire.config.GemfireDataNamespaceHandler
|
||||
@@ -1,4 +1,6 @@
|
||||
http\://www.springframework.org/schema/gemfire/spring-gemfire-1.0.xsd=org/springframework/data/gemfire/config/spring-gemfire-1.0.xsd
|
||||
http\://www.springframework.org/schema/gemfire/spring-gemfire-1.1.xsd=org/springframework/data/gemfire/config/spring-gemfire-1.1.xsd
|
||||
http\://www.springframework.org/schema/gemfire/spring-gemfire-1.2.xsd=org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd
|
||||
http\://www.springframework.org/schema/gemfire/spring-gemfire.xsd=org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd
|
||||
http\://www.springframework.org/schema/gemfire/spring-gemfire.xsd=org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd
|
||||
http\://www.springframework.org/schema/data/gemfire/spring-data-gemfire-1.2.xsd=org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd
|
||||
http\://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd=org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd
|
||||
@@ -1,4 +1,8 @@
|
||||
# Tooling related information for the gemfire namespace
|
||||
http\://www.springframework.org/schema/gemfire@name=gemfire Namespace
|
||||
http\://www.springframework.org/schema/gemfire@prefix=gfe
|
||||
http\://www.springframework.org/schema/gemfire@icon=org/springframework/data/gemfire/config/spring-gemfire.gif
|
||||
http\://www.springframework.org/schema/gemfire@icon=org/springframework/data/gemfire/config/spring-gemfire.gif
|
||||
#
|
||||
http\://www.springframework.org/schema/data/gemfire@name=Spring data gemfire Namespace
|
||||
http\://www.springframework.org/schema/data/gemfire@prefix=gfe-data
|
||||
http\://www.springframework.org/schema/data/gemfire@icon=org/springframework/data/gemfire/config/spring-gemfire.gif
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- edited with XMLSpy v2011 rel. 2 sp1 (http://www.altova.com) by David
|
||||
Turanski (EMC) -->
|
||||
<xsd:schema xmlns="http://www.springframework.org/schema/data/gemfire" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:repository="http://www.springframework.org/schema/data/repository"
|
||||
targetNamespace="http://www.springframework.org/schema/data/gemfire" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.2">
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/data/repository" schemaLocation="http://www.springframework.org/schema/data/repository/spring-repository.xsd"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/gemfire" schemaLocation="http://www.springframework.org/schema/gemfire/spring-gemfire.xsd"/>
|
||||
<!-- -->
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Namespace support for the Spring Data GemFire Repositories.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<!-- -->
|
||||
<!-- Repositories -->
|
||||
<xsd:element name="repositories">
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="repository:repositories">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="repository" type="gemfire-repository" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attributeGroup ref="gemfire-repository-attributes"/>
|
||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<!-- -->
|
||||
<xsd:complexType name="gemfire-repository">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="repository:repository">
|
||||
<xsd:attributeGroup ref="gemfire-repository-attributes"/>
|
||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:attributeGroup name="gemfire-repository-attributes">
|
||||
<xsd:attribute name="gemfire-template-ref" type="gemfireTemplateRef" default="gemfireTemplate">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The reference to a GemfireTemplate.
|
||||
Will default to 'gemfireTemplate'.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attributeGroup>
|
||||
<!-- -->
|
||||
<xsd:simpleType name="gemfireTemplateRef">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:assignable-to type="org.springframework.data.gemfire.GemfireTemplate"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:union memberTypes="xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
<!-- -->
|
||||
</xsd:schema>
|
||||
3700
src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd
Normal file → Executable file
3700
src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,6 @@ public class CacheIntegrationTest extends RecreatingContextTest {
|
||||
|
||||
@Test
|
||||
public void testCacheWithXml() throws Exception {
|
||||
Cache cache = ctx.getBean("cache-with-xml", Cache.class);
|
||||
ctx.getBean("cache-with-xml", Cache.class);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import com.gemstone.gemfire.cache.query.SelectResults;
|
||||
public class GemfireTemplateTest extends RecreatingContextTest {
|
||||
|
||||
private static final String MULTI_QUERY = "select * from /simple";
|
||||
|
||||
private static final String SINGLE_QUERY = "(select * from /simple).size";
|
||||
|
||||
@Override
|
||||
@@ -38,28 +39,33 @@ public class GemfireTemplateTest extends RecreatingContextTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFind() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
SelectResults<Object> find = template.find(MULTI_QUERY);
|
||||
assertNotNull(find);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindUnique() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
Integer find = template.findUnique(SINGLE_QUERY);
|
||||
assertEquals(find, Integer.valueOf(0));
|
||||
public void testAll() throws Exception {
|
||||
testFind();
|
||||
testFindUnique();
|
||||
}
|
||||
|
||||
@Test(expected = InvalidDataAccessApiUsageException.class)
|
||||
public void testFindMultiException() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
SelectResults<Object> find = template.find(SINGLE_QUERY);
|
||||
template.find(SINGLE_QUERY);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidDataAccessApiUsageException.class)
|
||||
public void testFindMultiOne() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
SelectResults<Object> find = template.findUnique(MULTI_QUERY);
|
||||
template.findUnique(MULTI_QUERY);
|
||||
}
|
||||
|
||||
private void testFind() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
SelectResults<Object> find = template.find(MULTI_QUERY);
|
||||
assertNotNull(find);
|
||||
}
|
||||
|
||||
private void testFindUnique() throws Exception {
|
||||
GemfireTemplate template = ctx.getBean("template", GemfireTemplate.class);
|
||||
Integer find = template.findUnique(SINGLE_QUERY);
|
||||
assertEquals(find, Integer.valueOf(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SimpleCacheListener extends CacheListenerAdapter {
|
||||
|
||||
}
|
||||
|
||||
@@ -23,12 +23,15 @@ import com.gemstone.gemfire.cache.LoaderHelper;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SimpleCacheLoader implements CacheLoader {
|
||||
|
||||
@Override
|
||||
public Object load(LoaderHelper helper) throws CacheLoaderException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SimpleCacheWriter extends CacheWriterAdapter {
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SimpleObjectSizer implements ObjectSizer {
|
||||
|
||||
private static final ObjectSizer sizer = new ObjectSizerImpl();
|
||||
|
||||
@Override
|
||||
public int sizeof(Object o) {
|
||||
return sizer.sizeof(o);
|
||||
}
|
||||
|
||||
@@ -24,16 +24,20 @@ import com.gemstone.gemfire.cache.PartitionResolver;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SimplePartitionResolver implements PartitionResolver {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getRoutingObject(EntryOperation opDetails) {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,15 @@ public class SubRegionTest extends RecreatingContextTest {
|
||||
return "org/springframework/data/gemfire/basic-subregion.xml";
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasic();
|
||||
testContext();
|
||||
testChildOnly();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private void testBasic() throws Exception {
|
||||
CacheFactoryBean cfb = new CacheFactoryBean();
|
||||
cfb.setUseBeanFactoryLocator(false);
|
||||
cfb.afterPropertiesSet();
|
||||
@@ -57,13 +63,10 @@ public class SubRegionTest extends RecreatingContextTest {
|
||||
|
||||
assertNotNull(parent.getSubregion("child"));
|
||||
assertSame(child, parent.getSubregion("child"));
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testContext() throws Exception {
|
||||
private void testContext() throws Exception {
|
||||
Region parent = ctx.getBean("parent", Region.class);
|
||||
Region child = ctx.getBean("/parent/child", Region.class);
|
||||
assertNotNull(parent.getSubregion("child"));
|
||||
@@ -72,7 +75,6 @@ public class SubRegionTest extends RecreatingContextTest {
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testChildOnly() throws Exception {
|
||||
Region child = ctx.getBean("/parent/child", Region.class);
|
||||
assertEquals("/parent/child", child.getFullPath());
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import org.springframework.data.gemfire.WiringDeclarableSupport;
|
||||
|
||||
import com.gemstone.gemfire.cache.CacheLoader;
|
||||
import com.gemstone.gemfire.cache.CacheLoaderException;
|
||||
import com.gemstone.gemfire.cache.LoaderHelper;
|
||||
@@ -27,11 +25,13 @@ import com.gemstone.gemfire.cache.LoaderHelper;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class UserObject extends WiringDeclarableSupport implements CacheLoader {
|
||||
|
||||
public static UserObject THIS;
|
||||
|
||||
private String prop1;
|
||||
|
||||
private Object prop2;
|
||||
|
||||
public UserObject() {
|
||||
@@ -39,6 +39,7 @@ public class UserObject extends WiringDeclarableSupport implements CacheLoader {
|
||||
THIS = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object load(LoaderHelper helper) throws CacheLoaderException {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
|
||||
import com.gemstone.gemfire.cache.util.CacheWriterAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -53,10 +52,12 @@ public class RegionIntegrationTest {
|
||||
|
||||
private static class CacheLoad<K, V> implements CacheLoader<K, V> {
|
||||
|
||||
@Override
|
||||
public V load(LoaderHelper<K, V> arg0) throws CacheLoaderException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -68,20 +69,28 @@ public class RegionIntegrationTest {
|
||||
private ApplicationContext ctx;
|
||||
|
||||
@Test
|
||||
public void testBasicRegion() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicRegion();
|
||||
testExistingRegion();
|
||||
testRegionWithListeners();
|
||||
testRegionAttributes();
|
||||
}
|
||||
|
||||
private void testBasicRegion() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Region region = ctx.getBean("basic", Region.class);
|
||||
assertEquals("basic", region.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingRegion() throws Exception {
|
||||
private void testExistingRegion() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Region region = ctx.getBean("root", Region.class);
|
||||
// the name property seems to be ignored
|
||||
assertEquals("root", region.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionWithListeners() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testRegionWithListeners() throws Exception {
|
||||
Region region = ctx.getBean("listeners", Region.class);
|
||||
assertEquals("listeners", region.getName());
|
||||
CacheListener[] listeners = region.getAttributes().getCacheListeners();
|
||||
@@ -91,17 +100,20 @@ public class RegionIntegrationTest {
|
||||
assertSame(CacheWrite.class, region.getAttributes().getCacheWriter().getClass());
|
||||
}
|
||||
|
||||
//@Test
|
||||
// TODO: disabled since the interest registration requires a proper pool to be created, which requires another JVM to run with the server/locator
|
||||
// @Test
|
||||
// TODO: disabled since the interest registration requires a proper pool to
|
||||
// be created, which requires another JVM to run with the server/locator
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testRegionInterest() throws Exception {
|
||||
ClientRegionFactoryBean regionFB = (ClientRegionFactoryBean) ctx.getBean("&basic-client");
|
||||
System.out.println("**** interests are " + Arrays.toString(regionFB.getInterests()));
|
||||
BeanDefinition bd = ((BeanDefinitionRegistry) ctx.getAutowireCapableBeanFactory()).getBeanDefinition("basic-client");
|
||||
BeanDefinition bd = ((BeanDefinitionRegistry) ctx.getAutowireCapableBeanFactory())
|
||||
.getBeanDefinition("basic-client");
|
||||
System.out.println(bd.getPropertyValues().getPropertyValue("interests").getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionAttributes() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testRegionAttributes() throws Exception {
|
||||
Region region = ctx.getBean("attr-region", Region.class);
|
||||
assertEquals("attr-region", region.getName());
|
||||
RegionAttributes attr = region.getAttributes();
|
||||
|
||||
@@ -44,23 +44,30 @@ public class CacheNamespaceTest extends RecreatingContextTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicCache() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicCache();
|
||||
testNamedCache();
|
||||
testCacheWithXml();
|
||||
// testBasicClientCache();
|
||||
// testBasicClientCacheWithXml();
|
||||
testHeapTunedCache();
|
||||
}
|
||||
|
||||
private void testBasicCache() throws Exception {
|
||||
assertTrue(ctx.containsBean("gemfire-cache"));
|
||||
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfire-cache");
|
||||
assertNull(TestUtils.readField("cacheXml", cfb));
|
||||
assertNull(TestUtils.readField("properties", cfb));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamedCache() throws Exception {
|
||||
private void testNamedCache() throws Exception {
|
||||
assertTrue(ctx.containsBean("cache-with-name"));
|
||||
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&cache-with-name");
|
||||
assertNull(TestUtils.readField("cacheXml", cfb));
|
||||
assertNull(TestUtils.readField("properties", cfb));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheWithXml() throws Exception {
|
||||
private void testCacheWithXml() throws Exception {
|
||||
assertTrue(ctx.containsBean("cache-with-xml"));
|
||||
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&cache-with-xml");
|
||||
Resource res = TestUtils.readField("cacheXml", cfb);
|
||||
@@ -106,8 +113,7 @@ public class CacheNamespaceTest extends RecreatingContextTest {
|
||||
assertEquals("gemfire-client-cache.xml", res.getFilename());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeapTunedCache() throws Exception {
|
||||
private void testHeapTunedCache() throws Exception {
|
||||
assertTrue(ctx.containsBean("heap-tuned-cache"));
|
||||
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&heap-tuned-cache");
|
||||
Float chp = (Float) TestUtils.readField("criticalHeapPercentage", cfb);
|
||||
|
||||
@@ -56,23 +56,31 @@ public class ClientRegionNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicClient() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicClient();
|
||||
testBeanNames();
|
||||
testPublishingClient();
|
||||
testPersistent();
|
||||
testOverflowToDisk();
|
||||
}
|
||||
|
||||
private void testBasicClient() throws Exception {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanNames() throws Exception {
|
||||
private void testBeanNames() throws Exception {
|
||||
assertTrue(ObjectUtils.isEmpty(context.getAliases("publisher")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishingClient() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPublishingClient() throws Exception {
|
||||
assertTrue(context.containsBean("empty"));
|
||||
ClientRegionFactoryBean fb = context.getBean("&empty", ClientRegionFactoryBean.class);
|
||||
assertEquals(DataPolicy.EMPTY, TestUtils.readField("dataPolicy", fb));
|
||||
}
|
||||
|
||||
// @Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testComplexClient() throws Exception {
|
||||
assertTrue(context.containsBean("complex"));
|
||||
ClientRegionFactoryBean fb = context.getBean("&complex", ClientRegionFactoryBean.class);
|
||||
@@ -97,8 +105,8 @@ public class ClientRegionNamespaceTest {
|
||||
assertEquals(".*", TestUtils.readField("key", regexInt));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersistent() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPersistent() throws Exception {
|
||||
assertTrue(context.containsBean("persistent"));
|
||||
Region region = context.getBean("persistent", Region.class);
|
||||
RegionAttributes attrs = region.getAttributes();
|
||||
@@ -106,8 +114,8 @@ public class ClientRegionNamespaceTest {
|
||||
assertEquals(1, attrs.getDiskDirSizes()[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverflowToDisk() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testOverflowToDisk() throws Exception {
|
||||
assertTrue(context.containsBean("overflow"));
|
||||
ClientRegionFactoryBean fb = context.getBean("&overflow", ClientRegionFactoryBean.class);
|
||||
assertEquals(DataPolicy.NORMAL, TestUtils.readField("dataPolicy", fb));
|
||||
|
||||
@@ -83,7 +83,14 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDiskStore() {
|
||||
public void testAll() throws Exception {
|
||||
testDiskStore();
|
||||
testReplicaDataOptions();
|
||||
testPartitionDataOptions();
|
||||
testEntryTtl();
|
||||
}
|
||||
|
||||
private void testDiskStore() {
|
||||
assertEquals("diskStore1", diskStore1.getName());
|
||||
assertEquals(50, diskStore1.getQueueSize());
|
||||
assertEquals(true, diskStore1.getAutoCompact());
|
||||
@@ -95,12 +102,13 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertSame(diskStore1, cache.findDiskStore("diskStore1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicaDataOptions() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testReplicaDataOptions() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-data"));
|
||||
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
|
||||
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, TestUtils.readField("scope", fb));
|
||||
@SuppressWarnings("unused")
|
||||
Region region = context.getBean("replicated-data", Region.class);
|
||||
// eviction tests
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
@@ -111,8 +119,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertNull(evicAttr.getObjectSizer());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionDataOptions() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPartitionDataOptions() throws Exception {
|
||||
assertTrue(context.containsBean("partition-data"));
|
||||
RegionFactoryBean fb = context.getBean("&partition-data", RegionFactoryBean.class);
|
||||
assertTrue(fb instanceof PartitionedRegionFactoryBean);
|
||||
@@ -129,8 +137,8 @@ public class DiskStoreAndEvictionRegionParsingTest {
|
||||
assertEquals(SimpleObjectSizer.class, sizer.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntryTtl() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testEntryTtl() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-data"));
|
||||
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.RecreatingContextTest;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.wan.GatewayHubFactoryBean;
|
||||
import org.springframework.data.gemfire.wan.GatewayProxy;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEvent;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GemfireV6GatewayNamespaceTest extends RecreatingContextTest {
|
||||
@Override
|
||||
protected String location() {
|
||||
return "/org/springframework/data/gemfire/config/gateway-v6-ns.xml";
|
||||
}
|
||||
|
||||
/*
|
||||
* Faster this way
|
||||
*/
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
testGatewayHubFactoryBean();
|
||||
testGatewaysInGemfire();
|
||||
}
|
||||
|
||||
private void testGatewayHubFactoryBean() throws Exception {
|
||||
GatewayHubFactoryBean gwhfb = ctx.getBean("&gateway-hub", GatewayHubFactoryBean.class);
|
||||
List<GatewayProxy> gateways = TestUtils.readField("gateways", gwhfb);
|
||||
assertNotNull(gateways);
|
||||
assertEquals(2, gateways.size());
|
||||
GatewayProxy gwp = gateways.get(0);
|
||||
assertEquals("gateway", gwp.getId());
|
||||
assertTrue(gwp.getListeners().get(0) instanceof GatewayListener);
|
||||
|
||||
gwp = gateways.get(1);
|
||||
assertEquals("gateway2", gwp.getId());
|
||||
List<GatewayProxy.GatewayEndpoint> endpoints = gwp.getEndpoints();
|
||||
assertEquals(2, endpoints.size());
|
||||
GatewayProxy.GatewayEndpoint endpoint;
|
||||
|
||||
endpoint = endpoints.get(0);
|
||||
assertEquals("endpoint1", endpoint.getId());
|
||||
assertEquals("host1", endpoint.getHost());
|
||||
assertEquals(1234, endpoint.getPort());
|
||||
|
||||
endpoint = endpoints.get(1);
|
||||
assertEquals("endpoint2", endpoint.getId());
|
||||
assertEquals("host2", endpoint.getHost());
|
||||
assertEquals(2345, endpoint.getPort());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testGatewaysInGemfire() {
|
||||
Cache cache = ctx.getBean("gemfire-cache", Cache.class);
|
||||
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
|
||||
assertNotNull(gwh);
|
||||
|
||||
Region region = ctx.getBean("region-with-gateway", Region.class);
|
||||
assertTrue(region.getAttributes().getEnableGateway());
|
||||
assertEquals("gateway-hub", region.getAttributes().getGatewayHubId());
|
||||
}
|
||||
|
||||
public static class GatewayListener implements GatewayEventListener {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processEvents(List<GatewayEvent> event) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.RecreatingContextTest;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
|
||||
|
||||
import com.gemstone.gemfire.cache.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.AsyncEvent;
|
||||
import com.gemstone.gemfire.cache.wan.AsyncEventListener;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
* This test is only valid for GF 7.0 and above
|
||||
*
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest {
|
||||
@Override
|
||||
protected String location() {
|
||||
return "/org/springframework/data/gemfire/config/gateway-v7-ns.xml";
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void createCtx() {
|
||||
if (ParsingUtils.GEMFIRE_VERSION.startsWith("7")) {
|
||||
super.createCtx();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Faster this way
|
||||
*/
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
if (ctx != null) {
|
||||
testGatewaySender();
|
||||
testInnerGatewaySender();
|
||||
testInnerGatewayReceiver();
|
||||
testAsyncEventQueue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void testAsyncEventQueue() {
|
||||
AsyncEventQueue aseq = ctx.getBean("async-event-queue", AsyncEventQueue.class);
|
||||
assertEquals(10, aseq.getBatchSize());
|
||||
assertTrue(aseq.isPersistent());
|
||||
assertEquals("diskstore", aseq.getDiskStoreName());
|
||||
assertEquals(50, aseq.getMaximumQueueMemory());
|
||||
}
|
||||
|
||||
private void testGatewaySender() throws Exception {
|
||||
GatewaySenderFactoryBean gwsfb = ctx.getBean("&gateway-sender", GatewaySenderFactoryBean.class);
|
||||
Cache cache = TestUtils.readField("cache", gwsfb);
|
||||
assertNotNull(cache);
|
||||
List<GatewayEventFilter> eventFilters = TestUtils.readField("eventFilters", gwsfb);
|
||||
assertNotNull(eventFilters);
|
||||
assertEquals(2, eventFilters.size());
|
||||
assertTrue(eventFilters.get(0) instanceof TestEventFilter);
|
||||
|
||||
List<GatewayTransportFilter> transportFilters = TestUtils.readField("transportFilters", gwsfb);
|
||||
assertNotNull(transportFilters);
|
||||
assertEquals(2, transportFilters.size());
|
||||
assertTrue(transportFilters.get(0) instanceof TestTransportFilter);
|
||||
|
||||
assertEquals(2, TestUtils.readField("remoteDistributedSystemId", gwsfb));
|
||||
assertEquals(10, TestUtils.readField("alertThreshold", gwsfb));
|
||||
assertEquals(11, TestUtils.readField("batchSize", gwsfb));
|
||||
assertEquals(12, TestUtils.readField("dispatcherThreads", gwsfb));
|
||||
assertEquals(true, TestUtils.readField("manualStart", gwsfb));
|
||||
}
|
||||
|
||||
private void testInnerGatewaySender() {
|
||||
Region<?, ?> region = ctx.getBean("region-inner-gateway-sender", Region.class);
|
||||
GatewaySender gws = ctx.getBean("gateway-sender", GatewaySender.class);
|
||||
assertNotNull(region.getAttributes().getGatewaySenders());
|
||||
assertEquals(2, region.getAttributes().getGatewaySenders().size());
|
||||
|
||||
// Isolate the inner gateway
|
||||
Set<GatewaySender> gatewaySenders = region.getAttributes().getGatewaySenders();
|
||||
assertTrue(gatewaySenders.remove(gws));
|
||||
gatewaySenders.remove(gws);
|
||||
|
||||
gws = gatewaySenders.iterator().next();
|
||||
List<GatewayEventFilter> eventFilters = gws.getGatewayEventFilters();
|
||||
assertNotNull(eventFilters);
|
||||
assertEquals(1, eventFilters.size());
|
||||
assertTrue(eventFilters.get(0) instanceof TestEventFilter);
|
||||
|
||||
List<GatewayTransportFilter> transportFilters = gws.getGatewayTransportFilters();
|
||||
|
||||
assertNotNull(transportFilters);
|
||||
assertEquals(1, transportFilters.size());
|
||||
assertTrue(transportFilters.get(0) instanceof TestTransportFilter);
|
||||
|
||||
assertEquals(1, gws.getRemoteDSId());
|
||||
assertEquals(true, gws.isManualStart());
|
||||
assertEquals(10, gws.getAlertThreshold());
|
||||
assertEquals(11, gws.getBatchSize());
|
||||
assertEquals(3000, gws.getBatchTimeInterval());
|
||||
assertEquals(2, gws.getDispatcherThreads());
|
||||
assertEquals("diskstore", gws.getDiskStoreName());
|
||||
assertTrue(gws.isBatchConflationEnabled());
|
||||
assertEquals(50, gws.getMaximumQueueMemory());
|
||||
assertEquals(OrderPolicy.THREAD, gws.getOrderPolicy());
|
||||
assertTrue(gws.isPersistenceEnabled());
|
||||
assertTrue(gws.isParallel());
|
||||
assertEquals(16536, gws.getSocketBufferSize());
|
||||
assertEquals(3000, gws.getSocketReadTimeout());
|
||||
}
|
||||
|
||||
private void testInnerGatewayReceiver() {
|
||||
GatewayReceiver gwr = ctx.getBean("gateway-receiver", GatewayReceiver.class);
|
||||
assertEquals(12345, gwr.getStartPort());
|
||||
assertEquals(23456, gwr.getEndPort());
|
||||
assertEquals("192.168.0.1", gwr.getBindAddress());
|
||||
assertEquals(3000, gwr.getMaximumTimeBetweenPings());
|
||||
assertEquals(16536, gwr.getSocketBufferSize());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class TestEventFilter implements GatewayEventFilter {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAcknowledgement(AsyncEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeEnqueue(AsyncEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeTransmit(AsyncEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TestTransportFilter implements GatewayTransportFilter {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream(InputStream arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream(OutputStream arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class TestAsyncEventListener implements AsyncEventListener {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processEvents(List<AsyncEvent> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,11 +38,11 @@ import com.gemstone.gemfire.cache.query.IndexType;
|
||||
@ContextConfiguration("index-ns.xml")
|
||||
public class IndexNamespaceTest {
|
||||
|
||||
private String name = "test-index";
|
||||
private final String name = "test-index";
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Cache cache = (Cache) context.getBean("gemfire-cache");
|
||||
@@ -52,7 +52,12 @@ public class IndexNamespaceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicIndex() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicIndex();
|
||||
testComplexIndex();
|
||||
}
|
||||
|
||||
private void testBasicIndex() throws Exception {
|
||||
Index idx = (Index) context.getBean("simple");
|
||||
|
||||
assertEquals("/test-index", idx.getFromClause());
|
||||
@@ -62,8 +67,7 @@ public class IndexNamespaceTest {
|
||||
assertEquals(IndexType.FUNCTIONAL, idx.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexIndex() throws Exception {
|
||||
private void testComplexIndex() throws Exception {
|
||||
Index idx = (Index) context.getBean("complex");
|
||||
|
||||
assertEquals("/test-index tsi", idx.getFromClause());
|
||||
|
||||
@@ -49,12 +49,20 @@ public class LocalRegionNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicLocal() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicLocal();
|
||||
testComplexLocal();
|
||||
testLocalWithAttributes();
|
||||
testPublishingLocal();
|
||||
testRegionLookup();
|
||||
}
|
||||
|
||||
private void testBasicLocal() throws Exception {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishingLocal() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPublishingLocal() throws Exception {
|
||||
assertTrue(context.containsBean("pub"));
|
||||
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
|
||||
assertEquals("NORMAL", TestUtils.readField("dataPolicyName", fb));
|
||||
@@ -64,8 +72,8 @@ public class LocalRegionNamespaceTest {
|
||||
assertFalse(attrs.getPublisher());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexLocal() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testComplexLocal() throws Exception {
|
||||
assertTrue(context.containsBean("complex"));
|
||||
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
|
||||
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
|
||||
@@ -77,8 +85,8 @@ public class LocalRegionNamespaceTest {
|
||||
assertSame(context.getBean("c-writer"), TestUtils.readField("cacheWriter", fb));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalWithAttributes() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testLocalWithAttributes() throws Exception {
|
||||
assertTrue(context.containsBean("local-with-attributes"));
|
||||
Region region = context.getBean("local-with-attributes", Region.class);
|
||||
RegionAttributes attrs = region.getAttributes();
|
||||
@@ -90,8 +98,8 @@ public class LocalRegionNamespaceTest {
|
||||
assertEquals(true, attrs.isDiskSynchronous());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionLookup() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testRegionLookup() throws Exception {
|
||||
Cache cache = context.getBean(Cache.class);
|
||||
Region existing = cache.createRegionFactory().create("existing");
|
||||
assertTrue(context.containsBean("lookup"));
|
||||
|
||||
@@ -48,12 +48,18 @@ public class PartitionedRegionNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicPartition() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicPartition();
|
||||
testComplexPartition();
|
||||
testPartitionOptions();
|
||||
}
|
||||
|
||||
private void testBasicPartition() throws Exception {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionOptions() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPartitionOptions() throws Exception {
|
||||
assertTrue(context.containsBean("options"));
|
||||
RegionFactoryBean fb = context.getBean("&options", RegionFactoryBean.class);
|
||||
assertTrue(fb instanceof PartitionedRegionFactoryBean);
|
||||
@@ -70,8 +76,8 @@ public class PartitionedRegionNamespaceTest {
|
||||
assertSame(SimplePartitionResolver.class, pAttr.getPartitionResolver().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexPartition() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testComplexPartition() throws Exception {
|
||||
assertTrue(context.containsBean("complex"));
|
||||
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
|
||||
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
|
||||
|
||||
@@ -46,7 +46,12 @@ public class PoolNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicClient() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicClient();
|
||||
testComplexPool();
|
||||
}
|
||||
|
||||
private void testBasicClient() throws Exception {
|
||||
assertTrue(context.containsBean("gemfire-pool"));
|
||||
assertEquals(context.getBean("gemfire-pool"), PoolManager.find("gemfire-pool"));
|
||||
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfire-pool");
|
||||
@@ -57,8 +62,7 @@ public class PoolNamespaceTest {
|
||||
assertEquals(40403, locator.getPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexPool() throws Exception {
|
||||
private void testComplexPool() throws Exception {
|
||||
assertTrue(context.containsBean("complex"));
|
||||
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&complex");
|
||||
assertEquals(30, TestUtils.readField("retryAttempts", pfb));
|
||||
|
||||
@@ -50,12 +50,20 @@ public class ReplicatedRegionNamespaceTest {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicReplica() throws Exception {
|
||||
public void testAll() throws Exception {
|
||||
testBasicReplica();
|
||||
testPublishingReplica();
|
||||
testComplexReplica();
|
||||
testRegionLookup();
|
||||
testReplicaWithAttributes();
|
||||
}
|
||||
|
||||
private void testBasicReplica() throws Exception {
|
||||
assertTrue(context.containsBean("simple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishingReplica() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testPublishingReplica() throws Exception {
|
||||
assertTrue(context.containsBean("pub"));
|
||||
RegionFactoryBean fb = context.getBean("&pub", RegionFactoryBean.class);
|
||||
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
|
||||
@@ -65,8 +73,8 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertFalse(attrs.getPublisher());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexReplica() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testComplexReplica() throws Exception {
|
||||
assertTrue(context.containsBean("complex"));
|
||||
RegionFactoryBean fb = context.getBean("&complex", RegionFactoryBean.class);
|
||||
CacheListener[] listeners = TestUtils.readField("cacheListeners", fb);
|
||||
@@ -78,8 +86,8 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertSame(context.getBean("c-writer"), TestUtils.readField("cacheWriter", fb));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicaWithAttributes() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testReplicaWithAttributes() throws Exception {
|
||||
assertTrue(context.containsBean("replicated-with-attributes"));
|
||||
Region region = context.getBean("replicated-with-attributes", Region.class);
|
||||
RegionAttributes attrs = region.getAttributes();
|
||||
@@ -99,8 +107,8 @@ public class ReplicatedRegionNamespaceTest {
|
||||
assertEquals(true, attrs.getMulticastEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionLookup() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testRegionLookup() throws Exception {
|
||||
Cache cache = context.getBean(Cache.class);
|
||||
Region existing = cache.createRegionFactory().create("existing");
|
||||
assertTrue(context.containsBean("lookup"));
|
||||
|
||||
@@ -45,68 +45,71 @@ public class SubRegionNamespaceTest {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testNestedReplicatedRegions() {
|
||||
Region parent = context.getBean("parent",Region.class);
|
||||
public void testAll() throws Exception {
|
||||
testComplexNestedRegions();
|
||||
testMixedNestedRegions();
|
||||
testNestedRegionsWithSiblings();
|
||||
testNestedReplicatedRegions();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void testNestedReplicatedRegions() {
|
||||
Region parent = context.getBean("parent", Region.class);
|
||||
Region child = context.getBean("/parent/child", Region.class);
|
||||
Region grandchild = context.getBean("/parent/child/grandchild", Region.class);
|
||||
assertNotNull(child);
|
||||
assertEquals("/parent/child",child.getFullPath());
|
||||
assertSame(child,parent.getSubregion("child"));
|
||||
|
||||
assertEquals("/parent/child/grandchild",grandchild.getFullPath());
|
||||
assertSame(grandchild,child.getSubregion("grandchild"));
|
||||
|
||||
assertEquals("/parent/child", child.getFullPath());
|
||||
assertSame(child, parent.getSubregion("child"));
|
||||
|
||||
assertEquals("/parent/child/grandchild", grandchild.getFullPath());
|
||||
assertSame(grandchild, child.getSubregion("grandchild"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testMixedNestedRegions() {
|
||||
private void testMixedNestedRegions() {
|
||||
Cache cache = context.getBean(Cache.class);
|
||||
|
||||
Region parent = context.getBean("replicatedParent",Region.class);
|
||||
parent.createSubregion("lookupChild",new AttributesFactory().create());
|
||||
|
||||
|
||||
Region parent = context.getBean("replicatedParent", Region.class);
|
||||
parent.createSubregion("lookupChild", new AttributesFactory().create());
|
||||
|
||||
Region child = context.getBean("/replicatedParent/lookupChild", Region.class);
|
||||
Region grandchild = context.getBean("/replicatedParent/lookupChild/partitionedGrandchild", Region.class);
|
||||
assertNotNull(child);
|
||||
assertEquals("/replicatedParent/lookupChild",child.getFullPath());
|
||||
assertSame(child,parent.getSubregion("lookupChild"));
|
||||
|
||||
assertEquals("/replicatedParent/lookupChild/partitionedGrandchild",grandchild.getFullPath());
|
||||
assertSame(grandchild,child.getSubregion("partitionedGrandchild"));
|
||||
|
||||
assertEquals("/replicatedParent/lookupChild", child.getFullPath());
|
||||
assertSame(child, parent.getSubregion("lookupChild"));
|
||||
|
||||
assertEquals("/replicatedParent/lookupChild/partitionedGrandchild", grandchild.getFullPath());
|
||||
assertSame(grandchild, child.getSubregion("partitionedGrandchild"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testNestedRegionsWithSiblings() {
|
||||
Region parent = context.getBean("parentWithSiblings",Region.class);
|
||||
Region child1 = context.getBean("/parentWithSiblings/child1",Region.class);
|
||||
assertEquals("/parentWithSiblings/child1",child1.getFullPath());
|
||||
Region child2 = context.getBean("/parentWithSiblings/child2",Region.class);
|
||||
assertEquals("/parentWithSiblings/child2",child2.getFullPath());
|
||||
assertSame(child1,parent.getSubregion("child1"));
|
||||
assertSame(child2,parent.getSubregion("child2"));
|
||||
|
||||
Region grandchild1 = context.getBean("/parentWithSiblings/child1/grandChild11",Region.class);
|
||||
assertEquals("/parentWithSiblings/child1/grandChild11",grandchild1.getFullPath());
|
||||
private void testNestedRegionsWithSiblings() {
|
||||
Region parent = context.getBean("parentWithSiblings", Region.class);
|
||||
Region child1 = context.getBean("/parentWithSiblings/child1", Region.class);
|
||||
assertEquals("/parentWithSiblings/child1", child1.getFullPath());
|
||||
Region child2 = context.getBean("/parentWithSiblings/child2", Region.class);
|
||||
assertEquals("/parentWithSiblings/child2", child2.getFullPath());
|
||||
assertSame(child1, parent.getSubregion("child1"));
|
||||
assertSame(child2, parent.getSubregion("child2"));
|
||||
|
||||
Region grandchild1 = context.getBean("/parentWithSiblings/child1/grandChild11", Region.class);
|
||||
assertEquals("/parentWithSiblings/child1/grandChild11", grandchild1.getFullPath());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
@Test
|
||||
public void testComplexNestedRegions() throws Exception {
|
||||
Region parent = context.getBean("complexNested",Region.class);
|
||||
Region child1 = context.getBean("/complexNested/child1",Region.class);
|
||||
Region child2 = context.getBean("/complexNested/child2",Region.class);
|
||||
Region grandchild1 = context.getBean("/complexNested/child1/grandChild11",Region.class);
|
||||
|
||||
SubRegionFactoryBean grandchild1fb = context.getBean("&/complexNested/child1/grandChild11",SubRegionFactoryBean.class);
|
||||
private void testComplexNestedRegions() throws Exception {
|
||||
Region parent = context.getBean("complexNested", Region.class);
|
||||
Region child1 = context.getBean("/complexNested/child1", Region.class);
|
||||
Region child2 = context.getBean("/complexNested/child2", Region.class);
|
||||
Region grandchild1 = context.getBean("/complexNested/child1/grandChild11", Region.class);
|
||||
|
||||
SubRegionFactoryBean grandchild1fb = context.getBean("&/complexNested/child1/grandChild11",
|
||||
SubRegionFactoryBean.class);
|
||||
assertNotNull(grandchild1fb);
|
||||
RegionAttributes attr = grandchild1fb.create();
|
||||
RegionAttributes attr = grandchild1fb.create();
|
||||
assertNotNull(attr);
|
||||
CacheLoader cl = attr.getCacheLoader();
|
||||
assertNotNull(cl);
|
||||
|
||||
@@ -52,6 +52,7 @@ public class TxEventHandlersTest {
|
||||
@Resource(name = "gemfire-cache")
|
||||
Cache cache;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Resource(name = "local")
|
||||
Region local;
|
||||
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -28,7 +30,6 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.expression.TypedValue;
|
||||
|
||||
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Arrays;
|
||||
import com.gemstone.gemfire.pdx.PdxReader;
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,6 @@ public class PdxReaderPropertyAccessorUnitTests {
|
||||
PdxReader reader;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void appliesToPdxReadersOnly() {
|
||||
List<Class<?>> classes = Arrays.asList(PdxReaderPropertyAccessor.INSTANCE.getSpecificTargetClasses());
|
||||
assertThat(classes, hasItem(PdxReader.class));
|
||||
|
||||
@@ -15,12 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.gemfire.mapping.Region;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Region("address")
|
||||
public class Address {
|
||||
|
||||
@Id
|
||||
public String zipCode;
|
||||
|
||||
public String city;
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.mapping.Regions;
|
||||
import org.springframework.data.gemfire.repository.sample.PersonRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Collections;
|
||||
|
||||
/**
|
||||
* Integration test for {@link GemfireRepositoryFactory}.
|
||||
*
|
||||
@@ -41,7 +41,7 @@ public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRep
|
||||
@SuppressWarnings("unchecked")
|
||||
public void throwsExceptionIfReferencedRegionIsNotConfigured() {
|
||||
|
||||
GemfireRepositoryFactory factory = new GemfireRepositoryFactory(Collections.emptySet(), null);
|
||||
GemfireRepositoryFactory factory = new GemfireRepositoryFactory((Iterable) Collections.emptySet(), null);
|
||||
factory.getRepository(PersonRepository.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<gfe:cache/>
|
||||
<gfe:replicated-region id="region-with-gateway" enable-gateway="true" hub-id="gateway-hub"/>
|
||||
<gfe:gateway-hub id="gateway-hub" manual-start="true">
|
||||
<gfe:gateway gateway-id="gateway">
|
||||
<gfe:gateway-listener>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV6GatewayNamespaceTest.GatewayListener"/>
|
||||
</gfe:gateway-listener>
|
||||
<gfe:gateway-queue maximum-queue-memory="5" batch-size="3"
|
||||
batch-time-interval="10" />
|
||||
</gfe:gateway>
|
||||
<gfe:gateway gateway-id="gateway2">
|
||||
<gfe:gateway-endpoint port="1234" host="host1" endpoint-id="endpoint1"/>
|
||||
<gfe:gateway-endpoint port="2345" host="host2" endpoint-id="endpoint2"/>
|
||||
</gfe:gateway>
|
||||
</gfe:gateway-hub>
|
||||
</beans>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<gfe:cache />
|
||||
|
||||
<!-- need manual-start=true for the unit test because GF will throw an exception if no locators are configured -->
|
||||
<gfe:local-region id="region-inner-gateway-sender" >
|
||||
<gfe:gateway-sender
|
||||
remote-distributed-system-id="1"
|
||||
manual-start="true"
|
||||
alert-threshold="10"
|
||||
batch-size="11"
|
||||
batch-time-interval="3000"
|
||||
dispatcher-threads="2"
|
||||
disk-store-ref="diskstore"
|
||||
enable-batch-conflation="true"
|
||||
maximum-queue-memory="50"
|
||||
order-policy="THREAD"
|
||||
persistent="true"
|
||||
parallel="true"
|
||||
socket-buffer-size="16536"
|
||||
socket-read-timeout="3000">
|
||||
<gfe:event-filter>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestEventFilter"/>
|
||||
</gfe:event-filter>
|
||||
<gfe:transport-filter>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestTransportFilter"/>
|
||||
</gfe:transport-filter>
|
||||
</gfe:gateway-sender>
|
||||
<gfe:gateway-sender-ref bean="gateway-sender"/>
|
||||
</gfe:local-region>
|
||||
|
||||
<gfe:async-event-queue id="async-event-queue" batch-size="10" persistent="true" disk-store-ref="diskstore"
|
||||
maximum-queue-memory="50">
|
||||
<gfe:async-event-listener>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestAsyncEventListener"/>
|
||||
</gfe:async-event-listener>
|
||||
</gfe:async-event-queue>
|
||||
|
||||
<gfe:disk-store id="diskstore"/>
|
||||
|
||||
<gfe:gateway-receiver id="gateway-receiver"
|
||||
start-port="12345" end-port="23456" bind-address="192.168.0.1" maximum-time-between-pings="3000" socket-buffer-size="16536">
|
||||
<gfe:transport-filter>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestTransportFilter"/>
|
||||
</gfe:transport-filter>
|
||||
</gfe:gateway-receiver>
|
||||
|
||||
<!-- need manual-start=true for the unit test because GF will throw an exception if no locators are configured -->
|
||||
<gfe:gateway-sender id="gateway-sender"
|
||||
remote-distributed-system-id="2"
|
||||
alert-threshold="10"
|
||||
batch-size="11"
|
||||
dispatcher-threads="12"
|
||||
manual-start="true">
|
||||
<gfe:event-filter>
|
||||
<ref bean="event-filter"/>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestEventFilter"/>
|
||||
</gfe:event-filter>
|
||||
<gfe:transport-filter>
|
||||
<ref bean="transport-filter"/>
|
||||
<bean class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestTransportFilter"/>
|
||||
</gfe:transport-filter>
|
||||
</gfe:gateway-sender>
|
||||
|
||||
<bean id="event-filter" class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestEventFilter"/>
|
||||
<bean id="transport-filter" class="org.springframework.data.gemfire.config.GemfireV7GatewayNamespaceTest.TestTransportFilter"/>
|
||||
|
||||
</beans>
|
||||
@@ -15,8 +15,8 @@
|
||||
<gfe:local-region id="pub" name="publisher"/>
|
||||
|
||||
<gfe:local-region id="complex" close="true" destroy="false">
|
||||
<gfe:cache-listener>
|
||||
<ref bean="c-listener"/>
|
||||
<gfe:cache-listener>
|
||||
<ref bean="c-listener"/>
|
||||
<bean class="org.springframework.data.gemfire.SimpleCacheListener"/>
|
||||
</gfe:cache-listener>
|
||||
<gfe:cache-loader ref="c-loader"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<gfe:replicated-region id="complex" close="true" destroy="false">
|
||||
<gfe:cache-listener>
|
||||
<ref bean="c-listener"/>
|
||||
<ref bean="c-listener"/>
|
||||
<bean class="org.springframework.data.gemfire.SimpleCacheListener"/>
|
||||
</gfe:cache-listener>
|
||||
<gfe:cache-loader ref="c-loader"/>
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
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">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
|
||||
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/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd">
|
||||
|
||||
<gfe:repositories base-package="org.springframework.data.gemfire.repository.sample" />
|
||||
<gfe-data:repositories base-package="org.springframework.data.gemfire.repository.sample"/>
|
||||
|
||||
<gfe:cache use-bean-factory-locator="false" />
|
||||
<gfe:replicated-region id="simple" />
|
||||
|
||||
<gfe:replicated-region id="person"/>
|
||||
<gfe:replicated-region id="address"/>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user