From b4e2b4e92c2775fb192ba884e03b551a01dd8447 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Thu, 25 Aug 2011 18:39:05 +0300 Subject: [PATCH] SGF-35 + address cycle again --- .../springframework/data/gemfire/CacheFactoryBean.java | 7 +------ .../data/gemfire/client/PoolFactoryBean.java | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index 86d971c3..1e1f98e9 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -28,7 +28,6 @@ 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.core.Ordered; import org.springframework.core.io.Resource; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.PersistenceExceptionTranslator; @@ -59,7 +58,7 @@ import com.gemstone.gemfire.pdx.PdxSerializer; * @author Costin Leau */ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanClassLoaderAware, DisposableBean, - InitializingBean, FactoryBean, PersistenceExceptionTranslator, Ordered { + InitializingBean, FactoryBean, PersistenceExceptionTranslator { /** * Inner class to avoid a hard dependency on the GemFire 6.6 API. @@ -322,8 +321,4 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl protected BeanFactory getBeanFactory() { return beanFactory; } - - public int getOrder() { - return 0; - } } \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java index 1f68a380..53796054 100644 --- a/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java @@ -31,9 +31,11 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import com.gemstone.gemfire.cache.GemFireCache; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.PoolFactory; import com.gemstone.gemfire.cache.client.PoolManager; +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; /** * Factory bean for easy declaration and configuration of a GemFire pool. @@ -104,6 +106,12 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis name = beanName; } + // eagerly initialize cache (if needed) + if (InternalDistributedSystem.getAnyInstance() == null) { + // no cache found, do eager initialization + beanFactory.getBean(GemFireCache.class); + } + // first check the configured pools Pool existingPool = PoolManager.find(name); if (existingPool != null) {