General code refactoring and cleanup.

This commit is contained in:
John Blum
2013-11-11 12:35:45 -08:00
parent ffadfc6cb2
commit ac5527ba52
2 changed files with 19 additions and 15 deletions

View File

@@ -94,17 +94,17 @@ public class RegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V> imple
}
@Override
protected Region<K, V> lookupFallback(GemFireCache cache, String regionName) throws Exception {
Assert.isTrue(cache instanceof Cache, "Unable to create regions from " + cache);
protected Region<K, V> lookupFallback(GemFireCache gemfireCache, String regionName) throws Exception {
Assert.isTrue(gemfireCache instanceof Cache, "Unable to create Regions from " + gemfireCache);
Cache c = (Cache) cache;
Cache cache = (Cache) gemfireCache;
if (attributes != null) {
AttributesFactory.validateAttributes(attributes);
}
final RegionFactory<K, V> regionFactory = (attributes != null ? c.createRegionFactory(attributes) :
c.<K, V> createRegionFactory());
final RegionFactory<K, V> regionFactory = (attributes != null ? cache.createRegionFactory(attributes) :
cache.<K, V> createRegionFactory());
if (hubId != null) {
enableGateway = enableGateway == null ? true : enableGateway;

View File

@@ -29,23 +29,27 @@ import org.w3c.dom.Element;
* @author David Turanski
*/
class ReplicatedRegionParser extends AbstractRegionParser {
@Override
protected Class<?> getRegionFactoryClass() {
return ReplicatedRegionFactoryBean.class;
}
@Override
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
boolean subRegion) {
ParsingUtils.parseScope(element, builder);
BeanDefinitionBuilder attrBuilder = subRegion ? builder : BeanDefinitionBuilder
.genericBeanDefinition(RegionAttributesFactoryBean.class);
super.doParseCommonRegionConfiguration(element, parserContext, builder, attrBuilder, subRegion);
BeanDefinitionBuilder regionAttributesFactoryBuilder = (subRegion ? builder
: BeanDefinitionBuilder.genericBeanDefinition(RegionAttributesFactoryBean.class));
super.doParseCommonRegionConfiguration(element, parserContext, builder, regionAttributesFactoryBuilder,
subRegion);
if (!subRegion) {
builder.addPropertyValue("attributes", attrBuilder.getBeanDefinition());
builder.addPropertyValue("attributes", regionAttributesFactoryBuilder.getBeanDefinition());
}
}
@Override
protected Class<?> getRegionFactoryClass() {
return ReplicatedRegionFactoryBean.class;
}
}
}