diff --git a/src/main/java/org/springframework/data/gemfire/PoolFactoryBean.java b/src/main/java/org/springframework/data/gemfire/PoolFactoryBean.java index 747b1915..d7fb15f3 100644 --- a/src/main/java/org/springframework/data/gemfire/PoolFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/PoolFactoryBean.java @@ -20,12 +20,14 @@ import java.util.Collection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +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.data.gemfire.client.PoolConnection; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.PoolFactory; @@ -44,7 +46,7 @@ import com.gemstone.gemfire.cache.client.PoolManager; * * @author Costin Leau */ -public class PoolFactoryBean implements FactoryBean, InitializingBean, DisposableBean { +public class PoolFactoryBean implements FactoryBean, InitializingBean, DisposableBean, BeanNameAware { private static final Log log = LogFactory.getLog(PoolFactoryBean.class); @@ -54,6 +56,7 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis private Pool pool; // pool settings + private String beanName; private String name; private Collection locators; private Collection servers; @@ -76,7 +79,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis private int subscriptionRedundancy = PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY; private boolean threadLocalConnections = PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS; - public Class getObjectType() { return Pool.class; } @@ -90,7 +92,11 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis } public void afterPropertiesSet() throws Exception { - Assert.hasText(name, "the pool name is required"); + if (!StringUtils.hasText(name)) { + Assert.hasText(beanName, "the pool name is required"); + name = beanName; + } + // first check the configured pools Pool existingPool = PoolManager.find(name); if (existingPool != null) { @@ -155,26 +161,8 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis } } - - /** - * @return the internalPool - */ - public boolean isInternalPool() { - return internalPool; - } - - /** - * @param internalPool the internalPool to set - */ - public void setInternalPool(boolean internalPool) { - this.internalPool = internalPool; - } - - /** - * @return the pool - */ - public Pool getPool() { - return pool; + public void setBeanName(String name) { + this.beanName = name; } /** @@ -184,13 +172,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.pool = pool; } - /** - * @return the name - */ - public String getName() { - return name; - } - /** * @param name the name to set */ @@ -198,13 +179,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.name = name; } - /** - * @return the locators - */ - public Collection getLocators() { - return locators; - } - /** * @param locators the locators to set */ @@ -212,13 +186,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.locators = locators; } - /** - * @return the servers - */ - public Collection getServers() { - return servers; - } - /** * @param servers the servers to set */ @@ -226,13 +193,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.servers = servers; } - /** - * @return the keepAlive - */ - public boolean isKeepAlive() { - return keepAlive; - } - /** * @param keepAlive the keepAlive to set */ @@ -240,13 +200,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.keepAlive = keepAlive; } - /** - * @return the freeConnectionTimeout - */ - public int getFreeConnectionTimeout() { - return freeConnectionTimeout; - } - /** * @param freeConnectionTimeout the freeConnectionTimeout to set */ @@ -254,13 +207,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.freeConnectionTimeout = freeConnectionTimeout; } - /** - * @return the idleTimeout - */ - public long getIdleTimeout() { - return idleTimeout; - } - /** * @param idleTimeout the idleTimeout to set */ @@ -268,13 +214,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.idleTimeout = idleTimeout; } - /** - * @return the loadConditioningInterval - */ - public int getLoadConditioningInterval() { - return loadConditioningInterval; - } - /** * @param loadConditioningInterval the loadConditioningInterval to set */ @@ -282,13 +221,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.loadConditioningInterval = loadConditioningInterval; } - /** - * @return the maxConnections - */ - public int getMaxConnections() { - return maxConnections; - } - /** * @param maxConnections the maxConnections to set */ @@ -296,13 +228,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.maxConnections = maxConnections; } - /** - * @return the minConnections - */ - public int getMinConnections() { - return minConnections; - } - /** * @param minConnections the minConnections to set */ @@ -310,13 +235,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.minConnections = minConnections; } - /** - * @return the pingInterval - */ - public long getPingInterval() { - return pingInterval; - } - /** * @param pingInterval the pingInterval to set */ @@ -324,13 +242,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.pingInterval = pingInterval; } - /** - * @return the readTimeout - */ - public int getReadTimeout() { - return readTimeout; - } - /** * @param readTimeout the readTimeout to set */ @@ -338,13 +249,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.readTimeout = readTimeout; } - /** - * @return the retryAttempts - */ - public int getRetryAttempts() { - return retryAttempts; - } - /** * @param retryAttempts the retryAttempts to set */ @@ -352,13 +256,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.retryAttempts = retryAttempts; } - /** - * @return the serverGroup - */ - public String getServerGroup() { - return serverGroup; - } - /** * @param serverGroup the serverGroup to set */ @@ -366,13 +263,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.serverGroup = serverGroup; } - /** - * @return the socketBufferSize - */ - public int getSocketBufferSize() { - return socketBufferSize; - } - /** * @param socketBufferSize the socketBufferSize to set */ @@ -380,13 +270,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.socketBufferSize = socketBufferSize; } - /** - * @return the statisticInterval - */ - public int getStatisticInterval() { - return statisticInterval; - } - /** * @param statisticInterval the statisticInterval to set */ @@ -394,13 +277,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.statisticInterval = statisticInterval; } - /** - * @return the subscriptionAckInterval - */ - public int getSubscriptionAckInterval() { - return subscriptionAckInterval; - } - /** * @param subscriptionAckInterval the subscriptionAckInterval to set */ @@ -408,13 +284,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.subscriptionAckInterval = subscriptionAckInterval; } - /** - * @return the enableSubscription - */ - public boolean isEnableSubscription() { - return enableSubscription; - } - /** * @param enableSubscription the enableSubscription to set */ @@ -422,13 +291,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.enableSubscription = enableSubscription; } - /** - * @return the subscriptionMessageTrackingTimeout - */ - public int getSubscriptionMessageTrackingTimeout() { - return subscriptionMessageTrackingTimeout; - } - /** * @param subscriptionMessageTrackingTimeout the subscriptionMessageTrackingTimeout to set */ @@ -436,13 +298,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.subscriptionMessageTrackingTimeout = subscriptionMessageTrackingTimeout; } - /** - * @return the subscriptionRedundancy - */ - public int getSubscriptionRedundancy() { - return subscriptionRedundancy; - } - /** * @param subscriptionRedundancy the subscriptionRedundancy to set */ @@ -450,13 +305,6 @@ public class PoolFactoryBean implements FactoryBean, InitializingBean, Dis this.subscriptionRedundancy = subscriptionRedundancy; } - /** - * @return the threadLocalConnections - */ - public boolean isThreadLocalConnections() { - return threadLocalConnections; - } - /** * @param threadLocalConnections the threadLocalConnections to set */