Skip to content

Commit

Permalink
modified for Gemfire 7 WAN API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dturanski committed Aug 10, 2012
1 parent 13836ba commit c2536e9
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 47 deletions.
1 change: 1 addition & 0 deletions .springBeans
Expand Up @@ -7,6 +7,7 @@
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>src/test/resources/org/springframework/data/gemfire/support/GemfirePersistenceExceptionTranslationTest-context.xml</config>
</configs>
<configSets>
</configSets>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -8,7 +8,7 @@ slf4jVersion = 1.6.4
springVersion = 3.1.2.RELEASE
springDataCommonsVersion = 1.4.0.M1
#Temporary until release of 7.0
gemfireVersion = 7.0-beta
gemfireVersion = 7.0.Beta-SNAPSHOT
gemfireVersion6x = 6.6.3

# Testing
Expand Down
3 changes: 2 additions & 1 deletion samples/readme.txt
@@ -1,6 +1,7 @@
Spring GemFire Samples
----------------------

NOTE: Spring Data GemFire Sample code has been moved to https://github.com/SpringSource/spring-gemfire-examples
-----------------------------------------------------------------------------------------------------------------
This folder contains various various demo applications and samples for Spring GemFire.

Please see each folder for detailed instructions (readme.txt).
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;

import com.gemstone.gemfire.GemFireCheckedException;
import com.gemstone.gemfire.GemFireException;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
Expand Down Expand Up @@ -454,6 +455,12 @@ public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
return wrapped;
}
}
if (ex.getCause() instanceof GemFireException) {
return GemfireCacheUtils.convertGemfireAccessException((GemFireException)ex.getCause());
}
if (ex.getCause() instanceof GemFireCheckedException) {
return GemfireCacheUtils.convertGemfireAccessException((GemFireCheckedException)ex.getCause());
}

return null;
}
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;

import com.gemstone.gemfire.cache.AsyncEventQueue;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
Expand Down Expand Up @@ -133,13 +133,13 @@ protected Region<K, V> lookupFallback(GemFireCache cache, String regionName) thr
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 (Object gatewaySender : gatewaySenders) {
regionFactory.addGatewaySender((GatewaySender) gatewaySender);
regionFactory.addGatewaySenderId(((GatewaySender) gatewaySender).getId());
}
}

if (!ObjectUtils.isEmpty(asyncEventQueues)) {
for (Object asyncEventQueue : asyncEventQueues) {
regionFactory.addAsyncEventQueue((AsyncEventQueue) asyncEventQueue);
regionFactory.addAsyncEventQueueId(((AsyncEventQueue) asyncEventQueue).getId());
}
}

Expand Down
Expand Up @@ -19,10 +19,8 @@
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;
Expand Down
Expand Up @@ -38,6 +38,8 @@ public abstract class AbstractWANComponentFactoryBean<T> implements FactoryBean<

protected final Cache cache;

protected Object factory;

protected AbstractWANComponentFactoryBean(Cache cache) {
this.cache = cache;
}
Expand Down Expand Up @@ -71,4 +73,9 @@ public final void afterPropertiesSet() throws Exception {
public final boolean isSingleton() {
return true;
}

public void setFactory(Object factory) {
this.factory = factory;
}

}
Expand Up @@ -17,11 +17,11 @@

import org.springframework.util.Assert;

import com.gemstone.gemfire.cache.AsyncEventQueue;
import com.gemstone.gemfire.cache.AsyncEventQueueFactory;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.wan.AsyncEventListener;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;

/**
* FactoryBean for creating GemFire {@link AsyncEventQueue}s.
Expand All @@ -44,8 +44,6 @@ public void setDiskStoreRef(String diskStoreRef) {

private Boolean persistent;

private Boolean parallel;

private String diskStoreRef;

/**
Expand All @@ -71,11 +69,13 @@ public Class<?> getObjectType() {
@Override
protected void doInit() {
Assert.notNull(asyncEventListener, "AsyncEventListener cannot be null");

AsyncEventQueueFactory asyncEventQueueFactory = cache.createAsyncEventQueueFactory();
if (parallel != null) {
asyncEventQueueFactory.setParallel(parallel);
AsyncEventQueueFactory asyncEventQueueFactory = null;
if (this.factory == null) {
asyncEventQueueFactory = cache.createAsyncEventQueueFactory();
} else {
asyncEventQueueFactory = (AsyncEventQueueFactory)factory;
}

if (persistent != null) {
asyncEventQueueFactory.setPersistent(persistent);
}
Expand All @@ -99,7 +99,6 @@ protected void doInit() {
public void destroy() throws Exception {
if (!cache.isClosed()) {
try {
asyncEventQueue.stop();
asyncEventListener.close();
}
catch (CacheClosedException cce) {
Expand All @@ -119,8 +118,4 @@ public void setMaximumQueueMemory(Integer maximumQueueMemory) {
public void setPersistent(Boolean persistent) {
this.persistent = persistent;
}

public void setParallel(Boolean parallel) {
this.parallel = parallel;
}
}
Expand Up @@ -92,7 +92,12 @@ public Class<?> getObjectType() {

@Override
protected void doInit() {
GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
GatewaySenderFactory gatewaySenderFactory = null;
if (this.factory == null) {
gatewaySenderFactory = cache.createGatewaySenderFactory();
} else {
gatewaySenderFactory = (GatewaySenderFactory)factory;
}
if (diskStoreRef != null) {
persistent = (persistent == null) ? Boolean.TRUE : persistent;
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
Expand Down Expand Up @@ -161,10 +166,6 @@ protected void doInit() {
gatewaySender = gatewaySenderFactory.create(name, remoteDistributedSystemId);
}

public void setGatewaySender(GatewaySender gatewaySender) {
this.gatewaySender = gatewaySender;
}

public void setRemoteDistributedSystemId(int remoteDistributedSystemId) {
this.remoteDistributedSystemId = remoteDistributedSystemId;
}
Expand Down
Expand Up @@ -29,14 +29,20 @@
*/
public abstract class RecreatingContextTest {

protected GenericApplicationContext ctx;
protected GenericXmlApplicationContext ctx;

protected abstract String location();

protected void configureContext(){
}

@Before
public void createCtx() {
ctx = new GenericXmlApplicationContext(location());
ctx = new GenericXmlApplicationContext();
configureContext();
ctx.load(location());
ctx.registerShutdownHook();
ctx.refresh();
}

@After
Expand Down

0 comments on commit c2536e9

Please sign in to comment.