The gfe namespace doesn't support this yet but you can do something like this:
Code:
package org.springframework.data.gemfire.config;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
public class SubRegionFactoryBean implements FactoryBean<Region<?,?>>, InitializingBean, BeanNameAware {
private String name;
private Region<?,?> parent;
private Region<?,?> region;
private RegionAttributes<?,?> attributes;
@Override
public Region<?,?> getObject() throws Exception {
return this.region;
}
SubRegionFactoryBean(Region<?,?> parent){
this.parent = parent;
}
@Override
public Class<?> getObjectType() {
return Region.class;
}
@Override
public boolean isSingleton() {
return true;
}
public void setAttributes(RegionAttributes<?,?> attributes) {
this.attributes = attributes;
}
@Override
public void afterPropertiesSet() throws Exception {
if (this.attributes == null){
this.attributes = parent.getAttributes();
}
this.region = this.parent.createSubregion(this.name,this.attributes);
}
@Override
public void setBeanName(String name) {
this.name = name;
}
}
In your spring xml:
Code:
<gfe:replicated-region id="root/>
<bean id="accounts" class="org.springframework.data.gemfire.config.SubRegionFactoryBean">
<constructor-arg ref="root"/>
</bean>
<bean id="transactions" class="org.springframework.data.gemfire.config.SubRegionFactoryBean">
<constructor-arg ref="root"/>
</bean>