Partial Fix and Refactoring for JIRA issue SGF-236 enabling the <gfe:lookup-region/> nested element syntax to function properly.
This commit is contained in:
@@ -77,8 +77,6 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
private Object[] asyncEventQueues;
|
||||
private Object[] gatewaySenders;
|
||||
|
||||
private Region<?, ?> parent;
|
||||
|
||||
private RegionAttributes<K, V> attributes;
|
||||
|
||||
private Resource snapshot;
|
||||
@@ -169,13 +167,13 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
// get underlying AttributesFactory
|
||||
postProcess(findAttributesFactory(regionFactory));
|
||||
|
||||
Region<K, V> region = (this.parent != null ? regionFactory.createSubregion(parent, regionName)
|
||||
Region<K, V> region = (getParent() != null ? regionFactory.createSubregion(getParent(), regionName)
|
||||
: regionFactory.create(regionName));
|
||||
|
||||
if (log.isInfoEnabled()) {
|
||||
if (parent != null) {
|
||||
if (getParent() != null) {
|
||||
log.info(String.format("Created new Cache sub-Region [%1$s] under parent Region [%2$s].",
|
||||
regionName, parent.getName()));
|
||||
regionName, getParent().getName()));
|
||||
}
|
||||
else {
|
||||
log.info(String.format("Created new Cache Region [%1$s].", regionName));
|
||||
@@ -249,7 +247,6 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected void postProcess(Region<K, V> region) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,10 +371,6 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
|
||||
this.hubId = hubId;
|
||||
}
|
||||
|
||||
public void setParent(Region<?, ?> parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void setPersistent(boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,14 @@ import com.gemstone.gemfire.cache.Region;
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class RegionLookupFactoryBean<K, V> implements FactoryBean<Region<K, V>>, InitializingBean, BeanNameAware {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private GemFireCache cache;
|
||||
|
||||
private Region<?, ?> parent;
|
||||
private Region<K, V> region;
|
||||
|
||||
private String beanName;
|
||||
@@ -56,7 +58,13 @@ public class RegionLookupFactoryBean<K, V> implements FactoryBean<Region<K, V>>,
|
||||
Assert.hasText(regionName, "The 'regionName', 'name' or 'beanName' property must be set.");
|
||||
|
||||
synchronized (cache) {
|
||||
region = cache.getRegion(regionName);
|
||||
//region = (getParent() != null ? getParent().getSubregion(regionName) : cache.getRegion(regionName));
|
||||
if (getParent() != null) {
|
||||
region = getParent().getSubregion(regionName);
|
||||
}
|
||||
else {
|
||||
region = cache.getRegion(regionName);
|
||||
}
|
||||
|
||||
if (region != null) {
|
||||
log.info(String.format("Retrieved Region [%1$s] from Cache [%2$s].", regionName, cache.getName()));
|
||||
@@ -126,6 +134,26 @@ public class RegionLookupFactoryBean<K, V> implements FactoryBean<Region<K, V>>,
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.
|
||||
* <p/>
|
||||
* @param parent a reference to the parent Region if this Region is a Sub-Region.
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
*/
|
||||
public void setParent(Region<?, ?> parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.
|
||||
* <p/>
|
||||
* @return a reference to the parent Region or null if this Region is not a Sub-Region.
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
*/
|
||||
protected Region<?, ?> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the Cache Region as expected by GemFire. If no Region is found with the given name, a new one
|
||||
* will be created. If no name is given, the value of the 'name' property will be used.
|
||||
|
||||
@@ -41,15 +41,13 @@ class LookupRegionParser extends AbstractRegionParser {
|
||||
boolean subRegion) {
|
||||
super.doParse(element, builder);
|
||||
|
||||
String resolvedCacheRef = ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref"));
|
||||
|
||||
builder.addPropertyReference("cache", resolvedCacheRef);
|
||||
ParsingUtils.setPropertyValue(element, builder, "name", "name");
|
||||
|
||||
if (!subRegion) {
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
builder.addPropertyReference("cache", (StringUtils.hasText(cacheRef) ? cacheRef
|
||||
: GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
}
|
||||
else {
|
||||
builder.addPropertyValue("lookupOnly", true);
|
||||
parseSubRegions(element, parserContext, resolvedCacheRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user