Removed the AliasReplacingBeanDefinitionParser class from the Region/bean definition parsing hierarchy moving the remaining methods: getBeanClass, getRegionFactoryClass and isSubRegion to the AbstractRegionParser class. Modified ClientRegionParser to extends AbstractRegionParser directly and provide an supported doParseRegion method since ClientRegionParser overrides doParse directly. Modified AbstractRegionParser class to extend org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser directly changing the overridden doParseInternal method from AliasReplacingBeanDefinitionParser to the overridden to doParse method from AbstractSingleBeanDefintionParser.
This commit is contained in:
@@ -24,7 +24,9 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedArray;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.SubRegionFactoryBean;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
@@ -35,11 +37,23 @@ import org.w3c.dom.Element;
|
||||
*
|
||||
* @author David Turanski
|
||||
*/
|
||||
abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
protected void doParseInternal(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return (isSubRegion(element) ? SubRegionFactoryBean.class : getRegionFactoryClass());
|
||||
}
|
||||
|
||||
protected abstract Class<?> getRegionFactoryClass();
|
||||
|
||||
protected boolean isSubRegion(Element element) {
|
||||
return element.getParentNode().getLocalName().endsWith("region");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
boolean subRegion = isSubRegion(element);
|
||||
|
||||
@@ -196,4 +210,4 @@ abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
String name = element.getAttribute(NAME_ATTRIBUTE);
|
||||
return StringUtils.hasText(name) ? name : element.getAttribute(ID_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.SubRegionFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Extension class dealing with the attribute clash (name) that triggers the
|
||||
* region name to be considered a bean alias. Overrides the automatic alias
|
||||
* detection and replaces it with its own using meta attributes (since the
|
||||
* parsing method is final).
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
abstract class AliasReplacingBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
|
||||
if (isSubRegion(element)) {
|
||||
return SubRegionFactoryBean.class;
|
||||
}
|
||||
else {
|
||||
return getRegionFactoryClass();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Class<?> getRegionFactoryClass();
|
||||
|
||||
@Override
|
||||
protected final void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
doParseInternal(element, parserContext, builder);
|
||||
}
|
||||
|
||||
protected boolean isSubRegion(Element element) {
|
||||
return element.getParentNode().getLocalName().endsWith("region");
|
||||
}
|
||||
|
||||
protected abstract void doParseInternal(Element element, ParserContext parserContext, BeanDefinitionBuilder builder);
|
||||
|
||||
}
|
||||
@@ -39,15 +39,17 @@ import com.gemstone.gemfire.cache.DataPolicy;
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
class ClientRegionParser extends AbstractRegionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return ClientRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParseInternal(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
|
||||
// set scope
|
||||
@@ -131,6 +133,14 @@ class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion) {
|
||||
throw new UnsupportedOperationException(String.format(
|
||||
"doParseRegion(:Element, :ParserContext, :BeanDefinitionBuilder, subRegion:boolean) is not supported on %1$s",
|
||||
getClass().getName()));
|
||||
}
|
||||
|
||||
private Object parseCacheListener(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
|
||||
return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
@@ -159,4 +169,4 @@ class ClientRegionParser extends AliasReplacingBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, builder, "result-policy", "policy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "receive-values", "receiveValues");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user