SGF-15
+ add pool support in client FB
+ add attributes processing hooks in region fb
This commit is contained in:
costin
2010-08-31 21:18:00 +03:00
parent 6a5a6e9160
commit f93a240205
2 changed files with 41 additions and 0 deletions

View File

@@ -16,9 +16,12 @@
package org.springframework.data.gemfire;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.Pool;
/**
* Client extension for Gemfire regions.
@@ -28,6 +31,7 @@ import com.gemstone.gemfire.cache.Region;
public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
private Interest<K>[] interests;
private String poolName;
@Override
protected void postProcess(Region<K, V> region) {
@@ -44,6 +48,11 @@ public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
}
}
@Override
protected void postProcess(AttributesFactory<K, V> attrFactory) {
attrFactory.setPoolName(poolName);
}
@Override
public void destroy() throws Exception {
Region<K, V> region = getObject();
@@ -83,4 +92,23 @@ public class ClientRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
Interest<K>[] getInterests() {
return interests;
}
/**
* Sets the pool name used by this client.
*
* @param poolName
*/
public void setPoolName(String poolName) {
this.poolName = poolName;
}
/**
* Sets the pool used by this client.
*
* @param poolName
*/
public void setPool(Pool pool) {
Assert.notNull(pool, "pool cannot be null");
setPoolName(pool.getName());
}
}

View File

@@ -103,6 +103,8 @@ public class RegionFactoryBean<K, V> implements DisposableBean, FactoryBean<Regi
attrFactory.setScope(scope);
}
postProcess(attrFactory);
region = cache.createRegion(name, attrFactory.create());
log.info("Created new cache region [" + name + "]");
if (snapshot != null) {
@@ -113,6 +115,17 @@ public class RegionFactoryBean<K, V> implements DisposableBean, FactoryBean<Regi
postProcess(region);
}
/**
* Post-process the attribute factory object used for configuring the region of this factory bean during the initialization process.
* The object is already initialized and configured by the factory bean before this method
* is invoked.
*
* @param attrFactory attribute factory
*/
protected void postProcess(AttributesFactory<K, V> attrFactory) {
}
/**
* Post-process the region object for this factory bean during the initialization process.
* The object is already initialized and configured by the factory bean before this method