diff --git a/docs/reference/bootstrap.xml b/docs/reference/bootstrap.xml
index 4d4e5dee..e95788c2 100644
--- a/docs/reference/bootstrap.xml
+++ b/docs/reference/bootstrap.xml
@@ -65,13 +65,88 @@
]]>
-
+
+ It is worth pointing out again, that the cache settings apply only if the cache needs to be created, there is no opened cache in existence otherwise the existing cache
+ will be used (and the configuration will simply be discarded).
Configuring a GemFire Region
- Once the Cache is configured, one needs to configure one or more Regions for interacting with the distributed fabric.
+ Once the Cache is configured, one needs to configure one or more Regions for interacting with the data
+ fabric. In a similar manner to the CacheFactoryBean, the RegionFactoryBean allows existing Regions
+ to retrieved or, in case they don't exist, created using various settings. One can specify the Region name, whether it will be destroyed on shutdown
+ (acting as a temporary cache), the associated CacheLoaders, CacheListeners and CacheWriters
+ and if needed, the RegionAttributes for full customization.
+
+
+ Let us start with a simple region declaration, named basic using a nested cache declaration:
+
+
+
+
+
+
+]]>
+
+ Since the region bean definition name is usually the same with that of the cache, the name property can be omitted (the bean name will be used automatically).
+ Additionally by using the name the p namespace,
+ the configuration can be simplified even more:
+
+
+
+
+
+
+
+
+
+
+
+
+]]>
+
+ It is worth pointing out, that for the vast majority of cases configuring the cache loader, listener and writer through the Spring container is preferred since the same instances
+ can be reused across multiple regions and additionally, the instances themselves can benefit from the container rich feature set:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+]]>
+
+
+ Configuring a client Region
+
+ For scenarios where a CacheServer is used and clients need to be configured, SGI offers a dedicated configuration class named:
+ ClientRegionFactoryBean. This allows client interests to be registered in both key and regex form through Interest
+ and RegexInterest classes in the org.springframework.data.gemfire package:
+
+
+
+
+
+
+
+
+
+
+]]>
+
+
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
index 8e55d310..5b348bc4 100644
--- a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
@@ -18,12 +18,14 @@ package org.springframework.data.gemfire;
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.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
@@ -34,14 +36,17 @@ import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
/**
- * FactoryBean for creating generic Gemfire {@link Region}s.
+ * FactoryBean for creating generic Gemfire {@link Region}s. Will try to first locate the region (by name)
+ * and, in case none if found, proceed to creating one using the given settings.
*
* @author Costin Leau
*/
-public class RegionFactoryBean implements DisposableBean, FactoryBean>, InitializingBean {
+public class RegionFactoryBean implements DisposableBean, FactoryBean>, InitializingBean,
+ BeanNameAware {
protected final Log log = LogFactory.getLog(getClass());
+ private String beanName;
private Cache cache;
private String name;
private boolean destroy = false;
@@ -50,14 +55,15 @@ public class RegionFactoryBean implements DisposableBean, FactoryBean cacheListeners[];
private CacheLoader cacheLoader;
private CacheWriter cacheWriter;
-
private RegionAttributes attributes;
private Region region;
+
public void afterPropertiesSet() throws Exception {
Assert.notNull(cache, "Cache property must be set");
- Assert.hasText(name, "Name property must be set");
+ name = (!StringUtils.hasText(name) ? beanName : name);
+ Assert.hasText(name, "Name (or beanName) property must be set");
// first get cache
region = cache.getRegion(name);
@@ -125,6 +131,10 @@ public class RegionFactoryBean implements DisposableBean, FactoryBean implements DisposableBean, FactoryBean
+ default-lazy-init="true"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
@@ -18,6 +21,7 @@
+
cache-with-props