diff --git a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java index 2f739c52..fc664c50 100644 --- a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java @@ -20,14 +20,13 @@ import java.net.InetSocketAddress; import java.util.List; import java.util.Properties; -import org.springframework.beans.factory.BeanFactory; import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.util.Assert; -import org.springframework.util.StringUtils; import com.gemstone.gemfire.cache.GemFireCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.Pool; +import com.gemstone.gemfire.cache.client.PoolManager; import com.gemstone.gemfire.pdx.PdxSerializer; /** @@ -85,18 +84,9 @@ public class ClientCacheFactoryBean extends CacheFactoryBean { private void initializePool(ClientCacheFactory ccf) { Pool p = pool; - if (p == null && StringUtils.hasText(poolName)) { - BeanFactory beanFactory = getBeanFactory(); - - // try to eagerly initialize the pool name, if defined as a bean - if (beanFactory.isTypeMatch(poolName, Pool.class)) { - if (log.isDebugEnabled()) { - log.debug("Found bean definition for pool '" + poolName + "'. Eagerly initializing it..."); - } - p = beanFactory.getBean(poolName, Pool.class); - } - } + p = PoolManager.find(poolName); + System.out.println("*** Pool found " + p); if (p != null) { // copy the pool settings - this way if the pool is not found, at least the cache will have a similar config ccf.setPoolFreeConnectionTimeout(p.getFreeConnectionTimeout()); 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 fcbdfc94..228f8360 100644 --- a/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java @@ -23,16 +23,17 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.BeanFactoryUtils; 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.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import com.gemstone.gemfire.cache.Cache; +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; @@ -106,18 +107,18 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis name = beanName; } - // trigger the initialization of the cache - Class cacheClass = null; - try { - // attempt to use the 6.5 interfaces - cacheClass = ClassUtils.resolveClassName("com.gemstone.gemfire.cache.GemFireCache", classLoader); - } catch (IllegalArgumentException ex) { - // still on 6.0 - cacheClass = Cache.class; - } - if (beanFactory != null) { - beanFactory.getBean(cacheClass); + if (beanFactory instanceof ConfigurableListableBeanFactory) { + ConfigurableListableBeanFactory lbf = (ConfigurableListableBeanFactory) beanFactory; + String[] caches = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(lbf, GemFireCache.class, false, + false); + + for (String bn : caches) { + if (!lbf.isCurrentlyInCreation(bn)) { + beanFactory.getBean(bn); + } + } + } } // first check the configured pools diff --git a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml index 748ce520..d019b540 100644 --- a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml +++ b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml @@ -2,11 +2,11 @@ - - + +