Updating docs in progress and changed default bean names to camelCase
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Base package for Spring GemFire WAN support
|
||||
*/
|
||||
package org.springframework.data.gemfire.wan;
|
||||
|
||||
Reference in New Issue
Block a user