General code refactoring and cleanup.

This commit is contained in:
John Blum
2013-11-15 21:19:07 -08:00
parent f8368c72e8
commit bccf918b72
3 changed files with 19 additions and 16 deletions

View File

@@ -23,9 +23,9 @@ import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.RegionAttributes;
/**
* Spring-friendly bean for creating {@link RegionAttributes}. Eliminates the
* need of using a XML 'factory-method' tag.
*
* Spring-friendly bean for creating {@link RegionAttributes}. Eliminates the need of using
* a XML 'factory-method' tag.
* <p/>
* @author Costin Leau
*/
public class RegionAttributesFactoryBean extends AttributesFactory implements FactoryBean<RegionAttributes>,
@@ -33,11 +33,6 @@ public class RegionAttributesFactoryBean extends AttributesFactory implements Fa
private RegionAttributes attributes;
@Override
public void afterPropertiesSet() throws Exception {
attributes = super.create();
}
@Override
public RegionAttributes getObject() throws Exception {
return attributes;
@@ -52,4 +47,10 @@ public class RegionAttributesFactoryBean extends AttributesFactory implements Fa
public boolean isSingleton() {
return true;
}
}
@Override
public void afterPropertiesSet() throws Exception {
attributes = super.create();
}
}

View File

@@ -49,15 +49,15 @@ public class RegionLookupFactoryBean<K, V> implements FactoryBean<Region<K, V>>,
public void afterPropertiesSet() throws Exception {
Assert.notNull(cache, "Cache property must be set");
name = (!StringUtils.hasText(name) ? beanName : name);
Assert.hasText(name, "Name (or beanName) property must be set");
name = (StringUtils.hasText(name) ? name : beanName);
Assert.hasText(name, "The 'name' or 'beanName' property must be set.");
synchronized (cache) {
region = cache.getRegion(name);
if (region != null) {
log.info("Retrieved region [" + name + "] from cache");
}
if (region != null) {
log.info(String.format("Retrieved region [%1$s] from cache [%2$s].", name, cache.getName()));
}
else {
region = lookupFallback(cache, name);
}

View File

@@ -89,7 +89,8 @@ class PartitionedRegionParser extends AbstractRegionParser {
@SuppressWarnings("rawtypes")
ManagedList fixedPartitionAttributes = new ManagedList();
for (Element fp: fixedPartitions) {
BeanDefinitionBuilder fpaBuilder = BeanDefinitionBuilder.genericBeanDefinition(FixedPartitionAttributesFactoryBean.class);
BeanDefinitionBuilder fpaBuilder = BeanDefinitionBuilder.genericBeanDefinition(
FixedPartitionAttributesFactoryBean.class);
ParsingUtils.setPropertyValue(fp, fpaBuilder, "partition-name");
ParsingUtils.setPropertyValue(fp, fpaBuilder, "num-buckets");
ParsingUtils.setPropertyValue(fp, fpaBuilder, "primary");
@@ -123,7 +124,8 @@ class PartitionedRegionParser extends AbstractRegionParser {
}
}
private Object parsePartitionResolver(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
private Object parsePartitionResolver(ParserContext parserContext, Element subElement,
BeanDefinitionBuilder builder) {
return ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext, subElement, builder);
}