Permalink
Browse files

modified for Gemfire 7 WAN API changes

  • Loading branch information...
1 parent 13836ba commit c2536e91d89fc15ec012913acbbbd5273be544b4 @dturanski dturanski committed Aug 10, 2012
View
@@ -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>
View
@@ -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
View
@@ -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).
@@ -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;
@@ -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;
}
@@ -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;
@@ -133,13 +133,13 @@ public void afterPropertiesSet() throws Exception {
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());
}
}
@@ -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;
@@ -38,6 +38,8 @@
protected final Cache cache;
+ protected Object factory;
+
protected AbstractWANComponentFactoryBean(Cache cache) {
this.cache = cache;
}
@@ -71,4 +73,9 @@ public final void afterPropertiesSet() throws Exception {
public final boolean isSingleton() {
return true;
}
+
+ public void setFactory(Object factory) {
+ this.factory = factory;
+ }
+
}
@@ -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.
@@ -44,8 +44,6 @@ public void setDiskStoreRef(String diskStoreRef) {
private Boolean persistent;
- private Boolean parallel;
-
private String diskStoreRef;
/**
@@ -71,11 +69,13 @@ public AsyncEventQueue getObject() throws Exception {
@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);
}
@@ -99,7 +99,6 @@ protected void doInit() {
public void destroy() throws Exception {
if (!cache.isClosed()) {
try {
- asyncEventQueue.stop();
asyncEventListener.close();
}
catch (CacheClosedException cce) {
@@ -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;
- }
}
@@ -92,7 +92,12 @@ public GatewaySender getObject() throws Exception {
@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");
@@ -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;
}
@@ -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
Oops, something went wrong.

0 comments on commit c2536e9

Please sign in to comment.