SGF-538 - Reorganize the XML configuration classes and support in SDG.
This commit is contained in:
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -43,7 +43,7 @@ import com.gemstone.gemfire.cache.query.QueryService;
|
||||
|
||||
/**
|
||||
* Spring FactoryBean for easy declarative creation of GemFire Indexes.
|
||||
*
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
@@ -267,7 +267,7 @@ public class IndexFactoryBean implements InitializingBean, FactoryBean<Index>, B
|
||||
|
||||
/**
|
||||
* Sets the underlying cache used for creating indexes.
|
||||
*
|
||||
*
|
||||
* @param cache cache used for creating indexes.
|
||||
*/
|
||||
public void setCache(RegionService cache) {
|
||||
@@ -276,7 +276,7 @@ public class IndexFactoryBean implements InitializingBean, FactoryBean<Index>, B
|
||||
|
||||
/**
|
||||
* Sets the query service used for creating indexes.
|
||||
*
|
||||
*
|
||||
* @param service query service used for creating indexes.
|
||||
*/
|
||||
public void setQueryService(QueryService service) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.client.support.DelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.data.gemfire.DataPolicyConverter;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.RegionLookupFactoryBean;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -371,7 +371,7 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
|
||||
/**
|
||||
* Set the interests for this client region. Both key and regex interest are
|
||||
* supported.
|
||||
*
|
||||
*
|
||||
* @param interests the interests to set
|
||||
*/
|
||||
public void setInterests(Interest<K>[] interests) {
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.function.config.GemfireFunctionBeanPostProcessor;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
|
||||
*/
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
registerGemfireFunctionBeanPostProcessor(element, parserContext);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void registerGemfireFunctionBeanPostProcessor(Element element, ParserContext parserContext) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(GemfireFunctionBeanPostProcessor.class);
|
||||
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
beanDefinition.setSource(source);
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, parserContext.getRegistry());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
|
||||
/**
|
||||
* The CreateDefinedIndexesApplicationListener class is a Spring ApplicationListener used to create
|
||||
* all the GemFire Cache Region Indexes "defined" using the QueryService.defineXXXX(..) methods.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.context.ApplicationListener
|
||||
* @see org.springframework.context.event.ContextRefreshedEvent
|
||||
* @see com.gemstone.gemfire.cache.query.QueryService
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class CreateDefinedIndexesApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
protected final Log logger = initLogger();
|
||||
|
||||
/**
|
||||
* Attempts to create all defined Indexes using the QueryService, defineXXXX(..) API once
|
||||
* the Spring ApplicationContext has been refreshed.
|
||||
*
|
||||
* @param event the ContextRefreshedEvent fired when the Spring ApplicationContext gets refreshed.
|
||||
* @see #getCache(org.springframework.context.event.ContextRefreshedEvent)
|
||||
* @see org.springframework.context.event.ContextRefreshedEvent
|
||||
* @see com.gemstone.gemfire.cache.Cache#getQueryService()
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache#getLocalQueryService()
|
||||
* @see com.gemstone.gemfire.cache.query.QueryService#createDefinedIndexes()
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(final ContextRefreshedEvent event) {
|
||||
try {
|
||||
QueryService localQueryService = getQueryService(event);
|
||||
|
||||
if (localQueryService != null) {
|
||||
localQueryService.createDefinedIndexes();
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
logger.warn(String.format("unable to create defined Indexes (if any): %1$s", ignore.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
Log initLogger() {
|
||||
return LogFactory.getLog(getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private QueryService getQueryService(final ContextRefreshedEvent event) {
|
||||
ApplicationContext localApplicationContext = event.getApplicationContext();
|
||||
|
||||
return (localApplicationContext.containsBean(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE) ?
|
||||
localApplicationContext.getBean(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE,
|
||||
QueryService.class) : null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Simple utility class used for defining nested factory-method like definitions
|
||||
* w/o polluting the container with useless beans.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
class DiskWriteAttributesFactoryBean implements FactoryBean<com.gemstone.gemfire.cache.DiskWriteAttributes>, InitializingBean {
|
||||
|
||||
private com.gemstone.gemfire.cache.DiskWriteAttributes attributes;
|
||||
|
||||
private com.gemstone.gemfire.cache.DiskWriteAttributesFactory attrFactory;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
attributes = attrFactory.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.gemstone.gemfire.cache.DiskWriteAttributes getObject() throws Exception {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return (attributes != null ? attributes.getClass() : com.gemstone.gemfire.cache.DiskWriteAttributes.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setDiskAttributesFactory(com.gemstone.gemfire.cache.DiskWriteAttributesFactory dwaf) {
|
||||
this.attrFactory = dwaf;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.server.CacheServerFactoryBean;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,11 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -27,20 +30,17 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* The AutoRegionLookupBeanPostProcessor class is a Spring BeanPostProcessor that post processes a GemFireCache by
|
||||
* registering all Cache Regions that have not been explicitly defined in the Spring application context. This is
|
||||
* usually the case for Regions that have been defined in GemFire's native cache.xml or defined use GemFire 8's new
|
||||
* cluster-based configuration service.
|
||||
* The AutoRegionLookupBeanPostProcessor class is a Spring {@link BeanPostProcessor} that post processes
|
||||
* a {@link GemFireCache} by registering all cache {@link Region Regions} that have not been explicitly
|
||||
* defined in the Spring application context. This is usually the case for {@link Region Regions} that
|
||||
* have been defined in GemFire's native {@literal cache.xml} or defined using GemFire 8's cluster-based
|
||||
* configuration service.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware
|
||||
* @see org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @since 1.5.0
|
||||
@@ -49,26 +49,37 @@ public class AutoRegionLookupBeanPostProcessor implements BeanPostProcessor, Bea
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
|
||||
public final void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory,
|
||||
String.format("The BeanFactory reference (%1$s) must be an instance of ConfigurableListableBeanFactory!",
|
||||
ObjectUtils.nullSafeClassName(beanFactory)));
|
||||
String.format("BeanFactory [%1$s] must be an instance of %2$s",
|
||||
ObjectUtils.nullSafeClassName(beanFactory), ConfigurableListableBeanFactory.class.getSimpleName()));
|
||||
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected ConfigurableListableBeanFactory getBeanFactory() {
|
||||
Assert.state(this.beanFactory != null, "A reference to the BeanFactory was not properly configured and initialized!");
|
||||
Assert.state(this.beanFactory != null, "BeanFactory was not properly initialized");
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof GemFireCache) {
|
||||
registerCacheRegionsAsBeans((GemFireCache) bean);
|
||||
}
|
||||
@@ -76,13 +87,15 @@ public class AutoRegionLookupBeanPostProcessor implements BeanPostProcessor, Bea
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void registerCacheRegionsAsBeans(final GemFireCache cache) {
|
||||
/* (non-Javadoc) */
|
||||
void registerCacheRegionsAsBeans(GemFireCache cache) {
|
||||
for (Region region : cache.rootRegions()) {
|
||||
registerRegionAsBean(region);
|
||||
registerCacheRegionAsBean(region);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRegionAsBean(final Region<?, ?> region) {
|
||||
/* (non-Javadoc) */
|
||||
void registerCacheRegionAsBean(Region<?, ?> region) {
|
||||
if (region != null) {
|
||||
String regionBeanName = getBeanName(region);
|
||||
|
||||
@@ -91,19 +104,20 @@ public class AutoRegionLookupBeanPostProcessor implements BeanPostProcessor, Bea
|
||||
}
|
||||
|
||||
for (Region<?, ?> subregion : nullSafeSubregions(region)) {
|
||||
registerRegionAsBean(subregion);
|
||||
registerCacheRegionAsBean(subregion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Set<Region<?, ?>> nullSafeSubregions(final Region<?, ?> parentRegion) {
|
||||
Set<Region<?, ?>> subregions = parentRegion.subregions(false);
|
||||
return (subregions != null ? subregions : Collections.<Region<?, ?>>emptySet());
|
||||
}
|
||||
|
||||
private String getBeanName(final Region region) {
|
||||
/* (non-Javadoc) */
|
||||
String getBeanName(Region region) {
|
||||
String regionFullPath = region.getFullPath();
|
||||
return (regionFullPath.lastIndexOf(Region.SEPARATOR) > 0 ? regionFullPath : region.getName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
Set<Region<?, ?>> nullSafeSubregions(Region<?, ?> parentRegion) {
|
||||
Set<Region<?, ?>> subregions = parentRegion.subregions(false);
|
||||
return (subregions != null ? subregions : Collections.<Region<?, ?>>emptySet());
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -30,22 +27,26 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
|
||||
/**
|
||||
* The ClientRegionAndPoolBeanFactoryPostProcessor class is a Spring {@link BeanFactoryPostProcessor} that ensures
|
||||
* a proper dependency is declared between a GemFire client Region and the GemFire Pool it references and uses, if
|
||||
* the GemFire Pool has been defined and configured in Spring (Data GemFire) configuration meta-data (XML).
|
||||
* {@link ClientRegionPoolBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} implementation
|
||||
* ensuring a proper dependency is declared between a GemFire client {@link com.gemstone.gemfire.cache.Region}
|
||||
* and the GemFire client {@link com.gemstone.gemfire.cache.client.Pool} it references and uses, providing
|
||||
* the GemFire client {@link com.gemstone.gemfire.cache.client.Pool} has been defined and configured with
|
||||
* Spring (Data GemFire) configuration meta-data (e.g. XML).
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @since 1.8.2
|
||||
*/
|
||||
public class ClientRegionAndPoolBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
public class ClientRegionPoolBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
|
||||
protected static final String POOL_NAME_PROPERTY = "poolName";
|
||||
|
||||
/* (non-Javadoc)*/
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
Set<String> clientRegionBeanNames = new HashSet<String>();
|
||||
@@ -67,7 +68,7 @@ public class ClientRegionAndPoolBeanFactoryPostProcessor implements BeanFactoryP
|
||||
String poolName = getPoolName(clientRegionBean);
|
||||
|
||||
if (poolBeanNames.contains(poolName)) {
|
||||
addDependsOn(clientRegionBean, poolName);
|
||||
SpringUtils.addDependsOn(clientRegionBean, poolName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,19 +88,4 @@ public class ClientRegionAndPoolBeanFactoryPostProcessor implements BeanFactoryP
|
||||
PropertyValue poolNameProperty = clientRegionBean.getPropertyValues().getPropertyValue(POOL_NAME_PROPERTY);
|
||||
return (poolNameProperty != null ? String.valueOf(poolNameProperty.getValue()) : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
BeanDefinition addDependsOn(BeanDefinition bean, String beanName) {
|
||||
String[] dependsOn = bean.getDependsOn();
|
||||
List<String> dependsOnList = new ArrayList<String>();
|
||||
|
||||
if (dependsOn != null) {
|
||||
Collections.addAll(dependsOnList, dependsOn);
|
||||
}
|
||||
|
||||
dependsOnList.add(beanName);
|
||||
bean.setDependsOn(dependsOnList.toArray(new String[dependsOnList.size()]));
|
||||
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
@@ -35,37 +42,34 @@ import org.springframework.data.gemfire.ScopeConverter;
|
||||
import org.springframework.data.gemfire.client.InterestResultPolicyConverter;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicyConverter;
|
||||
import org.springframework.data.gemfire.support.AbstractPropertyEditorConverterSupport;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.wan.OrderPolicyConverter;
|
||||
import org.springframework.data.gemfire.wan.StartupPolicyConverter;
|
||||
import org.springframework.data.gemfire.wan.StartupPolicyType;
|
||||
|
||||
import com.gemstone.gemfire.cache.EvictionAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.InterestPolicy;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegisteringBeanFactoryPostProcessor class is a Spring {@link BeanFactoryPostProcessor} used
|
||||
* to register custom GemFire-specific JavaBeans {@link java.beans.PropertyEditor}s and Spring {@link Converter}s
|
||||
* {@link CustomEditorBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} implementation
|
||||
* used to register custom {@link java.beans.PropertyEditor PropertyEditors} / Spring {@link Converter Converters}
|
||||
* that are used to perform type conversions between String-based configuration meta-data and actual GemFire
|
||||
* or Spring Data GemFire defined enumerated types.
|
||||
* or Spring Data GemFire defined (enumerated) types.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
class CustomEditorRegisteringBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
public class CustomEditorBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
beanFactory.registerCustomEditor(ConnectionEndpoint.class, StringToConnectionEndpointConverter.class);
|
||||
//beanFactory.registerCustomEditor(ConnectionEndpoint[].class, ConnectionEndpointArrayToIterableConverter.class);
|
||||
beanFactory.registerCustomEditor(ConnectionEndpointList.class, StringToConnectionEndpointListConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionAction.class, EvictionActionConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionPolicyType.class, EvictionPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
|
||||
@@ -83,10 +87,39 @@ class CustomEditorRegisteringBeanFactoryPostProcessor implements BeanFactoryPost
|
||||
public static class ConnectionEndpointArrayToIterableConverter extends PropertyEditorSupport
|
||||
implements Converter<ConnectionEndpoint[], Iterable> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterable convert(ConnectionEndpoint[] source) {
|
||||
return ConnectionEndpointList.from(source);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static class StringToConnectionEndpointConverter
|
||||
extends AbstractPropertyEditorConverterSupport<ConnectionEndpoint> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConnectionEndpoint convert(String source) {
|
||||
return assertConverted(source, ConnectionEndpoint.parse(source), ConnectionEndpoint.class);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static class StringToConnectionEndpointListConverter
|
||||
extends AbstractPropertyEditorConverterSupport<ConnectionEndpointList> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConnectionEndpointList convert(String source) {
|
||||
return assertConverted(source, ConnectionEndpointList.parse(0, source.split(",")),
|
||||
ConnectionEndpointList.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.support;
|
||||
|
||||
import com.gemstone.gemfire.cache.query.MultiIndexCreationException;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
|
||||
/**
|
||||
* {@link DefinedIndexesApplicationListener} is a Spring {@link ApplicationListener} used to create all
|
||||
* "defined" GemFire {@link com.gemstone.gemfire.cache.query.Index Indexes} by using the {@link QueryService},
|
||||
* {@literal defineXxxIndex(..)} methods.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.context.ApplicationListener
|
||||
* @see org.springframework.context.event.ContextRefreshedEvent
|
||||
* @see com.gemstone.gemfire.cache.query.QueryService
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class DefinedIndexesApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
protected final Log logger = initLogger();
|
||||
|
||||
/**
|
||||
* Attempts to create all defined {@link com.gemstone.gemfire.cache.query.Index Indexes} using
|
||||
* the {@link QueryService}, {@literal defineXxxIndex(..)} API once the Spring {@link ApplicationContext}
|
||||
* has been refreshed.
|
||||
*
|
||||
* @param event {@link ContextRefreshedEvent} fired when the Spring {@link ApplicationContext} gets refreshed.
|
||||
* @see org.springframework.context.event.ContextRefreshedEvent
|
||||
* @see com.gemstone.gemfire.cache.query.QueryService#createDefinedIndexes()
|
||||
* @see #getQueryService(ContextRefreshedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
try {
|
||||
QueryService queryService = getQueryService(event);
|
||||
|
||||
if (queryService != null) {
|
||||
queryService.createDefinedIndexes();
|
||||
}
|
||||
}
|
||||
catch (MultiIndexCreationException ignore) {
|
||||
logger.warn(String.format("Failed to create pre-defined Indexes: %s", ignore.getMessage()), ignore);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
Log initLogger() {
|
||||
return LogFactory.getLog(getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private QueryService getQueryService(ContextRefreshedEvent event) {
|
||||
ApplicationContext applicationContext = event.getApplicationContext();
|
||||
String queryServiceBeanName = getQueryServiceBeanName();
|
||||
|
||||
return (applicationContext.containsBean(queryServiceBeanName) ?
|
||||
applicationContext.getBean(queryServiceBeanName, QueryService.class) : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private String getQueryServiceBeanName() {
|
||||
return GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -28,13 +28,13 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The DiskStoreBeanPostProcessor class post processes any GemFire Disk Store DiskDir Spring beans defined
|
||||
* in the application context to ensure that the Disk Store directory location (disk-dir) actually exists
|
||||
* before creating the Disk Store.
|
||||
* The {@link DiskStoreBeanPostProcessor} processes any GemFire {@link com.gemstone.gemfire.cache.DiskStore},
|
||||
* {@link DiskDir} Spring beans defined in the application context to ensure that the directory actually exists
|
||||
* before creating the {@link com.gemstone.gemfire.cache.DiskStore}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* @see org.springframework.data.gemfire.DiskStoreFactoryBean.DiskDir
|
||||
* @see com.gemstone.gemfire.cache.DiskStore
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@@ -42,11 +42,14 @@ public class DiskStoreBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Post Processing Bean (%1$s) of Type (%2$s) with Name (%3$s)...%n", bean,
|
||||
ObjectUtils.nullSafeClassName(bean), beanName));
|
||||
log.debug(String.format("Processing Bean [%1$s] of Type [%2$s] with Name [%3$s] before initialization%n",
|
||||
bean, ObjectUtils.nullSafeClassName(bean), beanName));
|
||||
}
|
||||
|
||||
if (bean instanceof DiskDir) {
|
||||
@@ -56,33 +59,43 @@ public class DiskStoreBeanPostProcessor implements BeanPostProcessor {
|
||||
return bean;
|
||||
}
|
||||
|
||||
private void createIfNotExists(final DiskDir diskDirectory) {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void createIfNotExists(DiskDir diskDirectory) {
|
||||
String location = readField(diskDirectory, "location");
|
||||
|
||||
File diskDirectoryFile = new File(location);
|
||||
|
||||
Assert.isTrue(diskDirectoryFile.isDirectory() || diskDirectoryFile.mkdirs(),
|
||||
String.format("Failed to create Disk Directory (%1$s)%n!", location));
|
||||
String.format("Failed to create Disk Directory [%s]%n", location));
|
||||
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info(String.format("The Disk Directory either exists or was created @ Location (%1$s).%n", location));
|
||||
log.info(String.format("Disk Directory is @ Location [%s].%n", location));
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T readField(final Object obj, final String fieldName) {
|
||||
private <T> T readField(Object obj, String fieldName) {
|
||||
try {
|
||||
Class type = obj.getClass();
|
||||
Field field;
|
||||
|
||||
do {
|
||||
field = type.getDeclaredField(fieldName);
|
||||
type = type.getSuperclass(); // traverse up the object class hierarchy
|
||||
type = type.getSuperclass();
|
||||
}
|
||||
while (field == null && !Object.class.equals(type));
|
||||
|
||||
if (field == null) {
|
||||
throw new NoSuchFieldException(String.format("Field (%1$s) does not exist on Object of type (%2$s)!",
|
||||
throw new NoSuchFieldException(String.format("No field with name [%1$s] found on object of type [%2$s]",
|
||||
fieldName, ObjectUtils.nullSafeClassName(obj)));
|
||||
}
|
||||
|
||||
@@ -91,14 +104,8 @@ public class DiskStoreBeanPostProcessor implements BeanPostProcessor {
|
||||
return (T) field.get(obj);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(String.format("Failed to read field (%1$s) on Object of type (%2$s)!",
|
||||
throw new RuntimeException(String.format("Failed to read field [%1$s] from object of type [%2$s]",
|
||||
fieldName, ObjectUtils.nullSafeClassName(obj)), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,23 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.support;
|
||||
|
||||
import com.gemstone.gemfire.cache.DiskStore;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.DiskStore;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
|
||||
/**
|
||||
* The PdxDiskStoreAwareBeanFactoryPostProcessor class is a BeanFactoryPostProcessor that modifies all Async Event Queue,
|
||||
* Region and Disk Store beans in the Spring container to form a dependency on the Cache's PDX Disk Store bean.
|
||||
* {@link PdxDiskStoreAwareBeanFactoryPostProcessor} is a Spring {@link BeanFactoryPostProcessor} that modifies
|
||||
* all GemFire Async Event Queue, Region and Disk Store beans in the Spring container to form a dependency on
|
||||
* the Cache's PDX {@link DiskStore} bean.
|
||||
*
|
||||
* A persistent Region may contain PDX typed data, in which case, the PDX type meta-data stored to disk needs to be
|
||||
* loaded before the Region having PDX data is loaded from disk.
|
||||
*
|
||||
@@ -48,17 +50,32 @@ public class PdxDiskStoreAwareBeanFactoryPostProcessor implements BeanFactoryPos
|
||||
|
||||
private final String pdxDiskStoreName;
|
||||
|
||||
public PdxDiskStoreAwareBeanFactoryPostProcessor(final String pdxDiskStoreName) {
|
||||
Assert.isTrue(StringUtils.hasText(pdxDiskStoreName), "The name of the PDX Disk Store must be specified!");
|
||||
/**
|
||||
* Constructs an instance of the {@link PdxDiskStoreAwareBeanFactoryPostProcessor} class initialized with
|
||||
* the given PDX {@link DiskStore} name.
|
||||
*
|
||||
* @param pdxDiskStoreName name of the GemFire PDX {@link DiskStore}.
|
||||
* @throws IllegalArgumentException if the GemFire PDX {@link DiskStore} name is unspecified.
|
||||
*/
|
||||
public PdxDiskStoreAwareBeanFactoryPostProcessor(String pdxDiskStoreName) {
|
||||
Assert.hasText(pdxDiskStoreName, "The PDX DiskStore name must be specified");
|
||||
this.pdxDiskStoreName = pdxDiskStoreName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the GemFire PDX {@link DiskStore}.
|
||||
*
|
||||
* @return the name of the GemFire PDX {@link DiskStore}.
|
||||
*/
|
||||
public String getPdxDiskStoreName() {
|
||||
return pdxDiskStoreName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
postProcessPdxDiskStoreDependencies(beanFactory, AsyncEventQueue.class, DiskStore.class, Region.class);
|
||||
}
|
||||
|
||||
@@ -72,7 +89,7 @@ public class PdxDiskStoreAwareBeanFactoryPostProcessor implements BeanFactoryPos
|
||||
* @param beanTypes an array of Class types indicating the type of beans to evaluate.
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory#getBeanNamesForType(Class)
|
||||
*/
|
||||
private void postProcessPdxDiskStoreDependencies(final ConfigurableListableBeanFactory beanFactory,
|
||||
private void postProcessPdxDiskStoreDependencies(ConfigurableListableBeanFactory beanFactory,
|
||||
final Class<?>... beanTypes) {
|
||||
for (Class<?> beanType : beanTypes) {
|
||||
for (String beanName : beanFactory.getBeanNamesForType(beanType)) {
|
||||
@@ -99,7 +116,7 @@ public class PdxDiskStoreAwareBeanFactoryPostProcessor implements BeanFactoryPos
|
||||
* @see #getDependsOn(org.springframework.beans.factory.config.BeanDefinition)
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition#setDependsOn(String[])
|
||||
*/
|
||||
private void addPdxDiskStoreDependency(final BeanDefinition beanDefinition) {
|
||||
private void addPdxDiskStoreDependency(BeanDefinition beanDefinition) {
|
||||
String[] newDependsOn = (String[]) ArrayUtils.insert(getDependsOn(beanDefinition), 0, getPdxDiskStoreName());
|
||||
beanDefinition.setDependsOn(newDependsOn);
|
||||
}
|
||||
@@ -114,8 +131,7 @@ public class PdxDiskStoreAwareBeanFactoryPostProcessor implements BeanFactoryPos
|
||||
* @see #addPdxDiskStoreDependency(org.springframework.beans.factory.config.BeanDefinition)
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition#getDependsOn()
|
||||
*/
|
||||
private String[] getDependsOn(final BeanDefinition beanDefinition) {
|
||||
return (beanDefinition.getDependsOn() != null ? beanDefinition.getDependsOn() : EMPTY_STRING_ARRAY);
|
||||
private String[] getDependsOn(BeanDefinition beanDefinition) {
|
||||
return SpringUtils.defaultIfNull(beanDefinition.getDependsOn(), EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,12 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
@@ -36,42 +39,53 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* Abstract base class encapsulating functionality common to all Region Parsers.
|
||||
* Abstract base class encapsulating functionality common to all Region parsers.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.RegionFactoryBean
|
||||
*/
|
||||
abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return getRegionFactoryClass();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected abstract Class<?> getRegionFactoryClass();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getParentName(final Element element) {
|
||||
protected String getParentName(Element element) {
|
||||
String regionTemplate = element.getAttribute("template");
|
||||
return (StringUtils.hasText(regionTemplate) ? regionTemplate : super.getParentName(element));
|
||||
}
|
||||
|
||||
protected boolean isRegionTemplate(final Element element) {
|
||||
/* (non-Javadoc) */
|
||||
protected boolean isRegionTemplate(Element element) {
|
||||
String localName = element.getLocalName();
|
||||
return (localName != null && localName.endsWith("-template"));
|
||||
}
|
||||
|
||||
protected boolean isSubRegion(final Element element) {
|
||||
/* (non-Javadoc) */
|
||||
protected boolean isSubRegion(Element element) {
|
||||
String localName = element.getParentNode().getLocalName();
|
||||
return (localName != null && localName.endsWith("region"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
@@ -79,13 +93,15 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
doParseRegion(element, parserContext, builder, isSubRegion(element));
|
||||
}
|
||||
|
||||
protected abstract void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion);
|
||||
/* (non-Javadoc) */
|
||||
protected abstract void doParseRegion(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder, boolean subRegion);
|
||||
|
||||
protected void doParseCommonRegionConfiguration(Element element, ParserContext parserContext,
|
||||
/* (non-Javadoc) */
|
||||
protected void doParseRegionConfiguration(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder regionAttributesBuilder, boolean subRegion) {
|
||||
|
||||
mergeTemplateRegionAttributes(element, parserContext, regionBuilder, regionAttributesBuilder);
|
||||
mergeRegionTemplateAttributes(element, parserContext, regionBuilder, regionAttributesBuilder);
|
||||
|
||||
String resolvedCacheRef = ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref"));
|
||||
|
||||
@@ -166,7 +182,8 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
void mergeTemplateRegionAttributes(Element element, ParserContext parserContext,
|
||||
/* (non-Javadoc) */
|
||||
void mergeRegionTemplateAttributes(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder regionAttributesBuilder) {
|
||||
|
||||
String regionTemplateName = getParentName(element);
|
||||
@@ -186,13 +203,15 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
else {
|
||||
parserContext.getReaderContext().error(String.format(
|
||||
"The Region template [%1$s] must be 'defined before' the Region [%2$s] referring to the template!",
|
||||
regionTemplateName, resolveId(element, regionBuilder.getRawBeanDefinition(), parserContext)), element);
|
||||
regionTemplateName, resolveId(element, regionBuilder.getRawBeanDefinition(), parserContext)),
|
||||
element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BeanDefinition getRegionAttributesBeanDefinition(final BeanDefinition region) {
|
||||
Assert.notNull(region, "The 'Region' BeanDefinition must not be null!");
|
||||
/* (non-Javadoc) */
|
||||
BeanDefinition getRegionAttributesBeanDefinition(BeanDefinition region) {
|
||||
Assert.notNull(region, "BeanDefinition must not be null");
|
||||
|
||||
Object regionAttributes = null;
|
||||
|
||||
@@ -204,10 +223,12 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
return (regionAttributes instanceof BeanDefinition ? (BeanDefinition) regionAttributes : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void parseCollectionOfCustomSubElements(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder, String className, String subElementName, String propertyName) {
|
||||
List<Element> subElements = DomUtils.getChildElementsByTagName(element, subElementName,
|
||||
subElementName + "-ref");
|
||||
|
||||
List<Element> subElements = DomUtils.getChildElementsByTagName(
|
||||
element, subElementName, subElementName + "-ref");
|
||||
|
||||
if (!CollectionUtils.isEmpty(subElements)) {
|
||||
ManagedArray array = new ManagedArray(className, subElements.size());
|
||||
@@ -220,6 +241,7 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void parseSubRegions(Element element, ParserContext parserContext, String resolvedCacheRef) {
|
||||
Map<String, Element> allSubRegionElements = new HashMap<String, Element>();
|
||||
|
||||
@@ -232,6 +254,7 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void findSubRegionElements(Element parent, String parentPath, Map<String, Element> allSubRegionElements) {
|
||||
for (Element element : DomUtils.getChildElements(parent)) {
|
||||
if (element.getLocalName().endsWith("region")) {
|
||||
@@ -243,11 +266,13 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private String getRegionNameFromElement(Element element) {
|
||||
String name = element.getAttribute(NAME_ATTRIBUTE);
|
||||
return (StringUtils.hasText(name) ? name : element.getAttribute(ID_ATTRIBUTE));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private String buildSubRegionPath(String parentName, String regionName) {
|
||||
String regionPath = StringUtils.arrayToDelimitedString(new String[] { parentName, regionName }, "/");
|
||||
if (!regionPath.startsWith("/")) {
|
||||
@@ -256,6 +281,7 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
return regionPath;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private BeanDefinition parseSubRegion(Element element, ParserContext parserContext, String subRegionPath,
|
||||
String cacheRef) {
|
||||
|
||||
@@ -274,6 +300,7 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
return beanDefinition;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private String getParentRegionPathFrom(String regionPath) {
|
||||
int index = regionPath.lastIndexOf("/");
|
||||
String parentPath = regionPath.substring(0, index);
|
||||
@@ -283,13 +310,12 @@ abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
return parentPath;
|
||||
}
|
||||
|
||||
protected void validateDataPolicyShortcutAttributesMutualExclusion(final Element element,
|
||||
final ParserContext parserContext) {
|
||||
/* (non-Javadoc) */
|
||||
protected void validateDataPolicyShortcutAttributesMutualExclusion(Element element, ParserContext parserContext) {
|
||||
if (element.hasAttribute("data-policy") && element.hasAttribute("shortcut")) {
|
||||
parserContext.getReaderContext().error(String.format(
|
||||
"Only one of [data-policy, shortcut] may be specified with element '%1$s'.", element.getTagName()),
|
||||
element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.xml;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.function.config.GemfireFunctionBeanPostProcessor;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* A Spring {@link BeanDefinitionParser} to enable Spring Data GemFire Function annotation support.
|
||||
*
|
||||
* Bean definition parser for the <gfe:annotation-driven> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.function.config.GemfireFunctionBeanPostProcessor
|
||||
*/
|
||||
class AnnotationDrivenParser implements BeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
registerGemfireFunctionBeanPostProcessor(element, parserContext);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the {@link GemfireFunctionBeanPostProcessor} as a bean with the Spring application context.
|
||||
*
|
||||
* @param element {@link Element} being parsed.
|
||||
* @param parserContext {@link ParserContext} used capture contextual information while parsing.
|
||||
*/
|
||||
private void registerGemfireFunctionBeanPostProcessor(Element element, ParserContext parserContext) {
|
||||
AbstractBeanDefinition gemfireFunctionBeanPostProcessor = BeanDefinitionBuilder
|
||||
.rootBeanDefinition(GemfireFunctionBeanPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition();
|
||||
|
||||
gemfireFunctionBeanPostProcessor.setSource(parserContext.extractSource(element));
|
||||
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(gemfireFunctionBeanPostProcessor,
|
||||
parserContext.getRegistry());
|
||||
}
|
||||
}
|
||||
@@ -13,34 +13,41 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
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.GemfireUtils;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Bean definition parse for the <gfe:async-event-queue> SDG XML namespace element.
|
||||
* Bean definition parser for the <gfe:async-event-queue> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean
|
||||
*/
|
||||
class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return AsyncEventQueueFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
@@ -85,9 +92,8 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseAsyncEventListener(final Element element, final ParserContext parserContext,
|
||||
final BeanDefinitionBuilder builder) {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseAsyncEventListener(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
Element asyncEventListenerElement = DomUtils.getChildElementByTagName(element, "async-event-listener");
|
||||
|
||||
Object asyncEventListener = ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext,
|
||||
@@ -100,16 +106,17 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseCache(final Element element, final BeanDefinitionBuilder builder) {
|
||||
/* (non-Javadoc) */
|
||||
private void parseCache(Element element, BeanDefinitionBuilder builder) {
|
||||
String cacheRefAttribute = element.getAttribute("cache-ref");
|
||||
|
||||
String cacheName = (StringUtils.hasText(cacheRefAttribute) ? cacheRefAttribute
|
||||
: GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
String cacheName = SpringUtils.defaultIfEmpty(cacheRefAttribute,
|
||||
GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
|
||||
builder.addConstructorArgReference(cacheName);
|
||||
}
|
||||
|
||||
private void parseDiskStore(final Element element, final BeanDefinitionBuilder builder) {
|
||||
/* (non-Javadoc) */
|
||||
private void parseDiskStore(Element element, BeanDefinitionBuilder builder) {
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-store-ref");
|
||||
|
||||
String diskStoreRef = element.getAttribute("disk-store-ref");
|
||||
@@ -118,5 +125,4 @@ class AsyncEventQueueParser extends AbstractSingleBeanDefinitionParser {
|
||||
builder.addDependsOn(diskStoreRef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
@@ -22,34 +22,37 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.config.support.AutoRegionLookupBeanPostProcessor;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* The AutoRegionLookupBeanDefinitionParser class is a Spring BeanDefinitionParser that registers a BeanPostProcessor
|
||||
* that auto registers Regions defined in GemFire's native cache.xml format, or when using GemFire 8's cluster-based
|
||||
* configuration service to define Regions, creating corresponding beans in the Spring context.
|
||||
* Bean definition parser for the <gfe:auto-region-lookup> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* This parser will register a Spring {@link org.springframework.beans.factory.config.BeanPostProcessor)
|
||||
* that discovers all Regions defined in GemFire's native {@literal cache.xml} file, or when using
|
||||
* GemFire 8's cluster-based configuration service to define Regions, to create corresponding beans
|
||||
* in the Spring application context.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.config.AutoRegionLookupBeanPostProcessor
|
||||
* @see org.w3c.dom.Element
|
||||
* @see org.springframework.data.gemfire.config.support.AutoRegionLookupBeanPostProcessor
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class AutoRegionLookupBeanDefinitionParser implements BeanDefinitionParser {
|
||||
class AutoRegionLookupParser implements BeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BeanDefinition parse(final Element element, final ParserContext parserContext) {
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
registerAutoRegionLookupBeanPostProcessor(element, parserContext);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerAutoRegionLookupBeanPostProcessor(final Element element, final ParserContext parserContext) {
|
||||
/* (non-Javadoc) */
|
||||
private void registerAutoRegionLookupBeanPostProcessor(Element element, ParserContext parserContext) {
|
||||
AbstractBeanDefinition autoRegionLookupBeanPostProcessor = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(AutoRegionLookupBeanPostProcessor.class)
|
||||
.rootBeanDefinition(AutoRegionLookupBeanPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition();
|
||||
|
||||
@@ -58,5 +61,4 @@ class AutoRegionLookupBeanDefinitionParser implements BeanDefinitionParser {
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(autoRegionLookupBeanPostProcessor,
|
||||
parserContext.getRegistry());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gemstone.gemfire.internal.datasource.ConfigProperty;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -28,6 +30,8 @@ import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.config.support.CustomEditorBeanFactoryPostProcessor;
|
||||
import org.springframework.data.gemfire.config.support.PdxDiskStoreAwareBeanFactoryPostProcessor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
@@ -35,23 +39,29 @@ import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
import com.gemstone.gemfire.internal.datasource.ConfigProperty;
|
||||
|
||||
/**
|
||||
* Parser for <cache> bean definitions.
|
||||
*
|
||||
* Bean definition parser for the <gfe:cache> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Oliver Gierke
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.CacheFactoryBean
|
||||
*/
|
||||
class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return CacheFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
@@ -117,9 +127,10 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
/* (non-Javadoc) */
|
||||
void registerGemFireBeanFactoryPostProcessors(BeanDefinitionRegistry registry) {
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(BeanDefinitionBuilder.genericBeanDefinition(
|
||||
CustomEditorRegisteringBeanFactoryPostProcessor.class).getBeanDefinition(), registry);
|
||||
CustomEditorBeanFactoryPostProcessor.class).getBeanDefinition(), registry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parsePdxDiskStore(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
ParsingUtils.setPropertyValue(element, builder, "pdx-disk-store", "pdxDiskStoreName");
|
||||
|
||||
@@ -136,6 +147,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
createPdxDiskStoreAwareBeanFactoryPostProcessorBeanDefinition(pdxDiskStoreName), registry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private AbstractBeanDefinition createPdxDiskStoreAwareBeanFactoryPostProcessorBeanDefinition(String pdxDiskStoreName) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
PdxDiskStoreAwareBeanFactoryPostProcessor.class);
|
||||
@@ -143,6 +155,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseDynamicRegionFactory(Element element, BeanDefinitionBuilder builder) {
|
||||
Element dynamicRegionFactory = DomUtils.getChildElementByTagName(element, "dynamic-region-factory");
|
||||
|
||||
@@ -153,6 +166,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private BeanDefinitionBuilder buildDynamicRegionSupport(Element dynamicRegionFactory) {
|
||||
if (dynamicRegionFactory != null) {
|
||||
BeanDefinitionBuilder dynamicRegionSupport = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
@@ -183,11 +197,12 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dynamicRegionSupport BDB for <dynamic-region-factory> element.
|
||||
* @param dynamicRegionSupport {@link BeanDefinitionBuilder} for <gfe:dynamic-region-factory> element.
|
||||
*/
|
||||
protected void postProcessDynamicRegionSupport(Element element, BeanDefinitionBuilder dynamicRegionSupport) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseJndiBindings(Element element, BeanDefinitionBuilder builder) {
|
||||
List<Element> jndiBindings = DomUtils.getChildElementsByTagName(element, "jndi-binding");
|
||||
|
||||
@@ -238,6 +253,9 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
@@ -251,5 +269,4 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
@@ -22,48 +22,49 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.server.CacheServerFactoryBean;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Namespace parser for "cache-server" element.
|
||||
* Bean definition parser for the <gfe:cache-server< SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.server.CacheServerFactoryBean
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class CacheServerParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return CacheServerFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
String name = super.resolveId(element, definition, parserContext);
|
||||
return (StringUtils.hasText(name) ? name : "gemfireServer");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) {
|
||||
return (super.isEligibleAttribute(attribute, parserContext) && !"groups".equals(attribute.getName())
|
||||
&& !"cache-ref".equals(attribute.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
|
||||
String cacheRefAttribute = element.getAttribute("cache-ref");
|
||||
String cacheRefAttribute = element.getAttribute(ParsingUtils.CACHE_REF_ATTRIBUTE_NAME);
|
||||
|
||||
builder.addPropertyReference("cache", (StringUtils.hasText(cacheRefAttribute) ? cacheRefAttribute
|
||||
: GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
builder.addPropertyReference("cache", SpringUtils.defaultIfEmpty(
|
||||
cacheRefAttribute, GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
|
||||
String groupsAttribute = element.getAttribute("groups");
|
||||
|
||||
@@ -74,6 +75,7 @@ class CacheServerParser extends AbstractSimpleBeanDefinitionParser {
|
||||
parseSubscription(element, builder);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseSubscription(Element element, BeanDefinitionBuilder builder) {
|
||||
Element subscriptionConfigElement = DomUtils.getChildElementByTagName(element, "subscription-config");
|
||||
|
||||
@@ -89,4 +91,14 @@ class CacheServerParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
String name = super.resolveId(element, definition, parserContext);
|
||||
return (StringUtils.hasText(name) ? name : "gemfireServer");
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -22,23 +22,32 @@ import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <client-cache;gt; definitions.
|
||||
*
|
||||
* Bean definition parser for the <gfe:client-cache> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
|
||||
* @see CacheParser
|
||||
*/
|
||||
class ClientCacheParser extends CacheParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return ClientCacheFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, parserContext, builder);
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "durable-client-id");
|
||||
ParsingUtils.setPropertyValue(element, builder, "durable-client-timeout");
|
||||
ParsingUtils.setPropertyValue(element, builder, "keep-alive");
|
||||
@@ -46,9 +55,11 @@ class ClientCacheParser extends CacheParser {
|
||||
ParsingUtils.setPropertyValue(element, builder, "ready-for-events");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void postProcessDynamicRegionSupport(Element element, BeanDefinitionBuilder dynamicRegionSupport) {
|
||||
ParsingUtils.setPropertyValue(element, dynamicRegionSupport, "pool-name");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,21 +30,29 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <client-region;gt; bean definitions.
|
||||
* Bean definition parser for the <gfe:client-region> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* To avoid eager evaluations, the region interests are declared as nested definition.
|
||||
* To avoid eager evaluations, Region interests are declared as nested bean definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
* @see AbstractRegionParser
|
||||
*/
|
||||
class ClientRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return ClientRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder regionBuilder,
|
||||
boolean subRegion) {
|
||||
@@ -72,7 +80,7 @@ class ClientRegionParser extends AbstractRegionParser {
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
|
||||
mergeTemplateRegionAttributes(element, parserContext, regionBuilder, regionAttributesBuilder);
|
||||
mergeRegionTemplateAttributes(element, parserContext, regionBuilder, regionAttributesBuilder);
|
||||
|
||||
ParsingUtils.parseOptionalRegionAttributes(parserContext, element, regionAttributesBuilder);
|
||||
ParsingUtils.parseStatistics(element, regionAttributesBuilder);
|
||||
@@ -118,7 +126,8 @@ class ClientRegionParser extends AbstractRegionParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseDiskStoreAttribute(final Element element, final BeanDefinitionBuilder builder) {
|
||||
/* (non-Javadoc) */
|
||||
private void parseDiskStoreAttribute(Element element, BeanDefinitionBuilder builder) {
|
||||
String diskStoreRefAttribute = element.getAttribute("disk-store-ref");
|
||||
|
||||
if (StringUtils.hasText(diskStoreRefAttribute)) {
|
||||
@@ -127,12 +136,14 @@ class ClientRegionParser extends AbstractRegionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseCommonInterestAttributes(Element element, BeanDefinitionBuilder builder) {
|
||||
ParsingUtils.setPropertyValue(element, builder, "durable", "durable");
|
||||
ParsingUtils.setPropertyValue(element, builder, "result-policy", "policy");
|
||||
ParsingUtils.setPropertyValue(element, builder, "receive-values", "receiveValues");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private Object parseKeyInterest(Element keyInterestElement, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder keyInterestBuilder = BeanDefinitionBuilder.genericBeanDefinition(Interest.class);
|
||||
|
||||
@@ -143,6 +154,7 @@ class ClientRegionParser extends AbstractRegionParser {
|
||||
return keyInterestBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private Object parseRegexInterest(Element regexInterestElement) {
|
||||
BeanDefinitionBuilder regexInterestBuilder = BeanDefinitionBuilder.genericBeanDefinition(RegexInterest.class);
|
||||
|
||||
@@ -151,5 +163,4 @@ class ClientRegionParser extends AbstractRegionParser {
|
||||
|
||||
return regexInterestBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -27,29 +28,28 @@ import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.DiskStoreFactoryBean;
|
||||
import org.springframework.data.gemfire.DiskStoreFactoryBean.DiskDir;
|
||||
import org.springframework.data.gemfire.config.support.DiskStoreBeanPostProcessor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <disk-store> bean definitions.
|
||||
* Bean definition parser for the <gfe:disk-store> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.DiskStoreFactoryBean
|
||||
* @see org.w3c.dom.Element
|
||||
*/
|
||||
public class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
|
||||
class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private static final AtomicBoolean registered = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean REGISTERED = new AtomicBoolean(false);
|
||||
|
||||
private static void registerDiskStoreBeanPostProcessor(final ParserContext parserContext) {
|
||||
if (registered.compareAndSet(false, true)) {
|
||||
/* (non-Javadoc) */
|
||||
private static void registerDiskStoreBeanPostProcessor(ParserContext parserContext) {
|
||||
if (REGISTERED.compareAndSet(false, true)) {
|
||||
AbstractBeanDefinition diskStoreBeanPostProcessor = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(DiskStoreBeanPostProcessor.class)
|
||||
.rootBeanDefinition(DiskStoreBeanPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition();
|
||||
|
||||
@@ -58,11 +58,17 @@ public class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return DiskStoreFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, parserContext, builder);
|
||||
@@ -102,5 +108,4 @@ public class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
|
||||
builder.addPropertyValue("diskDirs", diskDirs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
@@ -22,26 +22,35 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.FunctionServiceFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <function-service;gt; definitions.
|
||||
* Bean definition parser for the <gfe:function-service> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.FunctionServiceFactoryBean
|
||||
*/
|
||||
class FunctionServiceParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return FunctionServiceFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
|
||||
builder.setLazyInit(false);
|
||||
|
||||
Element functionElement = DomUtils.getChildElementByTagName(element, "function");
|
||||
@@ -52,12 +61,15 @@ class FunctionServiceParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
protected String resolveId(Element element, AbstractBeanDefinition beanDefinition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
String resolvedId = super.resolveId(element, definition, parserContext);
|
||||
return (StringUtils.hasText(resolvedId) ? resolvedId : GemfireConstants.DEFAULT_GEMFIRE_FUNCTION_SERVICE_NAME);
|
||||
}
|
||||
String resolvedId = super.resolveId(element, beanDefinition, parserContext);
|
||||
|
||||
return SpringUtils.defaultIfEmpty(resolvedId, GemfireConstants.DEFAULT_GEMFIRE_FUNCTION_SERVICE_NAME);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,25 +30,27 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for the <gateway-hub> SDG XML namespace element used to create GemFire GatewayHubs.
|
||||
* Bean definition parser for the <gfe:gateway-hub> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.support.ManagedList
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
|
||||
* @see org.springframework.data.gemfire.wan.GatewayProxy
|
||||
*/
|
||||
class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewayHubFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
@@ -65,6 +68,7 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
parseGateways(element, parserContext, builder);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseGateways(Element element, ParserContext parserContext, BeanDefinitionBuilder gatewayHubBuilder) {
|
||||
List<Element> gatewayElements = DomUtils.getChildElementsByTagName(element, "gateway");
|
||||
|
||||
@@ -91,6 +95,7 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseGatewayEndpoints(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) {
|
||||
List<Element> endpointElements = DomUtils.getChildElementsByTagName(gatewayElement, "gateway-endpoint");
|
||||
|
||||
@@ -112,6 +117,7 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseGatewayListeners(Element gatewayElement, ParserContext parserContext,
|
||||
BeanDefinitionBuilder gatewayBuilder) {
|
||||
|
||||
@@ -123,6 +129,7 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseGatewayQueue(Element gatewayElement, BeanDefinitionBuilder gatewayBuilder) {
|
||||
Element gatewayQueueElement = DomUtils.getChildElementByTagName(gatewayElement, "gateway-queue");
|
||||
|
||||
@@ -140,12 +147,10 @@ class GatewayHubParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/* Make sure any disk store is created first */
|
||||
if (gatewayQueueElement.hasAttribute("disk-store-ref")) {
|
||||
gatewayBuilder.getBeanDefinition().setDependsOn(new String[] {
|
||||
gatewayQueueElement.getAttribute("disk-store-ref") });
|
||||
gatewayBuilder.addDependsOn(gatewayQueueElement.getAttribute("disk-store-ref"));
|
||||
}
|
||||
|
||||
gatewayBuilder.addPropertyValue("queue", queueBuilder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,17 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Spring BeanDefinitionParser for the <gfe:gateway-receiver> SDG (GFE) XML XSD namespace element.
|
||||
* Bean definition parser for the <gfe:gateway-receiver> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
@@ -32,17 +33,24 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewayReceiverFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
String cacheRef = element.getAttribute(ParsingUtils.CACHE_REF_ATTRIBUTE_NAME);
|
||||
|
||||
builder.addConstructorArgReference(SpringUtils.defaultIfEmpty(
|
||||
cacheRef, GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef
|
||||
: GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
builder.setLazyInit(false);
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "bind-address");
|
||||
@@ -54,5 +62,4 @@ class GatewayReceiverParser extends AbstractSimpleBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, builder, "socket-buffer-size");
|
||||
ParsingUtils.parseTransportFilters(element, parserContext, builder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,35 +13,45 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.data.gemfire.wan.GatewaySenderFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Bean definition parser for the <gfe:gateway-sender> element in the SDG XML namespace.
|
||||
* Bean definition parser for the <gfe:gateway-sender> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.wan.GatewaySenderFactoryBean
|
||||
*/
|
||||
class GatewaySenderParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GatewaySenderFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
parseCache(element, builder);
|
||||
String cacheRef = element.getAttribute(ParsingUtils.CACHE_REF_ATTRIBUTE_NAME);
|
||||
|
||||
builder.addConstructorArgReference(SpringUtils.defaultIfEmpty(
|
||||
cacheRef, GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, NAME_ATTRIBUTE);
|
||||
ParsingUtils.setPropertyValue(element, builder, "alert-threshold");
|
||||
@@ -97,12 +107,4 @@ class GatewaySenderParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void parseCache(final Element element, final BeanDefinitionBuilder builder) {
|
||||
String cacheRef = element.getAttribute("cache-ref");
|
||||
|
||||
builder.addConstructorArgReference((StringUtils.hasText(cacheRef) ? cacheRef
|
||||
: GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
/**
|
||||
* The GemfireConstants class define constants for Spring GemFire component bean names.
|
||||
@@ -24,13 +24,10 @@ package org.springframework.data.gemfire.config;
|
||||
@SuppressWarnings("unused")
|
||||
public interface GemfireConstants {
|
||||
|
||||
static final String DEFAULT_GEMFIRE_CACHE_NAME = "gemfireCache";
|
||||
static final String DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE = "gemfireIndexDefinitionQueryService";
|
||||
static final String DEFAULT_GEMFIRE_FUNCTION_SERVICE_NAME = "gemfireFunctionService";
|
||||
static final String DEFAULT_GEMFIRE_POOL_NAME = "gemfirePool";
|
||||
static final String DEFAULT_GEMFIRE_TRANSACTION_MANAGER_NAME = "gemfireTransactionManager";
|
||||
|
||||
@Deprecated
|
||||
static final String DEFAULT_GEMFIRE_TXMANAGER_NAME = DEFAULT_GEMFIRE_TRANSACTION_MANAGER_NAME;
|
||||
String DEFAULT_GEMFIRE_CACHE_NAME = "gemfireCache";
|
||||
String DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE = "gemfireIndexDefinitionQueryService";
|
||||
String DEFAULT_GEMFIRE_FUNCTION_SERVICE_NAME = "gemfireFunctionService";
|
||||
String DEFAULT_GEMFIRE_POOL_NAME = "gemfirePool";
|
||||
String DEFAULT_GEMFIRE_TRANSACTION_MANAGER_NAME = "gemfireTransactionManager";
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.data.gemfire.function.config.FunctionExecutionBeanDefinitionParser;
|
||||
@@ -23,18 +23,22 @@ import org.springframework.data.repository.config.RepositoryBeanDefinitionParser
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
|
||||
/**
|
||||
* Namespace handler for GemFire definitions.
|
||||
*
|
||||
* Spring {@link org.springframework.beans.factory.xml.NamespaceHandler} for Spring Data GemFire
|
||||
* XML namespace (XSD) bean definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
class GemfireDataNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
// Repository namespace
|
||||
RepositoryConfigurationExtension extension = new GemfireRepositoryConfigurationExtension();
|
||||
registerBeanDefinitionParser("datasource", new GemfireDataSourceParser());
|
||||
registerBeanDefinitionParser("function-executions", new FunctionExecutionBeanDefinitionParser());
|
||||
@@ -1,16 +1,17 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -25,8 +26,14 @@ import org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Bean definition parser for the <gfe-data:datasource> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor
|
||||
* @see ClientCacheParser
|
||||
* @see PoolParser
|
||||
*/
|
||||
class GemfireDataSourceParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
@@ -35,8 +42,8 @@ class GemfireDataSourceParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#parseInternal(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
@@ -69,5 +76,4 @@ class GemfireDataSourceParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,18 +31,26 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for SGF <code><cq-listener-container></code> element.
|
||||
*
|
||||
* Bean definition parser for the <gfe:cq-listener-container> element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer
|
||||
*/
|
||||
class GemfireListenerContainerParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<ContinuousQueryListenerContainer> getBeanClass(Element element) {
|
||||
return ContinuousQueryListenerContainer.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
ParsingUtils.setPropertyReference(element, builder, "cache", "cache");
|
||||
@@ -67,10 +75,13 @@ class GemfireListenerContainerParser extends AbstractSingleBeanDefinitionParser
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a listener definition. Returns the listener bean reference definition (of a {@link ContinuousQueryDefinition}).
|
||||
*
|
||||
* @param element
|
||||
* @return
|
||||
* Parses a listener bean definition. Returns the listener bean definition
|
||||
* (of type {@link ContinuousQueryDefinition)).
|
||||
*
|
||||
* @param element XML DOM {@link Element} to parse.
|
||||
* @return a Spring {@link BeanDefinition} for the GemFire Continuous Query (CQ) listener configuration.
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinition
|
||||
* @see org.w3c.dom.Element
|
||||
*/
|
||||
private BeanDefinition parseListener(Element element) {
|
||||
BeanDefinitionBuilder continuousQueryListenerBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
@@ -104,5 +115,4 @@ class GemfireListenerContainerParser extends AbstractSingleBeanDefinitionParser
|
||||
|
||||
return continuousQueryBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,19 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Spring NamespaceHandler for GemFire XML namespace (XSD) bean definitions.
|
||||
*
|
||||
* Spring {@link org.springframework.beans.factory.xml.NamespaceHandler} for Spring GemFire
|
||||
* XML namespace (XSD) bean definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
@@ -35,45 +30,32 @@ import org.w3c.dom.Element;
|
||||
@SuppressWarnings("unused")
|
||||
class GemfireNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
static final List<String> GEMFIRE7_ELEMENTS = Arrays.asList("async-event-queue", "gateway-sender",
|
||||
"gateway-receiver");
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
if (GEMFIRE7_ELEMENTS.contains(element.getLocalName())) {
|
||||
ParsingUtils.throwExceptionIfNotGemfireV7(element.getLocalName(), null, parserContext);
|
||||
}
|
||||
|
||||
return super.parse(element, parserContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenParser());
|
||||
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
|
||||
registerBeanDefinitionParser("auto-region-lookup", new AutoRegionLookupParser());
|
||||
registerBeanDefinitionParser("cache", new CacheParser());
|
||||
registerBeanDefinitionParser("cache-server", new CacheServerParser());
|
||||
registerBeanDefinitionParser("auto-region-lookup", new AutoRegionLookupBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("lookup-region", new LookupRegionParser());
|
||||
registerBeanDefinitionParser("region-template", new TemplateRegionParser());
|
||||
registerBeanDefinitionParser("local-region", new LocalRegionParser());
|
||||
registerBeanDefinitionParser("local-region-template", new LocalRegionParser());
|
||||
registerBeanDefinitionParser("partitioned-region", new PartitionedRegionParser());
|
||||
registerBeanDefinitionParser("partitioned-region-template", new PartitionedRegionParser());
|
||||
registerBeanDefinitionParser("replicated-region", new ReplicatedRegionParser());
|
||||
registerBeanDefinitionParser("replicated-region-template", new ReplicatedRegionParser());
|
||||
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
|
||||
registerBeanDefinitionParser("client-cache", new ClientCacheParser());
|
||||
registerBeanDefinitionParser("client-region", new ClientRegionParser());
|
||||
registerBeanDefinitionParser("client-region-template", new ClientRegionParser());
|
||||
registerBeanDefinitionParser("cq-listener-container", new GemfireListenerContainerParser());
|
||||
registerBeanDefinitionParser("disk-store", new DiskStoreParser());
|
||||
registerBeanDefinitionParser("function-service", new FunctionServiceParser());
|
||||
registerBeanDefinitionParser("gateway-hub", new GatewayHubParser());
|
||||
registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser());
|
||||
registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser());
|
||||
registerBeanDefinitionParser("index", new IndexParser());
|
||||
registerBeanDefinitionParser("transaction-manager", new TransactionManagerParser());
|
||||
registerBeanDefinitionParser("client-cache", new ClientCacheParser());
|
||||
registerBeanDefinitionParser("client-region", new ClientRegionParser());
|
||||
registerBeanDefinitionParser("client-region-template", new ClientRegionParser());
|
||||
registerBeanDefinitionParser("cq-listener-container", new GemfireListenerContainerParser());
|
||||
registerBeanDefinitionParser("local-region", new LocalRegionParser());
|
||||
registerBeanDefinitionParser("local-region-template", new LocalRegionParser());
|
||||
registerBeanDefinitionParser("lookup-region", new LookupRegionParser());
|
||||
registerBeanDefinitionParser("partitioned-region", new PartitionedRegionParser());
|
||||
registerBeanDefinitionParser("partitioned-region-template", new PartitionedRegionParser());
|
||||
registerBeanDefinitionParser("pool", new PoolParser());
|
||||
registerBeanDefinitionParser("region-template", new TemplateRegionParser());
|
||||
registerBeanDefinitionParser("replicated-region", new ReplicatedRegionParser());
|
||||
registerBeanDefinitionParser("replicated-region-template", new ReplicatedRegionParser());
|
||||
registerBeanDefinitionParser("transaction-manager", new TransactionManagerParser());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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;
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.aop.config.AopNamespaceUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -24,30 +27,40 @@ import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
* Bean definition parser for the <gfe-data:json-region-auto-proxy< SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.support.JSONRegionAdvice
|
||||
*/
|
||||
public class GemfireRegionAutoProxyParser implements BeanDefinitionParser {
|
||||
class GemfireRegionAutoProxyParser implements BeanDefinitionParser {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(JSONRegionAdvice.class);
|
||||
ParsingUtils.setPropertyValue(element, builder, "pretty-print");
|
||||
ParsingUtils.setPropertyValue(element, builder, "convert-returned-collections");
|
||||
|
||||
BeanDefinitionBuilder jsonRegionAdviceBuilder = BeanDefinitionBuilder.rootBeanDefinition(
|
||||
JSONRegionAdvice.class).setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
||||
ParsingUtils.setPropertyValue(element, jsonRegionAdviceBuilder, "pretty-print");
|
||||
ParsingUtils.setPropertyValue(element, jsonRegionAdviceBuilder, "convert-returned-collections");
|
||||
|
||||
String regionNames = element.getAttribute("included-regions");
|
||||
|
||||
if (StringUtils.hasText(regionNames)) {
|
||||
String[] regions = StringUtils.commaDelimitedListToStringArray(regionNames);
|
||||
ManagedList<String> regionList = new ManagedList<String>(regions.length);
|
||||
for (String regionRef : regions) {
|
||||
regionList.add(regionRef);
|
||||
}
|
||||
builder.addPropertyValue("includedRegions", regionList);
|
||||
Collections.addAll(regionList, regions);
|
||||
jsonRegionAdviceBuilder.addPropertyValue("includedRegions", regionList);
|
||||
}
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
return builder.getBeanDefinition();
|
||||
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(jsonRegionAdviceBuilder.getBeanDefinition(),
|
||||
parserContext.getRegistry());
|
||||
|
||||
return jsonRegionAdviceBuilder.getBeanDefinition();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -25,26 +25,27 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.IndexFactoryBean;
|
||||
import org.springframework.data.gemfire.config.support.DefinedIndexesApplicationListener;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Namespace parser for <index;gt; bean definitions.
|
||||
*
|
||||
* Bean definition parser for <gfe:index> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class IndexParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
private static final AtomicBoolean registered = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean REGISTERED = new AtomicBoolean(false);
|
||||
|
||||
protected static void registerCreateDefinedIndexesApplicationListener(ParserContext parserContext) {
|
||||
if (registered.compareAndSet(false, true)) {
|
||||
/* (non-Javadoc) */
|
||||
protected static void registerDefinedIndexesApplicationListener(ParserContext parserContext) {
|
||||
if (REGISTERED.compareAndSet(false, true)) {
|
||||
AbstractBeanDefinition createDefinedIndexesApplicationListener = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(CreateDefinedIndexesApplicationListener.class)
|
||||
.rootBeanDefinition(DefinedIndexesApplicationListener.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition();
|
||||
|
||||
@@ -53,20 +54,27 @@ class IndexParser extends AbstractSimpleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return IndexFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, parserContext, builder);
|
||||
registerDefinedIndexesApplicationListener(parserContext);
|
||||
ParsingUtils.setPropertyReference(element, builder, "cache-ref", "cache");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(String attributeName) {
|
||||
return (!"cache-ref".equals(attributeName) && super.isEligibleAttribute(attributeName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
registerCreateDefinedIndexesApplicationListener(parserContext);
|
||||
ParsingUtils.setPropertyReference(element, builder, "cache-ref", "cache");
|
||||
super.doParse(element, parserContext, builder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -23,18 +23,26 @@ import org.springframework.data.gemfire.RegionAttributesFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <local-region> bean definitions.
|
||||
* Bean definition parser for the <gfe:local-region> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.LocalRegionFactoryBean
|
||||
* @see AbstractRegionParser
|
||||
*/
|
||||
class LocalRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return LocalRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion) {
|
||||
@@ -44,9 +52,8 @@ class LocalRegionParser extends AbstractRegionParser {
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
|
||||
doParseCommonRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
|
||||
builder.addPropertyValue("attributes", regionAttributesBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -26,28 +26,35 @@ import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* Parser for GFE <lookup-region> bean definitions.
|
||||
* Bean definition parser for the <gfe:lookup-region> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.LookupRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.AbstractRegionParser
|
||||
* @see AbstractRegionParser
|
||||
*/
|
||||
class LookupRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return LookupRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion) {
|
||||
|
||||
super.doParse(element, builder);
|
||||
|
||||
String resolvedCacheRef = ParsingUtils.resolveCacheReference(element.getAttribute("cache-ref"));
|
||||
String resolvedCacheRef = ParsingUtils.resolveCacheReference(
|
||||
element.getAttribute(ParsingUtils.CACHE_REF_ATTRIBUTE_NAME));
|
||||
|
||||
builder.addPropertyReference("cache", resolvedCacheRef);
|
||||
|
||||
@@ -87,5 +94,4 @@ class LookupRegionParser extends AbstractRegionParser {
|
||||
parseSubRegions(element, parserContext, resolvedCacheRef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gemstone.gemfire.cache.LossAction;
|
||||
import com.gemstone.gemfire.cache.MembershipAttributes;
|
||||
import com.gemstone.gemfire.cache.ResumptionAction;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
@@ -31,14 +35,11 @@ import org.springframework.data.gemfire.EvictionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.ExpirationAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.SubscriptionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.gemstone.gemfire.cache.LossAction;
|
||||
import com.gemstone.gemfire.cache.MembershipAttributes;
|
||||
import com.gemstone.gemfire.cache.ResumptionAction;
|
||||
|
||||
/**
|
||||
* Utilities used by the Spring Data GemFire XML Namespace parsers.
|
||||
*
|
||||
@@ -113,19 +114,19 @@ abstract class ParsingUtils {
|
||||
|
||||
/**
|
||||
* Utility method handling parsing of nested definition of the type:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <tag ref="someBean"/>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* or
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* <tag>
|
||||
* <bean .... />
|
||||
* </tag>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @param element the XML element.
|
||||
* @return Bean reference or nested Bean definition.
|
||||
*/
|
||||
@@ -240,7 +241,7 @@ abstract class ParsingUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the subscription sub-element. Populates the given attribute factory with the proper attributes.
|
||||
*
|
||||
@@ -407,7 +408,7 @@ abstract class ParsingUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static boolean parseCustomExpiration(Element rootElement, ParserContext parserContext, String elementName,
|
||||
String propertyName, BeanDefinitionBuilder regionAttributesBuilder) {
|
||||
Element expirationElement = DomUtils.getChildElementByTagName(rootElement, elementName);
|
||||
@@ -442,7 +443,7 @@ abstract class ParsingUtils {
|
||||
}
|
||||
|
||||
static String resolveCacheReference(String cacheReference) {
|
||||
return (StringUtils.hasText(cacheReference) ? cacheReference : GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
return SpringUtils.defaultIfEmpty(cacheReference, GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
}
|
||||
|
||||
static void setRegionReference(Element element, BeanDefinitionBuilder builder) {
|
||||
@@ -452,5 +453,4 @@ abstract class ParsingUtils {
|
||||
static String resolveRegionReference(Element element) {
|
||||
return element.getAttribute(REGION_REF_ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,21 +33,29 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <partitioned-region> bean definitions.
|
||||
* Bean definition parser for the <gfe:partitioned-region> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* To avoid eager evaluations, the region attributes are declared as a nested definition.
|
||||
* To avoid eager evaluations, Region attributes are declared as a nested bean definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.PartitionedRegionFactoryBean
|
||||
* @see AbstractRegionParser
|
||||
*/
|
||||
class PartitionedRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return PartitionedRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder regionBuilder,
|
||||
@@ -58,7 +66,7 @@ class PartitionedRegionParser extends AbstractRegionParser {
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
|
||||
doParseCommonRegionConfiguration(element, parserContext, regionBuilder, regionAttributesBuilder, subRegion);
|
||||
doParseRegionConfiguration(element, parserContext, regionBuilder, regionAttributesBuilder, subRegion);
|
||||
|
||||
regionBuilder.addPropertyValue("attributes", regionAttributesBuilder.getBeanDefinition());
|
||||
|
||||
@@ -110,6 +118,7 @@ class PartitionedRegionParser extends AbstractRegionParser {
|
||||
regionAttributesBuilder.addPropertyValue("partitionAttributes", partitionAttributesBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void mergeTemplateRegionPartitionAttributes(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder regionBuilder, BeanDefinitionBuilder partitionAttributesBuilder) {
|
||||
|
||||
@@ -143,6 +152,7 @@ class PartitionedRegionParser extends AbstractRegionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private void parseColocatedWith(Element element, BeanDefinitionBuilder regionBuilder,
|
||||
BeanDefinitionBuilder partitionAttributesBuilder, String attributeName) {
|
||||
// NOTE rather than using a dependency (with depends-on) we could also set the colocatedWith property of the
|
||||
@@ -160,14 +170,17 @@ class PartitionedRegionParser extends AbstractRegionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private Object parsePartitionResolver(Element subElement, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder) {
|
||||
|
||||
return ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private Object parsePartitionListeners(Element subElement, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder) {
|
||||
|
||||
return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.config.support.ClientRegionPoolBeanFactoryPostProcessor;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpointList;
|
||||
import org.springframework.data.gemfire.util.SpringUtils;
|
||||
@@ -39,14 +40,11 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <gfe:pool> bean definitions.
|
||||
* Bean definition parser for the <gfe:pool> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionRegistry
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.client.PoolFactoryBean
|
||||
*/
|
||||
@@ -69,7 +67,7 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
static void registerInfrastructureComponents(ParserContext parserContext) {
|
||||
if (INFRASTRUCTURE_COMPONENTS_REGISTERED.compareAndSet(false, true)) {
|
||||
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(ClientRegionAndPoolBeanFactoryPostProcessor.class)
|
||||
.rootBeanDefinition(ClientRegionPoolBeanFactoryPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition();
|
||||
|
||||
@@ -77,11 +75,17 @@ class PoolParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return PoolFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -23,19 +23,27 @@ import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <replicated-region;gt; definitions.
|
||||
* Bean definition parser for the <gfe:replicated-region> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.ReplicatedRegionFactoryBean
|
||||
* @see AbstractRegionParser
|
||||
*/
|
||||
class ReplicatedRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return ReplicatedRegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion) {
|
||||
@@ -47,9 +55,8 @@ class ReplicatedRegionParser extends AbstractRegionParser {
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
|
||||
doParseCommonRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
|
||||
builder.addPropertyValue("attributes", regionAttributesBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -26,23 +26,26 @@ import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <gfe-data:snapshot-service> bean definition elements in Spring XML config.
|
||||
* Bean definition parser for the <gfe-data:snapshot-service> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBean
|
||||
* @since 1.7.0
|
||||
*/
|
||||
class SnapshotServiceParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(final Element element) {
|
||||
return SnapshotServiceFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, parserContext, builder);
|
||||
@@ -54,14 +57,17 @@ class SnapshotServiceParser extends AbstractSingleBeanDefinitionParser {
|
||||
builder.addPropertyValue("imports", parseImports(element, parserContext));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private ManagedList<BeanDefinition> parseExports(Element element, ParserContext parserContext) {
|
||||
return parseSnapshots(element, parserContext, "snapshot-export");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private ManagedList<BeanDefinition> parseImports(Element element, ParserContext parserContext) {
|
||||
return parseSnapshots(element, parserContext, "snapshot-import");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private ManagedList<BeanDefinition> parseSnapshots(Element element, ParserContext parserContext,
|
||||
String childTagName) {
|
||||
|
||||
@@ -74,6 +80,7 @@ class SnapshotServiceParser extends AbstractSingleBeanDefinitionParser {
|
||||
return snapshotBeans;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private BeanDefinition parseSnapshotMetadata(Element snapshotMetadataElement, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder snapshotMetadataBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
SnapshotServiceFactoryBean.SnapshotMetadata.class);
|
||||
@@ -90,8 +97,8 @@ class SnapshotServiceParser extends AbstractSingleBeanDefinitionParser {
|
||||
return snapshotMetadataBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean isSnapshotFilterSpecified(final Element snapshotMetadataElement) {
|
||||
return (snapshotMetadataElement.hasAttribute("filter-ref") || snapshotMetadataElement.hasChildNodes());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -23,31 +23,34 @@ import org.springframework.data.gemfire.RegionFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* The TemplateRegionParser class is a generic Region parser used to parse Region Template bean definitions in the
|
||||
* Spring context configuration meta-data to encapsulate common Region 'attribute' configuration irrespective of the
|
||||
* Region's Data Policy (e.g. REPLICATE, PARTITION).
|
||||
* Bean definition parser for <gfe:*-region-template> SDG XML namespace (XSD) elements.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.RegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.AbstractRegionParser
|
||||
* @see AbstractRegionParser
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class TemplateRegionParser extends AbstractRegionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRegionFactoryClass() {
|
||||
return RegionFactoryBean.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
|
||||
boolean subRegion) {
|
||||
BeanDefinitionBuilder regionAttributesBuilder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
RegionAttributesFactoryBean.class);
|
||||
|
||||
doParseCommonRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
doParseRegionConfiguration(element, parserContext, builder, regionAttributesBuilder, subRegion);
|
||||
|
||||
builder.addPropertyValue("attributes", regionAttributesBuilder.getBeanDefinition());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
@@ -26,33 +26,41 @@ import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <transaction-manager> element bean definitions.
|
||||
*
|
||||
* Bean definition parser for the <gfe:transaction-manager> SDG XML namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
|
||||
* @see org.springframework.data.gemfire.GemfireTransactionManager
|
||||
*/
|
||||
class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return GemfireTransactionManager.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void doParse(Element element, BeanDefinitionBuilder builder) {
|
||||
super.doParse(element, builder);
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "copy-on-read", "copyOnRead");
|
||||
|
||||
String attr = element.getAttribute("cache-ref");
|
||||
// add cache reference (fallback to default if nothing is specified)
|
||||
builder.addPropertyReference("cache", (StringUtils.hasText(attr) ? attr : GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
|
||||
|
||||
builder.addPropertyReference("cache", ParsingUtils.resolveCacheReference(element));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
String name = super.resolveId(element, definition, parserContext);
|
||||
|
||||
if (!StringUtils.hasText(name)) {
|
||||
@@ -64,5 +72,4 @@ class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* This package provides classes and components for configuring GemFire using Spring Data GemFire's XML namespace
|
||||
* support. See more details here...
|
||||
* This package provides classes and components for configuring GemFire using Spring Data GemFire's
|
||||
* XML namespace support. See more details here...
|
||||
*
|
||||
* <a href="http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#_spring_data_gemfire_core_schema_gfe">Spring Data GemFire Core Schema (gfe)</a>
|
||||
*/
|
||||
package org.springframework.data.gemfire.config;
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -14,7 +14,7 @@ package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.function.execution.GemfireFunctionProxyFactoryBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.data.gemfire.GemfireQueryException;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.client.support.DelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
@@ -35,32 +35,32 @@ public abstract class AbstractPropertyEditorConverterSupport<T> extends Property
|
||||
implements Converter<String, T> {
|
||||
|
||||
/**
|
||||
* Asserts that the given String was successfully converted into an instance of Class type T.
|
||||
* Asserts that the given {@link String} was converted into an instance of {@link Class type} T.
|
||||
*
|
||||
* @param source the String to convert.
|
||||
* @param convertedValue the value of the String converted into instance of Class type T.
|
||||
* @param type the target Class type of the converted value.
|
||||
* @return the converted value of Class type T if not null.
|
||||
* @throws java.lang.IllegalArgumentException if the String could not be converted into
|
||||
* an instance of Class type T.
|
||||
* @param source {@link String} to convert.
|
||||
* @param convertedValue converted value of {@link Class type} T.
|
||||
* @param type {@link Class type} of the converted value.
|
||||
* @return the converted value.
|
||||
* @throws java.lang.IllegalArgumentException if the {@link String} could not be converted into
|
||||
* an instance of {@link Class type} T.
|
||||
*/
|
||||
protected T assertConverted(final String source, final T convertedValue, final Class<T> type) {
|
||||
Assert.notNull(convertedValue, String.format("(%1$s) is not a valid %2$s!", source, type.getSimpleName()));
|
||||
protected T assertConverted(String source, T convertedValue, Class<T> type) {
|
||||
Assert.notNull(convertedValue, String.format("[%1$s] is not a valid %2$s", source, type.getSimpleName()));
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of this PropertyEditor with the given String converted to the appropriate Class type.
|
||||
* Sets the value of this {@link java.beans.PropertyEditor} to the given {@link String}
|
||||
* converted to the appropriate {@link Class type}.
|
||||
*
|
||||
* @param text the String to convert.
|
||||
* @throws java.lang.IllegalArgumentException if the String could not be converted into
|
||||
* an instance of Class type T.
|
||||
* @param text {@link String} to convert.
|
||||
* @throws java.lang.IllegalArgumentException if the {@link String} could not be converted into
|
||||
* an instance of {@link Class type} T.
|
||||
* @see #convert(Object)
|
||||
* @see #setValue(Object)
|
||||
*/
|
||||
@Override
|
||||
public void setAsText(final String text) throws IllegalArgumentException {
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(convert(text));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ConnectionEndpointList extends AbstractList<ConnectionEndpoint> {
|
||||
*/
|
||||
public static ConnectionEndpointList parse(int defaultPort, String... hostsPorts) {
|
||||
List<ConnectionEndpoint> connectionEndpoints = new ArrayList<ConnectionEndpoint>(
|
||||
ArrayUtils.length((Object) hostsPorts));
|
||||
ArrayUtils.length(hostsPorts));
|
||||
|
||||
for (String hostPort : ArrayUtils.nullSafeArray(hostsPorts, String.class)) {
|
||||
connectionEndpoints.add(ConnectionEndpoint.parse(hostPort, defaultPort));
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class ArrayUtils {
|
||||
* @return a boolean value indicating whether the given array is empty.
|
||||
* @see #length(Object...)
|
||||
*/
|
||||
public static boolean isEmpty(Object... array) {
|
||||
public static boolean isEmpty(Object[] array) {
|
||||
return (length(array) == 0);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public abstract class ArrayUtils {
|
||||
* @param array the array to determine it's length.
|
||||
* @return the length of the given array or 0 if the array reference is null.
|
||||
*/
|
||||
public static int length(Object... array) {
|
||||
public static int length(Object[] array) {
|
||||
return (array != null ? array.length : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
|
||||
package org.springframework.data.gemfire.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -27,9 +32,22 @@ import org.springframework.util.StringUtils;
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
// TODO rename this utiltiy class using a more intuitive, meaningful name
|
||||
// TODO rename this utiltiy class using a more descriptive, intuitive and meaningful name
|
||||
public abstract class SpringUtils {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static BeanDefinition addDependsOn(BeanDefinition bean, String beanName) {
|
||||
String[] dependsOn = bean.getDependsOn();
|
||||
List<String> dependsOnList = new ArrayList<String>();
|
||||
|
||||
Collections.addAll(dependsOnList, ArrayUtils.nullSafeArray(dependsOn, String.class));
|
||||
|
||||
dependsOnList.add(beanName);
|
||||
bean.setDependsOn(dependsOnList.toArray(new String[dependsOnList.size()]));
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static String defaultIfEmpty(String value, String defaultValue) {
|
||||
return (StringUtils.hasText(value) ? value : defaultValue);
|
||||
@@ -40,6 +58,11 @@ public abstract class SpringUtils {
|
||||
return (value != null ? value : defaultValue);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean equalsIgnoreNull(Object obj1, Object obj2) {
|
||||
return (obj1 == null ? obj2 == null : obj1.equals(obj2));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static String dereferenceBean(String beanName) {
|
||||
return String.format("%1$s%2$s", BeanFactory.FACTORY_BEAN_PREFIX, beanName);
|
||||
|
||||
Reference in New Issue
Block a user