Updating docs in progress and changed default bean names to camelCase

This commit is contained in:
David Turanski
2012-08-05 14:07:28 -04:00
parent a067ddbf48
commit 5bf6e2f15a
54 changed files with 763 additions and 311 deletions

View File

@@ -47,8 +47,6 @@ import com.gemstone.gemfire.cache.DynamicRegionFactory;
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.TransactionListener;
import com.gemstone.gemfire.cache.TransactionWriter;
import com.gemstone.gemfire.cache.execute.Function;
import com.gemstone.gemfire.cache.execute.FunctionService;
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.DistributedSystem;
@@ -265,8 +263,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
protected List<JndiDataSource> jndiDataSources;
protected List<Function> functions;
// Defined this way for backward compatibility
protected Object gatewayConflictResolver;
@@ -336,24 +332,12 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
registerTransactionListeners();
registerTransactionWriter();
registerJndiDataSources();
registerFunctions();
}
finally {
th.setContextClassLoader(oldTCCL);
}
}
/**
*
*/
private void registerFunctions() {
if (!CollectionUtils.isEmpty(functions)) {
for (Function function : functions) {
FunctionService.registerFunction(function);
}
}
}
private void registerJndiDataSources() {
if (jndiDataSources != null) {
for (JndiDataSource jndiDataSource : jndiDataSources) {
@@ -593,59 +577,99 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
return beanFactory;
}
/**
*
* @param copyOnRead
*/
public void setCopyOnRead(boolean copyOnRead) {
this.copyOnRead = copyOnRead;
}
/**
*
* @param lockTimeout
*/
public void setLockTimeout(int lockTimeout) {
this.lockTimeout = lockTimeout;
}
/**
*
* @param lockLease
*/
public void setLockLease(int lockLease) {
this.lockLease = lockLease;
}
/**
*
* @param messageSyncInterval
*/
public void setMessageSyncInterval(int messageSyncInterval) {
this.messageSyncInterval = messageSyncInterval;
}
/**
*
* @param searchTimeout
*/
public void setSearchTimeout(int searchTimeout) {
this.searchTimeout = searchTimeout;
}
/**
*
* @param evictionHeapPercentage
*/
public void setEvictionHeapPercentage(Float evictionHeapPercentage) {
this.evictionHeapPercentage = evictionHeapPercentage;
}
/**
*
* @param criticalHeapPercentage
*/
public void setCriticalHeapPercentage(Float criticalHeapPercentage) {
this.criticalHeapPercentage = criticalHeapPercentage;
}
/**
*
* @param transactionListeners
*/
public void setTransactionListeners(List<TransactionListener> transactionListeners) {
this.transactionListeners = transactionListeners;
}
/**
*
* @param transactionWriter
*/
public void setTransactionWriter(TransactionWriter transactionWriter) {
this.transactionWriter = transactionWriter;
}
public void setFunctions(List<Function> functions) {
this.functions = functions;
}
/**
*
* @param gatewayConflictResolver defined as Object for backward
* compatibility with Gemfire 6 compatibility
* Requires GemFire 7.0 or higher
* @param gatewayConflictResolver defined as Object in the signature for backward
* compatibility with Gemfire 6 compatibility. This must be an instance of
* {@link com.gemstone.gemfire.cache.util.GatewayConflictResolver}
*/
public void setGatewayConflictResolver(Object gatewayConflictResolver) {
this.gatewayConflictResolver = gatewayConflictResolver;
}
/**
*
* @param dynamicRegionSupport
*/
public void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) {
this.dynamicRegionSupport = dynamicRegionSupport;
}
/**
*
* @param jndiDataSources
*/
public void setJndiDataSources(List<JndiDataSource> jndiDataSources) {
this.jndiDataSources = jndiDataSources;
}

View File

@@ -56,10 +56,12 @@ public class DiskStoreFactoryBean implements FactoryBean<DiskStore>, Initializin
private String name;
private List<DiskDir> diskDirs;
private DiskStore diskStore;
@Override
public DiskStore getObject() throws Exception {
return diskStoreFactory.create(name == null ? DiskStoreFactory.DEFAULT_DISK_STORE_NAME : name);
return diskStore;
}
@Override
@@ -109,6 +111,8 @@ public class DiskStoreFactoryBean implements FactoryBean<DiskStore>, Initializin
}
diskStoreFactory.setDiskDirsAndSizes(diskDirFiles, diskDirSizes);
}
diskStore = diskStoreFactory.create(name == null ? DiskStoreFactory.DEFAULT_DISK_STORE_NAME : name);
}
public void setCache(GemFireCache cache) {

View File

@@ -97,7 +97,7 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
if (!subRegion) {
String cacheRef = element.getAttribute("cache-ref");
// add cache reference (fallback to default if nothing is specified)
builder.addPropertyReference("cache", (StringUtils.hasText(cacheRef) ? cacheRef : "gemfire-cache"));
builder.addPropertyReference("cache", (StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
}
// add attributes
ParsingUtils.setPropertyValue(element, builder, "name");

View File

@@ -41,7 +41,7 @@ public class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
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
String cacheName = StringUtils.isEmpty(element.getAttribute("cache-ref")) ? "gemfireCache" : element
.getAttribute("cache-ref");
builder.addConstructorArgReference(cacheName);
builder.addConstructorArgValue(asyncEventListener);

View File

@@ -19,8 +19,10 @@ package org.springframework.data.gemfire.config;
import java.util.List;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
@@ -180,7 +182,9 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser {
throws BeanDefinitionStoreException {
String name = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(name)) {
name = "gemfire-cache";
name = "gemfireCache";
//For backward compatibility
parserContext.getRegistry().registerAlias("gemfireCache", "gemfire-cache");
}
return name;
}

View File

@@ -44,7 +44,7 @@ class CacheServerParser extends AbstractSimpleBeanDefinitionParser {
throws BeanDefinitionStoreException {
String name = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(name)) {
name = "gemfire-server";
name = "gemfireServer";
}
return name;
}
@@ -60,7 +60,7 @@ class CacheServerParser extends AbstractSimpleBeanDefinitionParser {
String attr = element.getAttribute("cache-ref");
// add cache reference (fallback to default if nothing is specified)
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfire-cache"));
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfireCache"));
attr = element.getAttribute("groups");
if (StringUtils.hasText(attr)) {

View File

@@ -73,7 +73,7 @@ class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
attr = element.getAttribute("cache-ref");
// add cache reference (fallback to default if nothing is specified)
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfire-cache"));
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfireCache"));
// eviction + overflow attributes
// client attributes

View File

@@ -42,6 +42,7 @@ public class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, parserContext, builder);
builder.setLazyInit(false);
ParsingUtils.setPropertyReference(element, builder, "cache-ref", "cache");
ParsingUtils.setPropertyValue(element, builder, "auto-compact");
ParsingUtils.setPropertyValue(element, builder, "allow-force-compaction");

View File

@@ -53,7 +53,7 @@ class FunctionServiceParser extends AbstractSimpleBeanDefinitionParser {
throws BeanDefinitionStoreException {
String name = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(name)) {
name = "gemfire-function-service";
name = "gemfireFunctionService";
}
return name;
}

View File

@@ -44,7 +44,7 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
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"));
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
ParsingUtils.setPropertyValue(element, builder, "bind-address");
ParsingUtils.setPropertyValue(element, builder, "manual-start");
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");

View File

@@ -37,7 +37,7 @@ class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser {
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"));
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
ParsingUtils.setPropertyValue(element, builder, "start-port");
ParsingUtils.setPropertyValue(element, builder, "end-port");
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");

View File

@@ -39,7 +39,7 @@ class GatewaySenderParser extends AbstractSimpleBeanDefinitionParser {
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"));
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef : "gemfireCache"));
ParsingUtils.setPropertyValue(element, builder, "alert-threshold");
ParsingUtils.setPropertyValue(element, builder, "batch-size");
ParsingUtils.setPropertyValue(element, builder, "batch-time-interval");

View File

@@ -43,7 +43,7 @@ class LookupRegionParser extends AbstractRegionParser {
if (!subRegion) {
String attr = element.getAttribute("cache-ref");
// add cache reference (fallback to default if nothing is specified)
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfire-cache"));
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfireCache"));
}
else {
builder.addPropertyValue("lookupOnly", true);

View File

@@ -88,7 +88,9 @@ class PoolParser extends AbstractSimpleBeanDefinitionParser {
throws BeanDefinitionStoreException {
String name = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(name)) {
name = "gemfire-pool";
name = "gemfirePool";
//For backward compatibility
parserContext.getRegistry().registerAlias("gemfirePool", "gemfire-pool");
}
return name;
}

View File

@@ -45,7 +45,7 @@ class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {
String attr = element.getAttribute("cache-ref");
// add cache reference (fallback to default if nothing is specified)
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfire-cache"));
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : "gemfireCache"));
}
@@ -54,7 +54,9 @@ class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {
throws BeanDefinitionStoreException {
String name = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(name)) {
name = "gemfire-transaction-manager";
name = "gemfireTransactionManager";
//For backward compatibility
parserContext.getRegistry().registerAlias("gemfireTransactionManager", "gemfire-transaction-manager");
}
return name;
}

View File

@@ -24,6 +24,7 @@ import com.gemstone.gemfire.pdx.PdxReader;
* {@link PropertyValueProvider} to read property values from a {@link PdxReader}.
*
* @author Oliver Gierke
* @author David Turanski
*/
class GemfirePropertyValueProvider implements PropertyValueProvider<GemfirePersistentProperty> {
@@ -46,6 +47,6 @@ class GemfirePropertyValueProvider implements PropertyValueProvider<GemfirePersi
@Override
@SuppressWarnings("unchecked")
public <T> T getPropertyValue(GemfirePersistentProperty property) {
return (T) reader.readObject(property.getName());
return (T) reader.readField(property.getName());
}
}

View File

@@ -42,6 +42,7 @@ import com.gemstone.gemfire.pdx.PdxWriter;
* {@link GemfireMappingContext} to read and write entities.
*
* @author Oliver Gierke
* @author David Turanski
*/
public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAware {
@@ -50,6 +51,8 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
private final ConversionService conversionService;
private EntityInstantiators instantiators;
private Map<Class<?>,PdxSerializer> customSerializers;
private SpELContext context;
@@ -90,6 +93,14 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
this.instantiators = new EntityInstantiators(gemfireInstantiators);
}
/**
* Configures custom pdx serializers to use for specific types
* @param customSerializers
*/
public void setCustomSerializers(Map<Class<?>, PdxSerializer> customSerializers) {
this.customSerializers = customSerializers;
}
/*
* (non-Javadoc)
*
@@ -110,7 +121,8 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
*/
@Override
public Object fromData(Class<?> type, final PdxReader reader) {
// TODO: check for custom serializer (PDX)
final GemfirePersistentEntity<?> entity = mappingContext.getPersistentEntity(type);
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
GemfirePropertyValueProvider propertyValueProvider = new GemfirePropertyValueProvider(reader);
@@ -131,7 +143,7 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
if (entity.isConstructorArgument(persistentProperty)) {
return;
}
// TODO: check for custom serializer (Spring Converter - primitives)
Object value = reader.readField(persistentProperty.getName());
try {
@@ -154,17 +166,18 @@ public class MappingPdxSerializer implements PdxSerializer, ApplicationContextAw
*/
@Override
public boolean toData(Object value, final PdxWriter writer) {
// TODO: check for custom serializer (PDX)
GemfirePersistentEntity<?> entity = mappingContext.getPersistentEntity(value.getClass());
final BeanWrapper<PersistentEntity<Object, ?>, Object> wrapper = BeanWrapper.create(value, conversionService);
entity.doWithProperties(new PropertyHandler<GemfirePersistentProperty>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void doWithPersistentProperty(GemfirePersistentProperty persistentProperty) {
// TODO: check for custom serializer (Spring Converter)
try {
Object value = wrapper.getProperty(persistentProperty);
writer.writeObject(persistentProperty.getName(), value);
Object propertyValue = wrapper.getProperty(persistentProperty);
writer.writeField(persistentProperty.getName(), propertyValue, (Class) persistentProperty.getType());
}
catch (Exception e) {
throw new MappingException("Could not write value for property " + persistentProperty.toString(), e);

View File

@@ -25,6 +25,8 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.gemstone.gemfire.cache.query.internal.ResultsBag;
/**
* {@link GemfireRepositoryQuery} using plain {@link String} based OQL queries.
*
@@ -81,8 +83,7 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
while (indexes.hasNext()) {
query = query.bindIn(toCollection(accessor.getBindableValue(indexes.next() - 1)));
}
return template.find(query.toString(), parameters);
return toCollection(template.find(query.toString(), parameters));
}
/**
@@ -93,10 +94,15 @@ public class StringBasedGemfireRepositoryQuery extends GemfireRepositoryQuery {
* @return
*/
private Collection<?> toCollection(Object source) {
if (source instanceof ResultsBag) {
ResultsBag bag = (ResultsBag)source;
return bag.asList();
}
if (source instanceof Collection) {
return (Collection<?>) source;
}
return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source);
}

View File

@@ -30,7 +30,7 @@ import com.gemstone.gemfire.cache.Region;
*/
public class GemfireCache implements Cache {
@SuppressWarnings("unchecked")
@SuppressWarnings({ "rawtypes" })
private final Region region;
/**
@@ -58,7 +58,6 @@ public class GemfireCache implements Cache {
region.destroy(key);
}
@SuppressWarnings("unchecked")
public ValueWrapper get(Object key) {
Object value = region.get(key);

View File

@@ -32,23 +32,27 @@ import com.gemstone.gemfire.cache.Region;
* discovers the created caches (or {@link Region}s in Gemfire terminology).
*
* @author Costin Leau
* @author David Turanski
*/
public class GemfireCacheManager extends AbstractCacheManager {
private com.gemstone.gemfire.cache.Cache gemfireCache;
private Set<Region<?,?>> regions;
@Override
protected Collection<Cache> loadCaches() {
Assert.notNull(gemfireCache, "a backing GemFire cache is required");
Assert.isTrue(!gemfireCache.isClosed(), "the GemFire cache is closed; an open instance is required");
Set<Region<?, ?>> regions = gemfireCache.rootRegions();
Collection<Cache> caches = new LinkedHashSet<Cache>(regions.size());
if (regions == null) {
Assert.notNull(gemfireCache, "a backing GemFire cache is required");
Assert.isTrue(!gemfireCache.isClosed(), "the GemFire cache is closed; an open instance is required");
regions = gemfireCache.rootRegions();
}
for (Region<?, ?> region : regions) {
Collection<Cache> caches = new LinkedHashSet<Cache>(regions.size());
for (Region<?,?> region: this.regions) {
caches.add(new GemfireCache(region));
}
return caches;
}
@@ -78,4 +82,12 @@ public class GemfireCacheManager extends AbstractCacheManager {
public void setCache(com.gemstone.gemfire.cache.Cache gemfireCache) {
this.gemfireCache = gemfireCache;
}
/**
* Sets a set of regions to use (alternative to injecting the GemFire Cache)
* @param regions
*/
public void setRegions(Set<Region<?,?>> regions) {
this.regions = regions;
}
}

View File

@@ -0,0 +1,5 @@
/**
* Base package for Spring GemFire WAN support
*/
package org.springframework.data.gemfire.wan;

View File

@@ -1,6 +1,4 @@
<?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"

View File

@@ -128,7 +128,7 @@ or copies of the objects (true).
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the cache definition (by default "gemfire-cache").]]></xsd:documentation>
The name of the cache definition (by default "gemfireCache").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-xml-location" type="xsd:string"
@@ -338,14 +338,14 @@ Defines a GemFire Transaction Manager instance for a single GemFire cache.
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the transaction manager definition (by default "gemfire-transaction-manager").]]></xsd:documentation>
The name of the transaction manager definition (by default "gemfireTransactionManager").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string"
use="optional" default="gemfire-cache">
use="optional" default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the bean defining the GemFire cache (by default 'gemfire-cache').
The name of the bean defining the GemFire cache (by default 'gemfireCache').
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -853,10 +853,10 @@ The id of the region bean definition.
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string"
use="optional" default="gemfire-cache">
use="optional" default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the bean defining the GemFire cache (by default 'gemfire-cache').
The name of the bean defining the GemFire cache (by default 'gemfireCache').
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -1500,9 +1500,9 @@ The name of the disk store bean definition. This is also used as the disk store
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string"
use="optional" default="gemfire-cache">
use="optional" default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[The name of the bean defining the GemFire cache (by default 'gemfire-cache').]]></xsd:documentation>
<xsd:documentation><![CDATA[The name of the bean defining the GemFire cache (by default 'gemfireCache').]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
@@ -1748,7 +1748,7 @@ Note that in order to instantiate a pool, a GemFire cache needs to be already st
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the pool definition (by default "gemfire-pool").]]></xsd:documentation>
The name of the pool definition (by default "gemfirePool").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="free-connection-timeout"
@@ -1837,7 +1837,7 @@ The client subscription configuration that is used to control a clients use of s
<xsd:attribute name="id" type="xsd:string"
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[The name of the cache server definition (by default "gemfire-server").]]></xsd:documentation>
<xsd:documentation><![CDATA[The name of the cache server definition (by default "gemfireServer").]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-startup" type="xsd:string"
@@ -1883,9 +1883,9 @@ The server groups that this server will be a member of given as a comma separate
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string"
use="optional" default="gemfire-cache">
use="optional" default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[The name of the bean defining the GemFire cache (by default 'gemfire-cache').]]></xsd:documentation>
<xsd:documentation><![CDATA[The name of the bean defining the GemFire cache (by default 'gemfireCache').]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
@@ -1909,10 +1909,10 @@ Container for continuous query listeners. All listeners will be hosted by the sa
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="cache" type="xsd:string"
default="gemfire-cache">
default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference (by name) to the GemFire cache bean. Default is "gemfire-cache".
A reference (by name) to the GemFire cache bean. Default is "gemfireCache".
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
@@ -2052,10 +2052,10 @@ Indicates whether the index is created even if there is an index with the same n
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="cache-ref" type="xsd:string"
use="optional" default="gemfire-cache">
use="optional" default="gemfireCache">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the bean defining the GemFire cache (by default 'gemfire-cache').
The name of the bean defining the GemFire cache (by default 'gemfireCache').
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -2384,7 +2384,7 @@ The id of this bean definition
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of the cache - default is gemfire-cache
The id of the cache - default is gemfireCache
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -2461,7 +2461,7 @@ The id of this bean definition.
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of the cache - default is gemfire-cache
The id of the cache - default is gemfireCache
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -2486,7 +2486,7 @@ The id of this bean definition.
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of the cache - default is gemfire-cache
The id of the cache - default is gemfireCache
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -2629,7 +2629,7 @@ The port for this hub (integer value, if not specified, Gemfire will select an o
use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[
The id of the cache - default is gemfire-cache
The id of the cache - default is gemfireCache
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

View File

@@ -45,6 +45,7 @@ public class SubRegionTest extends RecreatingContextTest {
@SuppressWarnings({ "rawtypes", "unchecked" })
private void testBasic() throws Exception {
CacheFactoryBean cfb = new CacheFactoryBean();
cfb.setBeanName("gemfireCache");
cfb.setUseBeanFactoryLocator(false);
cfb.afterPropertiesSet();
GemFireCache cache = cfb.getObject();

View File

@@ -58,8 +58,11 @@ public class CacheNamespaceTest extends RecreatingContextTest {
}
private void testBasicCache() throws Exception {
assertTrue(ctx.containsBean("gemfireCache"));
//Check alias is registered
assertTrue(ctx.containsBean("gemfire-cache"));
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfire-cache");
//
CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfireCache");
assertNull(TestUtils.readField("cacheXml", cfb));
assertNull(TestUtils.readField("properties", cfb));
}

View File

@@ -21,6 +21,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FilenameFilter;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,6 +68,20 @@ public class ClientRegionNamespaceTest {
testOverflowToDisk();
}
@AfterClass
public static void tearDown() {
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
new File(name).delete();
}
}
private void testBasicClient() throws Exception {
assertTrue(context.containsBean("simple"));
}

View File

@@ -22,6 +22,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FilenameFilter;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -80,6 +81,16 @@ public class DiskStoreAndEvictionRegionParsingTest {
file.delete();
}
diskStoreDir.delete();
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUPds");
}
})) {
new File(name).delete();
}
}
@Test
@@ -98,7 +109,7 @@ public class DiskStoreAndEvictionRegionParsingTest {
assertEquals(9999, diskStore1.getTimeInterval());
assertEquals(10, diskStore1.getMaxOplogSize());
assertEquals(diskStoreDir, diskStore1.getDiskDirs()[0]);
Cache cache = context.getBean("gemfire-cache", Cache.class);
Cache cache = context.getBean("gemfireCache", Cache.class);
assertSame(diskStore1, cache.findDiskStore("diskStore1"));
}

View File

@@ -44,7 +44,7 @@ public class DynamicRegionNamespaceTest extends RecreatingContextTest {
DynamicRegionFactory drf = DynamicRegionFactory.get();
assertFalse(drf.isOpen());
assertNull(drf.getConfig());
ctx.getBean("gemfire-cache", Cache.class);
ctx.getBean("gemfireCache", Cache.class);
assertTrue(drf.isOpen());
DynamicRegionFactory.Config config = drf.getConfig();
assertFalse(config.persistBackup);

View File

@@ -80,7 +80,7 @@ public class GemfireV6GatewayNamespaceTest extends RecreatingContextTest {
@SuppressWarnings("rawtypes")
private void testGatewaysInGemfire() {
Cache cache = ctx.getBean("gemfire-cache", Cache.class);
Cache cache = ctx.getBean("gemfireCache", Cache.class);
GatewayHub gwh = cache.getGatewayHub("gateway-hub");
assertNotNull(gwh);

View File

@@ -19,11 +19,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Set;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.gemfire.RecreatingContextTest;
@@ -74,6 +77,19 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest {
}
}
@AfterClass
public static void tearDown() {
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
new File(name).delete();
}
}
/**
*
*/

View File

@@ -45,7 +45,7 @@ public class IndexNamespaceTest {
@Before
public void setUp() throws Exception {
Cache cache = (Cache) context.getBean("gemfire-cache");
Cache cache = (Cache) context.getBean("gemfireCache");
if (cache.getRegion(name) == null) {
cache.createRegionFactory().create("test-index");
}

View File

@@ -37,7 +37,7 @@ public class JndiBindingsTest extends RecreatingContextTest {
@Test
public void testJndiBindings() throws Exception {
Cache cache = ctx.getBean("gemfire-cache", Cache.class);
Cache cache = ctx.getBean("gemfireCache", Cache.class);
assertNotNull(cache.getJNDIContext().lookup("java:/SimpleDataSource"));
GemFireBasicDataSource ds = (GemFireBasicDataSource) cache.getJNDIContext().lookup("java:/SimpleDataSource");
assertEquals("org.apache.derby.jdbc.EmbeddedDriver", ds.getJDBCDriver());

View File

@@ -52,9 +52,12 @@ public class PoolNamespaceTest {
}
private void testBasicClient() throws Exception {
assertTrue(context.containsBean("gemfirePool"));
//Check old style alias also registered
assertTrue(context.containsBean("gemfire-pool"));
assertEquals(context.getBean("gemfire-pool"), PoolManager.find("gemfire-pool"));
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfire-pool");
assertEquals(context.getBean("gemfirePool"), PoolManager.find("gemfirePool"));
PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfirePool");
Collection<PoolConnection> locators = TestUtils.readField("locators", pfb);
assertEquals(1, locators.size());
PoolConnection locator = locators.iterator().next();

View File

@@ -49,7 +49,7 @@ public class TxEventHandlersTest {
@Autowired
TestWriter txWriter;
@Resource(name = "gemfire-cache")
@Resource(name = "gemfireCache")
Cache cache;
@SuppressWarnings("rawtypes")

View File

@@ -35,8 +35,11 @@ public class TxManagerNamespaceTest extends RecreatingContextTest {
@Test
public void testBasicCache() throws Exception {
assertTrue(ctx.containsBean("gemfireTransactionManager"));
//Check old style alias also registered
assertTrue(ctx.containsBean("gemfire-transaction-manager"));
GemfireTransactionManager tx = ctx.getBean("gemfire-transaction-manager", GemfireTransactionManager.class);
GemfireTransactionManager tx = ctx.getBean("gemfireTransactionManager", GemfireTransactionManager.class);
assertFalse(tx.isCopyOnRead());
}
}

View File

@@ -54,7 +54,7 @@ public class ContainerXmlSetupTest {
ContinuousQueryListenerContainer container = ctx.getBean(ContinuousQueryListenerContainer.class);
assertTrue(container.isRunning());
Cache cache = ctx.getBean("gemfire-cache", Cache.class);
Cache cache = ctx.getBean("gemfireCache", Cache.class);
Pool pool = ctx.getBean("client", Pool.class);
CqQuery[] cqs = cache.getQueryService().getCqs();

View File

@@ -15,14 +15,16 @@
*/
package org.springframework.data.gemfire.mapping;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.io.File;
import java.io.FilenameFilter;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
import org.springframework.data.gemfire.mapping.MappingPdxSerializer;
import org.springframework.data.gemfire.repository.sample.Address;
import org.springframework.data.gemfire.repository.sample.Person;
@@ -41,6 +43,8 @@ public class MappingPdxSerializerIntegrationTest {
Region<Object, Object> region;
static Cache cache;
@Before
public void setUp() {
@@ -50,8 +54,7 @@ public class MappingPdxSerializerIntegrationTest {
CacheFactory factory = new CacheFactory();
factory.setPdxSerializer(serializer);
factory.setPdxPersistent(true);
Cache cache = factory.create();
cache = factory.create();
RegionFactory<Object, Object> regionFactory = cache.createRegionFactory();
regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
@@ -78,4 +81,22 @@ public class MappingPdxSerializerIntegrationTest {
assertThat(reference.getLastname(), is(person.getLastname()));
assertThat(reference.address, is(person.address));
}
@AfterClass
public static void tearDown() {
try {
cache.close();
}
catch (Exception e) {
}
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
new File(name).delete();
}
}
}

View File

@@ -15,10 +15,13 @@
*/
package org.springframework.data.gemfire.support;
import java.io.File;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.gemfire.CacheFactoryBean;
@@ -38,7 +41,7 @@ public abstract class AbstractRegionFactoryBeanTest {
@Before
public void setUp() throws Exception {
CacheFactoryBean cfb = new CacheFactoryBean();
cfb.setBeanName("gemfire-cache");
cfb.setBeanName("gemfireCache");
cfb.setUseBeanFactoryLocator(false);
cfb.afterPropertiesSet();
cache = cfb.getObject();
@@ -52,6 +55,19 @@ public abstract class AbstractRegionFactoryBeanTest {
}
}
@AfterClass
public static void cleanUp() {
for (String name : new File(".").list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
new File(name).delete();
}
}
protected void addRFBConfig(RegionFactoryBeanConfig rfbc) {
if (regionFactoryBeanConfigs.containsKey(rfbc.regionName)) {
throw new RuntimeException("duplicate region name " + rfbc.regionName);

View File

@@ -6,7 +6,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.category.org.springframework.data.gemfire.listener=TRACE
log4j.category.org.springframework.data.gemfire=DEBUG
log4j.category.org.springframework.beans.=DEBUG
log4j.category.org.springframework.beans=DEBUG
# for debugging datasource initialization
# log4j.category.test.jdbc=DEBUG

View File

@@ -9,7 +9,7 @@
<gfe:cache/>
<bean id="replicate-persistent-region" class="org.springframework.data.gemfire.RegionFactoryBean">
<property name="cache" ref="gemfire-cache"/>
<property name="cache" ref="gemfireCache"/>
<property name="dataPolicy" value="REPLICATE_PERSISTENT"/>
</bean>
</beans>

View File

@@ -1,17 +1,10 @@
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire-1.1.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
<!--
<gfe:client-cache use-bean-factory-locator="false" pool-name="gemfire-pool"/>
<gfe:pool subscription-enabled="false">
<gfe:server host="localhost" port="40404"/>
</gfe:pool>
-->
<gfe:client-cache/>
<gfe:client-region data-policy="NORMAL" name="ChallengeQuestions" id="challengeQuestionsRegion"/>
</beans>

View File

@@ -7,5 +7,5 @@
<gfe:cache />
<gfe:transaction-manager cache-ref="gemfire-cache" copy-on-read="false" />
<gfe:transaction-manager cache-ref="gemfireCache" copy-on-read="false" />
</beans>

View File

@@ -24,7 +24,7 @@
<task:executor id="testTaskExecutor" />
<gfe:cq-listener-container cache="gemfire-cache" pool-name="client">
<gfe:cq-listener-container cache="gemfireCache" pool-name="client">
<!-- default handle method -->
<gfe:listener ref="testBean1" query="SELECT * from /test-cq"/>
<gfe:listener ref="testBean1" query="SELECT * from /test-cq" name="test-bean-1" method="handleQuery"/>