diff --git a/build.gradle b/build.gradle index 6f93099c..8c0bcf3c 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/docs/src/info/changelog.txt b/docs/src/info/changelog.txt index 4c582513..1756f71d 100644 --- a/docs/src/info/changelog.txt +++ b/docs/src/info/changelog.txt @@ -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) --------------------------------------------- diff --git a/gradle.properties b/gradle.properties index fcff683b..85b98c0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index bb9ff271..9b4c2f5e 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -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; diff --git a/src/main/java/org/springframework/data/gemfire/config/GemfireDataNamespaceHandler.java b/src/main/java/org/springframework/data/gemfire/config/GemfireDataNamespaceHandler.java index e857c8d1..23c04674 100644 --- a/src/main/java/org/springframework/data/gemfire/config/GemfireDataNamespaceHandler.java +++ b/src/main/java/org/springframework/data/gemfire/config/GemfireDataNamespaceHandler.java @@ -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)); } } \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java b/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java new file mode 100644 index 00000000..e1b227dc --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java @@ -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 ""; +} \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrar.java b/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrar.java new file mode 100644 index 00000000..72cca049 --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrar.java @@ -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 getAnnotation() { + return EnableGemfireRepositories.class; + } + + /* + * (non-Javadoc) + * + * @see org.springframework.data.repository.config. + * RepositoryBeanDefinitionRegistrarSupport#getExtension() + */ + @Override + protected RepositoryConfigurationExtension getExtension() { + return new GemfireRepositoryConfigurationExtension(); + } +} \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryConfigurationExtension.java new file mode 100644 index 00000000..8b35a19b --- /dev/null +++ b/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryConfigurationExtension.java @@ -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); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryParser.java b/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryParser.java deleted file mode 100644 index 7b6c40dd..00000000 --- a/src/main/java/org/springframework/data/gemfire/repository/config/GemfireRepositoryParser.java +++ /dev/null @@ -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 { - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.AbstractRepositoryConfigDefinitionParser#getGlobalRepositoryConfigInformation(org.w3c.dom.Element) - */ - @Override - protected SimpleGemfireRepositoryConfiguration getGlobalRepositoryConfigInformation(Element element) { - return new SimpleGemfireRepositoryConfiguration(element); - } -} diff --git a/src/main/java/org/springframework/data/gemfire/repository/config/SimpleGemfireRepositoryConfiguration.java b/src/main/java/org/springframework/data/gemfire/repository/config/SimpleGemfireRepositoryConfiguration.java deleted file mode 100644 index afa04ff7..00000000 --- a/src/main/java/org/springframework/data/gemfire/repository/config/SimpleGemfireRepositoryConfiguration.java +++ /dev/null @@ -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 { - - 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 { - - String getGemfireTemplateRef(); - } - - static class ManualGemfireRepositoryConfiguration extends - ManualRepositoryConfigInformation 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 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(); - } - } -} \ No newline at end of file diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd index 65131ef5..3b6cabcc 100644 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-data-gemfire-1.2.xsd @@ -21,9 +21,6 @@ targetNamespace="http://www.springframework.org/schema/data/gemfire" elementForm - - - @@ -31,31 +28,21 @@ targetNamespace="http://www.springframework.org/schema/data/gemfire" elementForm - - - - - - - - - - + - The reference to a GemfireTemplate. - Will default to 'gemfireTemplate'. + The reference to a MappingContext. If not set a default one will be created. - + - + diff --git a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd index e301b8ce..cf137950 100755 --- a/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd +++ b/src/main/resources/org/springframework/data/gemfire/config/spring-gemfire-1.2.xsd @@ -2818,7 +2818,7 @@ THREAD:Indicates that events will be parallelized based on the event's originati use="optional"> @@ -2832,4 +2832,4 @@ Deprecated as of Gemfire 7 - + \ No newline at end of file diff --git a/src/test/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrarIntegrationTest.java b/src/test/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrarIntegrationTest.java new file mode 100644 index 00000000..60d6513f --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/repository/config/GemfireRepositoriesRegistrarIntegrationTest.java @@ -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 simple() throws Exception { + + LocalRegionFactoryBean factory = new LocalRegionFactoryBean(); + factory.setCache(cache()); + factory.setName("simple"); + factory.afterPropertiesSet(); + + return factory.getObject(); + } + } + + @Autowired + PersonRepository repository; + + @Test + public void bootstrapsRepositoriesCorrectly() { + + } +} \ No newline at end of file diff --git a/src/test/resources/org/springframework/data/gemfire/repository/config/partitioned-region-repo-context.xml b/src/test/resources/org/springframework/data/gemfire/repository/config/partitioned-region-repo-context.xml index a73d3a42..df12ce2e 100644 --- a/src/test/resources/org/springframework/data/gemfire/repository/config/partitioned-region-repo-context.xml +++ b/src/test/resources/org/springframework/data/gemfire/repository/config/partitioned-region-repo-context.xml @@ -1,14 +1,15 @@ + 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"> - + - - +