SGF-102 Enable JavaConfig for repositories
This commit is contained in:
@@ -14,7 +14,9 @@ version = "$springGemfireVersion"
|
||||
|
||||
repositories {
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
maven { url "http://repo.springsource.org/plugins-release" }
|
||||
maven { url "http://repo.springsource.org/plugins-release"}
|
||||
//TODO: This is temporary for the Gemfire 7.0 dependency
|
||||
maven { url "https://repo.springsource.org/ext-private-local"}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +63,7 @@ dependencies {
|
||||
// Spring Data
|
||||
compile "org.springframework.data:spring-data-commons-core:${springDataCommonsVersion}"
|
||||
//
|
||||
testCompile "cglib:cglib:${cglibVersion}"
|
||||
testCompile "org.apache.derby:derbyLocale_zh_TW:10.9.1.0"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
SPRING DATA GEMFIRE CHANGELOG
|
||||
=============================
|
||||
http://www.springsource.org/spring-gemfire
|
||||
Changes in version 1.2.0.RELEASE (2012-08-15)
|
||||
---------------------------------------------
|
||||
General
|
||||
* Upgraded to GemFire 7.0
|
||||
* Upgraded to Spring 3.1.2.RELEASE
|
||||
* Upgraded to Spring Data Commons 1.4.0.RELEASE
|
||||
* XML namespace supports everything that can be configured with Cache XML
|
||||
|
||||
Enhancements
|
||||
* [SGF-53] - Add "enable-gateway" to replicated and partitioned region namespace config
|
||||
* [SGF-75] - Ability to define gateways in the Spring Gemfire namespace
|
||||
* [SGF-76] - Disk store should be its own bean
|
||||
* [SGF-79] - Missing gateway attributes for regions
|
||||
* [SGF-86] - Make instance variables protected in CacheFactoryBean
|
||||
* [SGF-95] - Add namespace support for subregions
|
||||
* [SGF-98] - Provide namespace support for all cache and region properties
|
||||
* [SGF-102] - Add support for JavaConfig for repositories
|
||||
* [SGF-104] - The repository deleteAll() method only works for replicated regions
|
||||
* [SGF-109] - Separate repository support into its own namespace
|
||||
|
||||
Bug Fixes
|
||||
|
||||
|
||||
Changes in version 1.1.2.RELEASE (2012-07-04)
|
||||
---------------------------------------------
|
||||
|
||||
@@ -5,15 +5,16 @@ log4jVersion = 1.2.16
|
||||
slf4jVersion = 1.6.4
|
||||
|
||||
# Common libraries
|
||||
springVersion = 3.1.1.RELEASE
|
||||
springDataCommonsVersion = 1.3.2.BUILD-SNAPSHOT
|
||||
#gemfireVersion = 6.6.3
|
||||
gemfireVersion = 7.0
|
||||
springVersion = 3.1.2.RELEASE
|
||||
springDataCommonsVersion = 1.4.0.M1
|
||||
#Temporary until release of 7.0
|
||||
gemfireVersion = 7.0-beta
|
||||
|
||||
# Testing
|
||||
junitVersion = 4.8.1
|
||||
mockitoVersion = 1.8.5
|
||||
hamcrestVersion = 1.2.1
|
||||
cglibVersion = 2.2
|
||||
|
||||
# Manifest properties
|
||||
|
||||
@@ -24,4 +25,4 @@ gemfire.range = "[6.5, 7.0)"
|
||||
# --------------------
|
||||
# Project wide version
|
||||
# --------------------
|
||||
springGemfireVersion=1.2.0.BUILD-SNAPSHOT
|
||||
springGemfireVersion=1.2.0.BUILD-SNAPSHOT
|
||||
@@ -216,21 +216,21 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private GemFireCache cache;
|
||||
protected GemFireCache cache;
|
||||
|
||||
private Resource cacheXml;
|
||||
protected Resource cacheXml;
|
||||
|
||||
private Properties properties;
|
||||
protected Properties properties;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
protected ClassLoader beanClassLoader;
|
||||
|
||||
private GemfireBeanFactoryLocator factoryLocator;
|
||||
protected GemfireBeanFactoryLocator factoryLocator;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
protected BeanFactory beanFactory;
|
||||
|
||||
private String beanName;
|
||||
protected String beanName;
|
||||
|
||||
private boolean useBeanFactoryLocator = true;
|
||||
protected boolean useBeanFactoryLocator = true;
|
||||
|
||||
// PDX options
|
||||
protected Object pdxSerializer;
|
||||
|
||||
@@ -17,18 +17,23 @@
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
import org.springframework.data.gemfire.repository.config.GemfireRepositoryParser;
|
||||
import org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension;
|
||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
|
||||
/**
|
||||
* Namespace handler for GemFire definitions.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class GemfireDataNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("repositories", new GemfireRepositoryParser());
|
||||
// Repository namespace
|
||||
RepositoryConfigurationExtension extension = new GemfireRepositoryConfigurationExtension();
|
||||
registerBeanDefinitionParser("repositories", new RepositoryBeanDefinitionParser(extension));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
|
||||
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||
|
||||
/**
|
||||
* Annotation to enable Gemfire repositories.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Import(GemfireRepositoriesRegistrar.class)
|
||||
public @interface EnableGemfireRepositories {
|
||||
|
||||
/**
|
||||
* Alias for the {@link #basePackages()} attribute. Allows for more concise
|
||||
* annotation declarations e.g.:
|
||||
* {@code @EnableGemfireRepositories("org.my.pkg")} instead of
|
||||
* {@code @EnableGemfireRepositories(basePackages="org.my.pkg")}.
|
||||
*/
|
||||
String[] value() default {};
|
||||
|
||||
/**
|
||||
* Base packages to scan for annotated components. {@link #value()} is an
|
||||
* alias for (and mutually exclusive with) this attribute. Use
|
||||
* {@link #basePackageClasses()} for a type-safe alternative to String-based
|
||||
* package names.
|
||||
*/
|
||||
String[] basePackages() default {};
|
||||
|
||||
/**
|
||||
* Type-safe alternative to {@link #basePackages()} for specifying the
|
||||
* packages to scan for annotated components. The package of each class
|
||||
* specified will be scanned. Consider creating a special no-op marker class
|
||||
* or interface in each package that serves no purpose other than being
|
||||
* referenced by this attribute.
|
||||
*/
|
||||
Class<?>[] basePackageClasses() default {};
|
||||
|
||||
/**
|
||||
* Specifies which types are eligible for component scanning. Further
|
||||
* narrows the set of candidate components from everything in
|
||||
* {@link #basePackages()} to everything in the base packages that matches
|
||||
* the given filter or filters.
|
||||
*/
|
||||
Filter[] includeFilters() default {};
|
||||
|
||||
/**
|
||||
* Specifies which types are not eligible for component scanning.
|
||||
*/
|
||||
Filter[] excludeFilters() default {};
|
||||
|
||||
/**
|
||||
* Returns the postfix to be used when looking up custom repository
|
||||
* implementations. Defaults to {@literal Impl}. So for a repository named
|
||||
* {@code PersonRepository} the corresponding implementation class will be
|
||||
* looked up scanning for {@code PersonRepositoryImpl}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String repositoryImplementationPostfix() default "Impl";
|
||||
|
||||
/**
|
||||
* Configures the location of where to find the Spring Data named queries
|
||||
* properties file. Will default to
|
||||
* {@code META-INFO/jpa-named-queries.properties}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String namedQueriesLocation() default "";
|
||||
|
||||
/**
|
||||
* Returns the key of the {@link QueryLookupStrategy} to be used for lookup
|
||||
* queries for query methods. Defaults to {@link Key#CREATE_IF_NOT_FOUND}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Key queryLookupStrategy() default Key.CREATE_IF_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* Returns the {@link FactoryBean} class to be used for each repository
|
||||
* instance. Defaults to {@link GemfireRepositoryFactoryBean}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Class<?> repositoryFactoryBeanClass() default GemfireRepositoryFactoryBean.class;
|
||||
|
||||
// Gemfire specific configuration
|
||||
/**
|
||||
* Configures the name of the {@link GemfireMappingContext} bean definition
|
||||
* to be used to create repositories discovered through this annotation. If
|
||||
* not configured a default one will be created.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String mappingContextRef() default "";
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
|
||||
/**
|
||||
* {@link ImportBeanDefinitionRegistrar} to setup Gemfire repositories via
|
||||
* {@link EnableGemfireRepositories}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GemfireRepositoriesRegistrar extends RepositoryBeanDefinitionRegistrarSupport {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.config.
|
||||
* RepositoryBeanDefinitionRegistrarSupport#getAnnotation()
|
||||
*/
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
return EnableGemfireRepositories.class;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.config.
|
||||
* RepositoryBeanDefinitionRegistrarSupport#getExtension()
|
||||
*/
|
||||
@Override
|
||||
protected RepositoryConfigurationExtension getExtension() {
|
||||
return new GemfireRepositoryConfigurationExtension();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
|
||||
import org.springframework.data.repository.config.XmlRepositoryConfigurationSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* {@link RepositoryConfigurationExtension} implementation to add Gemfire
|
||||
* specific extensions to the repository XML namespace and annotation based
|
||||
* configuration.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GemfireRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {
|
||||
|
||||
private static final String MAPPING_CONTEXT_REF = "mapping-context-ref";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.repository.config.RepositoryConfigurationExtension
|
||||
* #getRepositoryFactoryClassName()
|
||||
*/
|
||||
@Override
|
||||
public String getRepositoryFactoryClassName() {
|
||||
return GemfireRepositoryFactoryBean.class.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.config.
|
||||
* RepositoryConfigurationExtensionSupport#getModulePrefix()
|
||||
*/
|
||||
@Override
|
||||
protected String getModulePrefix() {
|
||||
return "gemfire";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.config.
|
||||
* RepositoryConfigurationExtensionSupport
|
||||
* #postProcess(org.springframework.beans
|
||||
* .factory.support.BeanDefinitionBuilder,
|
||||
* org.springframework.data.repository
|
||||
* .config.XmlRepositoryConfigurationSource)
|
||||
*/
|
||||
@Override
|
||||
public void postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfigurationSource config) {
|
||||
|
||||
Element element = config.getElement();
|
||||
String mappingContextRef = element.getAttribute(MAPPING_CONTEXT_REF);
|
||||
|
||||
if (StringUtils.hasText(mappingContextRef)) {
|
||||
builder.addPropertyReference("mappingContext", mappingContextRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.data.gemfire.repository.config.SimpleGemfireRepositoryConfiguration.GemfireRepositoryConfiguration;
|
||||
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
|
||||
import org.springframework.data.repository.config.AbstractRepositoryConfigDefinitionParser;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* {@link BeanDefinitionParser} to create {@link GemfireRepositoryFactoryBean}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GemfireRepositoryParser extends
|
||||
AbstractRepositoryConfigDefinitionParser<SimpleGemfireRepositoryConfiguration, GemfireRepositoryConfiguration> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.config.AbstractRepositoryConfigDefinitionParser#getGlobalRepositoryConfigInformation(org.w3c.dom.Element)
|
||||
*/
|
||||
@Override
|
||||
protected SimpleGemfireRepositoryConfiguration getGlobalRepositoryConfigInformation(Element element) {
|
||||
return new SimpleGemfireRepositoryConfiguration(element);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.data.gemfire.repository.config.SimpleGemfireRepositoryConfiguration.GemfireRepositoryConfiguration;
|
||||
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
|
||||
import org.springframework.data.repository.config.AutomaticRepositoryConfigInformation;
|
||||
import org.springframework.data.repository.config.ManualRepositoryConfigInformation;
|
||||
import org.springframework.data.repository.config.RepositoryConfig;
|
||||
import org.springframework.data.repository.config.SingleRepositoryConfigInformation;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Repository configuration implementation.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class SimpleGemfireRepositoryConfiguration extends
|
||||
RepositoryConfig<GemfireRepositoryConfiguration, SimpleGemfireRepositoryConfiguration> {
|
||||
|
||||
private static final String GEMFIRE_TEMPLATE_REF = "gemfire-template-ref";
|
||||
|
||||
/**
|
||||
* Creates a new {@link SimpleGemfireRepositoryConfiguration} for the given {@link Element}.
|
||||
*
|
||||
* @param repositoriesElement must not be {@literal null}.
|
||||
*/
|
||||
protected SimpleGemfireRepositoryConfiguration(Element repositoriesElement) {
|
||||
super(repositoriesElement, GemfireRepositoryFactoryBean.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bean name of the {@link GemfireTemplate} to be used.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getGemfireTemplateRef() {
|
||||
|
||||
String attribute = getSource().getAttribute(GEMFIRE_TEMPLATE_REF);
|
||||
return StringUtils.hasText(attribute) ? attribute : null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.config.GlobalRepositoryConfigInformation#getAutoconfigRepositoryInformation(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public GemfireRepositoryConfiguration getAutoconfigRepositoryInformation(String interfaceName) {
|
||||
return new AutomaticGemfireRepositoryConfiguration(interfaceName, this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.config.CommonRepositoryConfigInformation#getNamedQueriesLocation()
|
||||
*/
|
||||
@Override
|
||||
public String getNamedQueriesLocation() {
|
||||
return "classpath*:META-INF/gemfire-named-queries.properties";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.config.RepositoryConfig#createSingleRepositoryConfigInformationFor(org.w3c.dom.Element)
|
||||
*/
|
||||
@Override
|
||||
protected GemfireRepositoryConfiguration createSingleRepositoryConfigInformationFor(Element element) {
|
||||
return new ManualGemfireRepositoryConfiguration(element, this);
|
||||
}
|
||||
|
||||
public interface GemfireRepositoryConfiguration extends
|
||||
SingleRepositoryConfigInformation<SimpleGemfireRepositoryConfiguration> {
|
||||
|
||||
String getGemfireTemplateRef();
|
||||
}
|
||||
|
||||
static class ManualGemfireRepositoryConfiguration extends
|
||||
ManualRepositoryConfigInformation<SimpleGemfireRepositoryConfiguration> implements GemfireRepositoryConfiguration {
|
||||
|
||||
/**
|
||||
* @param element
|
||||
* @param parent
|
||||
*/
|
||||
public ManualGemfireRepositoryConfiguration(Element element, SimpleGemfireRepositoryConfiguration parent) {
|
||||
super(element, parent);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.gemfire.config.GemfireRepositoryParser.SimpleGemfireRepositoryConfiguration.GemfireRepositoryConfiguration#getGemfireTemplateRef()
|
||||
*/
|
||||
@Override
|
||||
public String getGemfireTemplateRef() {
|
||||
return getAttribute(GEMFIRE_TEMPLATE_REF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class AutomaticGemfireRepositoryConfiguration extends
|
||||
AutomaticRepositoryConfigInformation<SimpleGemfireRepositoryConfiguration> implements
|
||||
GemfireRepositoryConfiguration {
|
||||
|
||||
/**
|
||||
* @param interfaceName
|
||||
* @param parent
|
||||
*/
|
||||
public AutomaticGemfireRepositoryConfiguration(String interfaceName, SimpleGemfireRepositoryConfiguration parent) {
|
||||
super(interfaceName, parent);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.gemfire.config.GemfireRepositoryParser.SimpleGemfireRepositoryConfiguration.GemfireRepositoryConfiguration#getGemfireTemplateRef()
|
||||
*/
|
||||
@Override
|
||||
public String getGemfireTemplateRef() {
|
||||
|
||||
return getParent().getGemfireTemplateRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,6 @@ targetNamespace="http://www.springframework.org/schema/data/gemfire" elementForm
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="repository:repositories">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="repository" type="gemfire-repository" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attributeGroup ref="gemfire-repository-attributes"/>
|
||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||
</xsd:extension>
|
||||
@@ -31,31 +28,21 @@ targetNamespace="http://www.springframework.org/schema/data/gemfire" elementForm
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<!-- -->
|
||||
<xsd:complexType name="gemfire-repository">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="repository:repository">
|
||||
<xsd:attributeGroup ref="gemfire-repository-attributes"/>
|
||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:attributeGroup name="gemfire-repository-attributes">
|
||||
<xsd:attribute name="gemfire-template-ref" type="gemfireTemplateRef" default="gemfireTemplate">
|
||||
<xsd:attribute name="mapping-context-ref" type="mappingContextRef">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The reference to a GemfireTemplate.
|
||||
Will default to 'gemfireTemplate'.
|
||||
The reference to a MappingContext. If not set a default one will be created.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:attributeGroup>
|
||||
<!-- -->
|
||||
<xsd:simpleType name="gemfireTemplateRef">
|
||||
<xsd:simpleType name="mappingContextRef">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:assignable-to type="org.springframework.data.gemfire.GemfireTemplate"/>
|
||||
<tool:assignable-to type="org.springframework.data.gemfire.GemfireMappingContext"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
|
||||
@@ -2818,7 +2818,7 @@ THREAD:Indicates that events will be parallelized based on the event's originati
|
||||
use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
|
||||
Specifies the number of parallel threads
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -2832,4 +2832,4 @@ Deprecated as of Gemfire 7
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<!-- End Gemfire 6 WAN Gateway schema -->
|
||||
</xsd:schema>
|
||||
</xsd:schema>
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.config;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.LocalRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.repository.sample.Person;
|
||||
import org.springframework.data.gemfire.repository.sample.PersonRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* Integration test for {@link GemfireRepositoriesRegistrar} (annotation based
|
||||
* repository configuration).
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class GemfireRepositoriesRegistrarIntegrationTest {
|
||||
|
||||
@Configuration
|
||||
@EnableGemfireRepositories("org.springframework.data.gemfire.repository.sample")
|
||||
static class Config {
|
||||
|
||||
@Bean
|
||||
public GemFireCache cache() throws Exception {
|
||||
|
||||
CacheFactoryBean factory = new CacheFactoryBean();
|
||||
factory.afterPropertiesSet();
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Region<Long, Person> simple() throws Exception {
|
||||
|
||||
LocalRegionFactoryBean<Long, Person> factory = new LocalRegionFactoryBean<Long, Person>();
|
||||
factory.setCache(cache());
|
||||
factory.setName("simple");
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
return factory.getObject();
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
PersonRepository repository;
|
||||
|
||||
@Test
|
||||
public void bootstrapsRepositoriesCorrectly() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire-1.2.xsd">
|
||||
|
||||
<gfe:repositories base-package="org.springframework.data.gemfire.repository.sample" />
|
||||
<gfe-data:repositories base-package="org.springframework.data.gemfire.repository.sample" />
|
||||
|
||||
<gfe:cache use-bean-factory-locator="false" />
|
||||
<gfe:partitioned-region id="simple" />
|
||||
|
||||
<gfe:partitioned-region id="simple" />
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user