SGF-10
SGF-15 + made pool-name attribute mandatory + added strategy for pool retrieval
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.data.gemfire.RegionFactoryBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -29,10 +32,11 @@ import com.gemstone.gemfire.cache.client.Pool;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
|
||||
public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> implements BeanFactoryAware {
|
||||
|
||||
private Interest<K>[] interests;
|
||||
private String poolName;
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void postProcess(Region<K, V> region) {
|
||||
@@ -51,6 +55,14 @@ public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
|
||||
|
||||
@Override
|
||||
protected void postProcess(AttributesFactory<K, V> attrFactory) {
|
||||
// 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...");
|
||||
}
|
||||
beanFactory.getBean(poolName, Pool.class);
|
||||
}
|
||||
|
||||
attrFactory.setPoolName(poolName);
|
||||
}
|
||||
|
||||
@@ -77,7 +89,11 @@ public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the interests for this client region. Both key and regex interest are supported.
|
||||
*
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean, Dis
|
||||
private boolean threadLocalConnections = PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS;
|
||||
|
||||
public Class<?> getObjectType() {
|
||||
return Pool.class;
|
||||
return (pool != null ? pool.getClass() : Pool.class);
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
|
||||
@@ -57,6 +57,7 @@ class ClientRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "data-policy", "dataPolicy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "name", "name");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name", "poolName");
|
||||
|
||||
String attr = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
|
||||
@@ -413,7 +413,7 @@ cache to differ from other caches.
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="pool-name" use="optional" type="xsd:string">
|
||||
<xsd:attribute name="pool-name" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the pool used by this client.
|
||||
@@ -452,6 +452,8 @@ The port number of the connection (between 1 and 65535 inclusive).
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="org.springframework.data.gemfire.client.PoolFactoryBean"><![CDATA[
|
||||
Defines a pool for connections from a client to a set of GemFire Cache Servers.
|
||||
|
||||
Note that in order to instantiate a pool, a GemFire cache needs to be already started.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation>
|
||||
|
||||
Reference in New Issue
Block a user