From 5bf6e2f15a814cc9bb4e20141de2ce4e3e0577b7 Mon Sep 17 00:00:00 2001 From: David Turanski Date: Sun, 5 Aug 2012 14:07:28 -0400 Subject: [PATCH] Updating docs in progress and changed default bean names to camelCase --- docs/src/info/changelog.txt | 5 +- docs/src/info/readme.txt | 15 +- docs/src/reference/docbook/index.xml | 15 +- .../docbook/introduction/introduction.xml | 8 +- .../docbook/introduction/new-features.xml | 46 ++ .../docbook/introduction/requirements.xml | 6 +- docs/src/reference/docbook/preface.xml | 13 +- .../reference/docbook/reference/bootstrap.xml | 557 +++++++++++++----- .../docbook/reference/cq-container.xml | 2 +- docs/src/reference/docbook/reference/data.xml | 2 +- .../docbook/reference/introduction.xml | 19 +- .../data/gemfire/CacheFactoryBean.java | 78 ++- .../data/gemfire/DiskStoreFactoryBean.java | 6 +- .../gemfire/config/AbstractRegionParser.java | 2 +- .../gemfire/config/AsyncEventQueueParser.java | 2 +- .../data/gemfire/config/CacheParser.java | 6 +- .../gemfire/config/CacheServerParser.java | 4 +- .../gemfire/config/ClientRegionParser.java | 2 +- .../data/gemfire/config/DiskStoreParser.java | 1 + .../gemfire/config/FunctionServiceParser.java | 2 +- .../data/gemfire/config/GatewayHubParser.java | 2 +- .../gemfire/config/GatewayReceiverParser.java | 2 +- .../gemfire/config/GatewaySenderParser.java | 2 +- .../gemfire/config/LookupRegionParser.java | 2 +- .../data/gemfire/config/PoolParser.java | 4 +- .../config/TransactionManagerParser.java | 6 +- .../mapping/GemfirePropertyValueProvider.java | 3 +- .../gemfire/mapping/MappingPdxSerializer.java | 25 +- .../StringBasedGemfireRepositoryQuery.java | 12 +- .../data/gemfire/support/GemfireCache.java | 3 +- .../gemfire/support/GemfireCacheManager.java | 26 +- .../data/gemfire/wan/package-info.java | 5 + .../config/spring-data-gemfire-1.2.xsd | 2 - .../gemfire/config/spring-gemfire-1.2.xsd | 40 +- .../data/gemfire/SubRegionTest.java | 1 + .../gemfire/config/CacheNamespaceTest.java | 5 +- .../config/ClientRegionNamespaceTest.java | 18 + ...DiskStoreAndEvictionRegionParsingTest.java | 13 +- .../config/DynamicRegionNamespaceTest.java | 2 +- .../config/GemfireV6GatewayNamespaceTest.java | 2 +- .../config/GemfireV7GatewayNamespaceTest.java | 16 + .../gemfire/config/IndexNamespaceTest.java | 2 +- .../data/gemfire/config/JndiBindingsTest.java | 2 +- .../gemfire/config/PoolNamespaceTest.java | 7 +- .../gemfire/config/TxEventHandlersTest.java | 2 +- .../config/TxManagerNamespaceTest.java | 5 +- .../adapter/ContainerXmlSetupTest.java | 2 +- .../MappingPdxSerializerIntegrationTest.java | 33 +- .../AbstractRegionFactoryBeanTest.java | 18 +- src/test/resources/log4j.properties | 2 +- .../data/gemfire/basic-region.xml | 2 +- .../data/gemfire/client/client-cache.xml | 13 +- .../data/gemfire/config/tx-ns.xml | 2 +- .../data/gemfire/listener/container.xml | 2 +- 54 files changed, 763 insertions(+), 311 deletions(-) create mode 100644 docs/src/reference/docbook/introduction/new-features.xml create mode 100644 src/main/java/org/springframework/data/gemfire/wan/package-info.java diff --git a/docs/src/info/changelog.txt b/docs/src/info/changelog.txt index 1756f71d..b9cc40c3 100644 --- a/docs/src/info/changelog.txt +++ b/docs/src/info/changelog.txt @@ -1,13 +1,16 @@ SPRING DATA GEMFIRE CHANGELOG ============================= http://www.springsource.org/spring-gemfire + Changes in version 1.2.0.RELEASE (2012-08-15) --------------------------------------------- General +* The Spring Data GemFire project, formerly Spring GemFire, is now a component of the Spring Data project * 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 +* The XML namespace supports everything that can be configured with Cache XML +* A separate namespace for Spring Data Repository support Enhancements * [SGF-53] - Add "enable-gateway" to replicated and partitioned region namespace config diff --git a/docs/src/info/readme.txt b/docs/src/info/readme.txt index 2a0429e4..75bdc995 100644 --- a/docs/src/info/readme.txt +++ b/docs/src/info/readme.txt @@ -4,9 +4,9 @@ http://www.springsource.org/spring-gemfire 1. INTRODUCTION -Spring GemFire Integration is a top-level Spring project who's purpose is -to make it easier to build Spring-powered highly scalable applications using -GemFire as distributed data management platform. +Spring Data GemFire started as a top level Spring project, formerly known as Spring GemFire, +and is now a component of the Spring Data project. The project's purpose is to make it easier to +build Spring-powered highly scalable applications using vFabric GemFire as distributed data management platform. 2. RELEASE NOTES @@ -15,14 +15,13 @@ details, consult the provided javadoc for specific packages and classes. 3. DISTRIBUTION JAR FILES -The Spring GemFire jars files can be found in the 'dist' directory. +The Spring Data GemFire jars files can be found in the 'dist' directory. 4. GETTING STARTED -Please see the reference documentation and the sample application (hello-world). -Additionally the blog at http://blog.springsource.com as well -as sections of interest in the reference documentation. +Please see the reference documentation at http://www.springsource.org/spring-gemfire/ +and the Spring GemFire Examples at https://github.com/SpringSource/spring-gemfire-examples ADDITIONAL RESOURCES Spring GemFire Homepage : http://www.springsource.org/spring-gemfire -GemStone Gemfire Homepage: http://www.gemstone.com/products/gemfire \ No newline at end of file +VMWare vFabric GemFire Homepage: http://www.vmware.com/products/application-platform/vfabric-gemfire/overview.html \ No newline at end of file diff --git a/docs/src/reference/docbook/index.xml b/docs/src/reference/docbook/index.xml index f0182cb1..8e693278 100644 --- a/docs/src/reference/docbook/index.xml +++ b/docs/src/reference/docbook/index.xml @@ -4,11 +4,10 @@ xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink"> - Spring Gemfire Integration Reference Guide + Spring Data Gemfire Reference Guide ${version} - Spring GemFire ${version} - Spring GemFire - + Spring Data GemFire ${version} + Spring Data GemFire @@ -35,6 +34,13 @@ copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. + + + + As of the 1.2.0 release, this project, formerly known as Spring GemFire, has been renamed to Spring Data GemFire to reflect that + it is now a component of the Spring Data project. + + @@ -45,6 +51,7 @@ + diff --git a/docs/src/reference/docbook/introduction/introduction.xml b/docs/src/reference/docbook/introduction/introduction.xml index 1e9b6966..8bec52b3 100644 --- a/docs/src/reference/docbook/introduction/introduction.xml +++ b/docs/src/reference/docbook/introduction/introduction.xml @@ -1,10 +1,8 @@ - - This document is the reference guide for Spring GemFire project (SGF). It explains the relationship - between Spring framework and GemFire Enterprise Fabric (GEF) 6.0.x, defines the basic concepts and semantics of the integration - and how these can be used effectively. + This document is the reference guide for Spring Data GemFire project (SGF). It explains the relationship + between Spring framework and vFabric GemFire + and defines the basic concepts, semantics, and effect use of Spring's support for GemFire. - \ No newline at end of file diff --git a/docs/src/reference/docbook/introduction/new-features.xml b/docs/src/reference/docbook/introduction/new-features.xml new file mode 100644 index 00000000..a070aaec --- /dev/null +++ b/docs/src/reference/docbook/introduction/new-features.xml @@ -0,0 +1,46 @@ + +New Features + + +As of the 1.2.0 release, this project, formerly known as Spring GemFire, has been renamed to Spring Data GemFire to reflect that +it is now a component of the Spring Data project. + + +
+New in the 1.2.0 Release + + +Full support for GemFire configuration via gfe namespace. Now GemFire components may be configured completely without requiring a native cache.xml file. + + + +WAN Gateway support for both GemFire 6.6.x and GemFire 7.0 + + + +Spring Data Repository support with a dedicated namespace: gfe-data + + + +Namespace support for registering GemFire functions + + + + +A top level <disk-store> element has been added to the gfe namespace to allow sharing of persist stores among regions, +and other components that support persistent backup. +The <*-region> elements no longer allow a nested <disk-store> + + + + +GemFire subregions are supported via nested <*-region> elements + + + + A <local-region> element has been added to configure a local region + + + +
+
\ No newline at end of file diff --git a/docs/src/reference/docbook/introduction/requirements.xml b/docs/src/reference/docbook/introduction/requirements.xml index 5998fed1..e5e22e49 100644 --- a/docs/src/reference/docbook/introduction/requirements.xml +++ b/docs/src/reference/docbook/introduction/requirements.xml @@ -1,8 +1,8 @@ Requirements - Spring GemFire integration requires JDK level 5.0 and above, Spring - Framework 3 and - GemFire 6.5 and above. + Spring Data GemFire requires JDK level 5.0 and above, Spring + Framework 3 and + vFabric GemFire 6.6 and above. \ No newline at end of file diff --git a/docs/src/reference/docbook/preface.xml b/docs/src/reference/docbook/preface.xml index a99572f2..67818662 100644 --- a/docs/src/reference/docbook/preface.xml +++ b/docs/src/reference/docbook/preface.xml @@ -2,18 +2,17 @@ Preface - Spring GemFire Integration focuses on integrating Spring Framework's powerful, non-invasive programming model - and concepts with Gemstone's GemFire Enterprise Fabric, providing easier configuration, use and high-level abstractions. - This document assumes the reader already has a basic familiarity with the Spring Framework and GemFire concepts - and APIs. + Spring Data GemFire focuses on integrating Spring Framework's powerful, non-invasive programming model + and concepts with vFabric GemFire, simplifying configuration, development and providing high-level abstractions. + This document assumes the reader already has a basic familiarity with the Spring Framework and vFabric GemFire + concepts and APIs. While every effort has been made to ensure that this documentation is comprehensive and there are no errors, - nevertheless some topics might require more explanation and some typos might have crept in. If you do spot any + some topics might require more explanation and some typos might have crept in. If you do spot any mistakes or even more serious errors and you can spare a few cycles during lunch, please do bring the error - to the attention of the Spring GemFire Integration team by raising an + to the attention of the Spring Data GemFire team by raising an issue. Thank you. - diff --git a/docs/src/reference/docbook/reference/bootstrap.xml b/docs/src/reference/docbook/reference/bootstrap.xml index 80a3fca1..233c3769 100644 --- a/docs/src/reference/docbook/reference/bootstrap.xml +++ b/docs/src/reference/docbook/reference/bootstrap.xml @@ -1,24 +1,26 @@ - Bootstrapping GemFire through the Spring container + Bootstrapping GemFire through the Spring Container - One of the first tasks when using GemFire and Spring is to configure - the data grid through the IoC container. While this is possible - out of the box, the configuration tends to be verbose and only address basic - cases. To address this problem, the Spring GemFire project provides several - classes that enable the configuration of distributed caches or regions to + Spring Data GemFire provides full configuration and initialization of the GemFire + data grid through Spring's IoC container. Spring Data GemFire provides several + classes that simplify the configuration of GemFire components including caches, regions, WAN gateways, persistence backup, and other distributed system components to support a variety of scenarios with minimal effort.
- Using the Spring GemFire Namespace + Using the Core Spring Data GemFire Namespace - To simplify configuration, SGF provides a dedicated namespace for most of its components. However, one can opt to configure the beans - directly through the usual <bean> definition. For more information about XML Schema-based configuration in Spring, see - this appendix in the + To simplify configuration, Spring Data Gemfire provides a dedicated namespace for configuring core GemFire components. + It is also possible to configure the beans directly through Springs usual <bean> definition. However, as of Spring Data GemFire 1.2.0, the namespace provides full + support and is much easier to use. For more information about XML Schema-based configuration in Spring, see + this appendix in the Spring Framework reference documentation. - To use the SGF namespace, one just needs to import it inside the configuration: + + Spring Data Repository support uses a separate dedicated namespace. See for more information on how to configure GemFire Repositories. + + + To use the Spring Data GemFire namespace, simply declare it in your Spring XML configuration: - Once declared, the namespace elements can be declared simply by appending the aforementioned prefix. Note that is possible to change the default namespace, - for example from <beans> to <gfe>. This is useful for configuration composed mainly of GemFire components as + Once declared, the namespace elements can be declared simply by appending the aforementioned prefix. + It is possible to change the default namespace, + for example from beans to gfe. This is useful for configuration composed mainly of GemFire components as it avoids declaring the prefix. To achieve this, simply swap the namespace prefix declaration above: + ]]> - The default namespace declaration for this XML file points to the Spring GemFire namespace. + The default namespace declaration for this XML file points to the Spring Data GemFire namespace. The beans namespace prefix declaration. - Bean declaration using the <beans> namespace. Notice the prefix. + Bean declaration using the beans namespace. Notice the prefix. - Bean declaration using the <gfe> namespace. Notice the lack of prefix (as the default namespace is used). + Bean declaration using the gfe namespace. Notice the lack of prefix (as the default namespace is used). - - For the remainder of this doc, to improve readability, the XML examples will simply refer to the <gfe> namespace - without the namespace declaration, where possible. +
- Configuring the GemFire - <interfacename>Cache</interfacename> + Configuring the GemFire Cache - In order to use the GemFire Fabric, one needs to either create a new - Cache or connect to an existing one. As in + In order to use GemFire, one needs to either create a new + Cache or connect to an existing one. In the current version of GemFire, there can be only one opened cache per VM - (or classloader to be technically correct). In most cases the cache is - created once and then all other consumers connect to it. + (or per classloader to be technically correct). In most cases the cache is created once. + - In its simplest form, a cache can be defined in one line: + A cache with default configuration can be created with a very simple declaration: - ]]> + ]]> - The declaration above declares a bean(CacheFactoryBean) - for the GemFire Cache, named gemfire-cache. All the other SGF components use this - naming convention if no name is specified, allowing for very concise configurations. The definition above will try to connect to - an existing cache and, in case one does not exist, create it. Since no - additional properties were specified the created cache uses the default - cache configuration.Especially in environments with opened caches, this basic - configuration can go a long way. - - For scenarios where the cache needs to be - configured, the user can pass in a reference the GemFire configuration - file: + + A Spring application context containing this definition will, upon initialization, will register a CacheFactoryBean + to create a Spring bean named gemfireCache referencing a GemFire Cache instance. + This will be either an existing cache, or if one does not exist, a newly created one. Since no additional properties were specified, a newly created + cache will apply the default cache configuration. + + + All Spring Data GemFire components which depend on + the Cache respect this naming convention so that there is no need to explicitly declare the Cache dependency. If you prefer, you can make the dependence explicit via the + cache-ref attribute provided by various namespace elements. Also you can easily override the Cache's bean name: + + ]]> + + + Starting with Spring Data GemFire 1.2.0, The GemFire Cache may be fully configured using Spring. However, GemFire's native XML + configuration file (e.g., cache.xml) is also supported. For scenarios in which the GemFire cache needs to be + configured natively, simply provide a reference the GemFire configuration + file using the cache-xml-location attribute: ]]> In this example, if the cache needs to be created, it will use the file named cache.xml located in the classpath root. - Only if the cache is created will the configuration file be used. + Note that the configuration makes use of Spring's Resource + url="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/resources.html">Resource abstraction to locate the file. This allows various search patterns to - be used, depending on the running environment or the prefix specified - (if any) by the value. + be used, depending on the runtime environment or the prefix specified + (if any) in the resource location. In addition to referencing an external configuration file one can - specify GemFire settings directly through Java - Properties. This can be quite handy when just a few - settings need to be changed. - - To setup properties one can either use the properties element inside the util namespace - to declare or load properties files (the latter is recommended for externalizing environment specific settings outside the application - configuration): + specify GemFire properties + using one of Spring's common properties configuration methods. For example, one can use the properties element defined in the util namespace + to define properties directly or load properties files. The latter is recommended for externalizing environment specific settings outside the application configuration: - + - + ]]> + + + + The cache settings apply only if a new cache needs to be created. If an open cache already exists in the JVM, these settings will + be ignored. + + - Or can use fallback to a raw <beans> declaration: +
Advanced Cache Configuration + For advanced cache configuration, the cache element provides several attributes and child elements: + + ]]> + ]]> + + + ]]> + + + ]]> + ]]> + + ]]> + - <bean id="cache-with-props" class="org.springframework.data.gemfire.CacheFactoryBean"> - <property name="properties"> - <props> - <prop key="bind-address">127.0.0.1</prop> - </props> - </property> -</bean> - - In this last example, the SGF classes are declared and configured directly without relying on the namespace. As one can tell, - this approach is a generic one, exposing more of the backing infrastructure. - - It is worth pointing out again, that the cache settings apply only - if the cache needs to be created, there is no opened cache in existence - otherwise the existing cache will be used and the configuration will - simply be discarded. + + + Various cache options are provided via these attributes. For a detailed explanation of any of these attributes, please consult + the GemFire product documentation + + + An example of a TransactionListener declaration using a bean reference. The referenced bean must implement + TransactionListener. + For a detailed explanation of the functionality provided by this + and any of the following elements, please consult the GemFire product documentation + + + An example of a TransactionWriter declaration using an inner bean declaration this time. The bean must implement + TransactionWriter + + com.gemstone.gemfire.cache.util.GatewayConflictResolver + An example of a GatewayConflictResolver declaration. The bean must implement + com.gemstone.gemfire.cache.util.GatewayConflictResolver. This requires GemFire 7.0 + + + Enable GemFire's DynamicRegionFactory + + + Declares a JNDI binding to enlist an extenal datasource in a GemFire transaction + + +
- Configuring a GemFire <literal>CacheServer</literal> + Configuring a GemFire Cache Server - In Spring GemFire 1.1 dedicated support for configuring a - CacheServer was added through - the org.springframework.data.gemfire.server package allowing complete configuration through the Spring container: + In Spring Data GemFire 1.1 dedicated support for configuring a + CacheServer was added, + allowing complete configuration through the Spring container: + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> @@ -196,99 +243,87 @@ - + ]]> - The configuration above shows the dedicated namespace support (through the cache-server element) and the pleothera of options available. Note that rather - then just hard-coding the port, this config uses Spring util namespace - to read it from a properties file and then replace it at runtime allowing administrators to change it without having to touch the main application config. Through Spring's property placeholder - support, - SpEL and the environment abstraction one - can externalize environment specific properties from the main code base easing the deployment across multiple machines. + The configuration above illustrates the cache-server element and the many options available. - To avoid initialization problems, the CacheServers started by SGF will start after the container has been fully initialized. This + Rather than hard-coding the port, this configuration uses Spring context + namespace to declare a property-placeholder. The property placeholder + reads one or more properties file and then replaces property placeholders with values at runtime. This allows administrators to change such values without having to touch the main application configuration. Spring + also provides + SpEL and the environment abstraction one + to support externalization of environment specific properties from the main code base, easing the deployment across multiple machines. + + + To avoid initialization problems, the CacheServers started by Spring Data GemFire will start after the container has been fully initialized. This allows potential regions, listener, writers or instantiators defined declaratively to be fully initialized and registered before the server starts accepting connections. Keep this in mind when doing programmatic configuration of the items above as the server might start before your components and thus not be seen by the clients connecting right away.
- Configuring a GemFire <literal>ClientCache</literal> + Configuring a GemFire Client Cache - Another configuration addition in SGF 1.1 is the dedicated support for configuring - ClientCache - - similar to a cache (in both usage and definition) - through the org.springframework.data.gemfire.client package and in particular - ClientCacheFactoryBean. + Another configuration addition in Spring Data GemFire 1.1 is the dedicated support for configuring + ClientCache. + This is similar to a cache in both usage and definition and supported by the + the ClientCacheFactoryBean in the org.springframework.data.gemfire.client package. - - - - - + + ]]> - client-cache supports much of the same options as the cache element. However as oppose to a vanilla cache, - a client cache connects to a server through a pool (by default a pool is created to connect to a server on localhost and 40404 - - the default pool is used by all client cache regions (unless configured to use a different pool)). + client-cache supports much of the same options as the cache element. However as opposed to a full cache, + a client cache connects to a remote cache server through a pool. By default a pool is created to connect to a server on localhost port 40404. The + the default pool is used by all client regions unless the region is configured to use a different pool. - Pools can be defined through the pool; in case of client caches and regions pools can be used to customize the connectivity to the server for - individual entities or for the entire cache. For example, to custommize the default pool used by client-cache, one needs to define a pool and wire it to cache definition: + Pools can be defined through the pool element; The client side pools can be used to configure connectivity to the server for + individual entities or for the entire cache. For example, to customize the default pool used by client-cache, one needs to define a pool and wire it to cache definition: - - - + + - + - ]]>
- Configuring a GemFire <interfacename>Region</interfacename> + Configuring a GemFire Region - Once the Cache is configured, one - needs to configure one or more Regions to - interact with the data fabric. SGF allows various region types to be configured and created directly from Spring or - in case they are created directly in GemFire, retrieved as such. + Once the Cache is configured, one needs to configure one or more Regions to + access cached data. Spring Data GemFire allows regions to be configured and created directly in Spring or, + if they are already created natively in GemFire, registered in the Spring context. For more information about the various region types and their capabilities as well as configuration options, please - refer to the GemFire Developer's Guide and community - site. + refer to the GemFire Developer's Guide and community + site.
- Using an externaly configured <interfacename>Region</interfacename> + Using an externaly configured Region - For consuming but not creating Regions (for example in case, - the regions are already configured through GemFire native configuration, the cache.xml), - one can use the lookup-region element. Simply declare the target region name the + For referencing Regions already configured through GemFire native configuration, e.g., a cache.xml file, + use the lookup-region element. Simply declare the target region name with the name attribute; for example to declare a bean definition, named region-bean for an existing region named orders one can use the following definition: ]]> - If the name is not specified, the bean name will be used automatically. The example above + If the name is not specified, the bean's id will be used. The example above becomes: ]]> - If the region does not exist, an initialization exception will be thrown. For configuring new GemFire regions - proceed to the sections below for replicated, partitioned, client or advanced region configuration. + If the region does not exist, an initialization exception will be thrown. For configuring new GemFire regions, + proceed to the appropriate sections below. - Note that in the previous examples, since no cache name was defined, the default SGF naming convention (gemfire-cache) - was used. If that is not an option, one can point to the cache bean through the cache-ref attribute: + Note that in the previous examples, since no cache name was defined, the default naming convention (gemfireCache) + was used. If that is not an option, one can reference the cache bean through the cache-ref attribute: @@ -298,6 +333,208 @@ The lookup-region provides a simple way of retrieving existing, pre-configured regions without exposing the region semantics or setup infrastructure.
+ +
+ Configuring Regions + Spring Data GemFire provides comprehensive support for configuring any type of Region GemFire provides. Currently these include: + + Local Region <local-region> - The region is only visible to the defining member + Replicated Region <replicated-region> - Holds all data from the distributed region + Partitioned Region <partitioned-region> - Data is divided into buckets across members + Client Region <client-region> - A local region used with a client cache + + For a comprehensive description of region types please + consult the GemFire product documentation. + + +
+ Common Region Attributes + The following table(s) list attributes available for all region types: + + Common Region Attributes + + + + + + + Name + Values + Description + + + + + + cache-ref + GemFire cache bean name + The name of the bean defining the GemFire cache (by default 'gemfireCache'). + + + close + boolean, default:true + Indicates whether the region should be closed at shutdown + + + data-policy + See GemFire's Data Policy + The region's data policy. Note not all data policies are supported for every region type + + + destroy + boolean, default:false + Indicates whether the region should be destroyed at shutdown + + + disk-store-ref + The name of a configured disk store + A reference to a bean created via the disk-store element. Note: This will automatically enable persistence. If persistent is explicitly set to false, an exception will be thrown. + + + disk-synchronous + boolean, default:false + Indicates whether disk store writes are synchronous. Note: This will automatically enable persistence. If persistent is explicitly set to false, an exception will be thrown. + + + enable-gateway + boolean, default:false + Indicates whether the region will synchronize entries over a WAN gateway. Note: This is deprecated in GemFire 7.0 + + + hub-id + The name of the Gateway Hub + Note: This is deprecated in GemFire 7.0. Also this will automatically set enable-gateway to true. If enable-gateway is explicitly set to false, an exception will be thrown. + + + id + any valid bean name + Will also be the region name by default + + + ignore-jta + boolean, default:false + Indicates whether the region participates in JTA transactions + + + index-update-type + synchronous or asynchronous, default:asynchronous + Indicates whether indices will be updated synchronously or asynchronously on entry creation + + + initial-capacity + integer, default:16 + The initial memory allocation for number of entries + + + key-constraint + any valid java class name + The expected key type + + + name + any valid region name + The name of the region definition. If no specified, it will assume the value of the id attribute (the bean name). + + + persistent + boolean, default:false + Indicates whether the region persists entries to a disk store + + + statistics + boolean, default:false + Indicates whether the region reports statistics + + + value-constraint + any valid java class name + The expected value type + + + +
+
+
+
+ Cache Listeners + Cache Listeners are registered with a region to handle region events such as entries being created, updated, destroyed, etc. A Cache Listener can be any bean that + implements the CacheListener + interface. A region may have multiple listeners, declared using the cache-listener element enclosed in a *-region element. + In the example below, there are two CacheListeners declared. The first references a top level named Spring bean; the second is an + anonymous inner bean definition. + + + + + + + + + + + ]]> + + +The following example uses an alternate form of the cache-listener element with a ref attribute. This allows for more concise configuration +for a single cache listener. Note that the namespace only allows a single cache-listener element so either the style above or below must be used. + Using ref and a nested declaration in a cache-listener, or similar element, +is illegal. The two options are mutually exclusive and using both on the same element will result in an exception. + + + + + + + + ]]> + + + + Note:Bean Reference Conventions + The cache-listener element is an example of a common pattern used in the namespace anywhere GemFire provides an interface that may be + implemented to invoke custom Java code. In order to simplify the configuration, a single occurance of the element is all that is required, + but may contain nested bean references and inner bean definitions in any combination if multiple instances are permitted. + The element name always takes the singular form (i.e., cache-listener vs cache-listeners) because it is assumed that + the most common scenario will in fact be a single instance. + We have already seen some examples of this pattern in the advanced cache configuration example. + + +
+ +
+ Cache Loaders and Cache Writers + Similar to cache-listener, the namespace provides cache-loader and cache-writer elements to register these + respective components for a region. A CacheLoader is invoked on a cache miss to allow an entry to be loaded from an external source, a database + for example. A CacheWriter is invoked afer an entry is created or updated,intended for synchronizing to an external data source. + The difference is GemFire only supports at most a single instance of each for each region. However, either declaration style may be + used. See CacheLoader and + CacheWriter for more details. +
+ +
+ Subregions + In Release 1.2.0, Spring Data GemFire added support for subregions, allowing regions to be arranged in a hierarchical relationship. For example, GemFire allows for + a /Customer/Address region and a different /Employee/Address region. Additionally, a subregion may have it's own subregions + and its own configuration. A subregion does not inherit attributes from the parent region. Regions types may be mixed and matched subject to GemFire constraints. + A subregion is naturally declared as a child element of a region. A subregion's name attribute is the simple name. The above example might be configured as: + + + + + + + + + + +]]> + + The subregions will be created with bean names /Customer/Address and /Employee/Address, respectively. So they may be referenced + directly by other beans that use them, such as GemfireTemplate. + +
+
Replicated Region @@ -310,21 +547,23 @@ in which it discovers other replicas and automatically copies all the entries. While one replica is initializing you can still continue to use the other replicas. - SGF offers a dedicated element for creating replicas in the form of replicated-region element. A minimal declaration looks as follows - (again, the example will not setup the cache wiring, relying on the SGF namespace naming conventions): + Spring Data GemFire offers a dedicated element for creating replicas in the form of replicated-region element. A minimal declaration looks as follows + (again, the example relies on the Spring Data GemFire namespace naming conventions to wire the cache): ]]> - Here, a replicated region is created (if one doesn't exist already). The name of the region is the same as the bean name (simple-replica) and - the bean assumes the existence of a GemFire cache named gemfire-cache. + Here, a replicated region is created (if one doesn't exist already). The name of the region is the same as the bean id (simple-replica) and + the bean assumes the existence of a GemFire cache named gemfireCache. - When setting a region, it's fairly common to associate various CacheLoaders, CacheListeners and + When setting up a region, it is fairly common to associate various CacheLoaders, CacheListeners and CacheWriters with it. These components can be either referrenced or declared inlined by the region declaration. - Following the GemFire recommandations, the namespace allows for each region created multiple listeners but only one - cache writer and cache loader. This restriction can be relaxed, for advanced usages by using the beans declaration (see the next section). - + Following the GemFire API, the namespace allows multiple cache listeners but only one + cache writer and cache loader for each region. + + + Below is an example, showing both styles: @@ -341,8 +580,8 @@ ]]> - Using ref and a nested declaration on cache-listener, cache-loader or cache-writer - is illegal. The two options are mutually exclusive and using them at the same time, on the same element will throw an exception. + Using ref and a nested declaration on cache-listener, cache-loader or cache-writer + is illegal. The two options are mutually exclusive and using both on the same element will result in an exception.
<literal>replicated-region</literal> Options @@ -350,7 +589,7 @@ The following table offers a quick overview of the most important configuration options names, possible values and short descriptions for each of settings supported by the replicated-region element. Please see the storage and eviction section for the relevant configuration. - +
<![CDATA[replicated-region]]> options @@ -377,7 +616,7 @@ cache-ref GemFire cache bean name - The name of the bean defining the GemFire cache (by default 'gemfire-cache'). + The name of the bean defining the GemFire cache (by default 'gemfireCache'). cache-listener @@ -404,7 +643,7 @@
Partition(ed) Region - Another region type supported out of the box by the SGF namespace, is the partitioned region. To quote again the GemFire docs: + Another region type supported out of the box by the Spring Data GemFire namespace, is the partitioned region. To quote again the GemFire docs: What is a partition? A partitioned region is a region where data is divided between peer servers hosting the region so that each peer stores a subset of the data. @@ -413,7 +652,7 @@ GemFire divides the domain of hashcodes into buckets. Each bucket is assigned to a specific peer, but may be relocated at any time to another peer in order to improve the utilization of resources across the cluster. - A partition can be created by SGF through the partitioned-region element. Its configuration options are similar to that of the + A partition can be created by Spring Data GemFire through the partitioned-region element. Its configuration options are similar to that of the replicated-region plus the partion specific features such as the number of redundant copies, total maximum memory, number of buckets, partition resolver and so on. Below is a quick example on setting up a partition region with 2 redundant copies: @@ -459,7 +698,7 @@ and a nested resolver declaration --> cache-ref GemFire cache bean name - The name of the bean defining the GemFire cache (by default 'gemfire-cache'). + The name of the bean defining the GemFire cache (by default 'gemfireCache'). @@ -527,7 +766,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages.GemFire supports various deployment topologies for managing and distributing data. The topic is outside the scope of this documentation however to quickly recap, they can be categoried in short in: peer-to-peer (p2p), client-server (or super-peer cache network) and wide area cache network (or WAN). In the last two scenarios, it is common - to declare client regions which connect to a backing cache server (or super peer). SGF offers dedicated support for such configuration through + to declare client regions which connect to a backing cache server (or super peer). Spring Data GemFire offers dedicated support for such configuration through , client-region and pool elements. As the name imply, the former defines a client region while the latter connection pools to be used/shared by the various client regions. @@ -555,12 +794,12 @@ redundancy. Each copy provides extra backup at the expense of extra storages.pool to be specified for connecting to the server. Each client can have its own pool or they can share the same one. - For a full list of options to set on the client and especially on the pool, please refer to the SGF schema () and the GemFire documentation. + For a full list of options to set on the client and especially on the pool, please refer to the Spring Data GemFire schema () and the GemFire documentation.
Client Interests - To minimize network traffic, each client can define its own 'interest', pointing out to GemFire, the data it actually needs. In SGF, interests can be defined for each client, both + To minimize network traffic, each client can define its own 'interest', pointing out to GemFire, the data it actually needs. In Spring Data GemFire, interests can be defined for each client, both key-based and regular-expression-based types being supported; for example: @@ -581,7 +820,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages. Configurating Disk Storage - GemFire can use disk as a secondary storage for persisting regions or/and overflow (known as data pagination or eviction to disk). SGF allows such options to be configured + GemFire can use disk as a secondary storage for persisting regions or/and overflow (known as data pagination or eviction to disk). Spring Data GemFire allows such options to be configured directly from Spring through disk-store element available on both replicated-region and partitioned-region as well as client-region. A disk store defines how that particular region can use the disk and how much space it has available. Multiple directories can be defined in a disk store such as in our example below: @@ -613,7 +852,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages. - With SGF, to enable persistence, simply set to true the persistent attribute on replicated-region, + With Spring Data GemFire, to enable persistence, simply set to true the persistent attribute on replicated-region, partitioned-region or client-region: ]]> @@ -631,7 +870,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages.LRU). Evicted entries are either destroyed or paged to disk (also known as overflow). - SGF supports all eviction policies (entry count, memory and heap usage) for both partitioned-region and replicated-region + Spring Data GemFire supports all eviction policies (entry count, memory and heap usage) for both partitioned-region and replicated-region as well as client-region, through the nested eviction element. For example, to configure a partition to overflow to disk if its size is more then 512 MB, one could use the following configuration: @@ -651,8 +890,8 @@ redundancy. Each copy provides extra backup at the expense of extra storages. Advanced Region Configuration - SGF namespaces allow short and easy configuration of the major GemFire regions and associated entities. However, there might be corner cases where the namespaces are not enough, where - a certain combination or set of attributes needs to be used. For such situations, using directly the SGF FactoryBeans is a possible alternative as it gives + Spring Data GemFire namespaces allow short and easy configuration of the major GemFire regions and associated entities. However, there might be corner cases where the namespaces are not enough, where + a certain combination or set of attributes needs to be used. For such situations, using directly the Spring Data GemFire FactoryBeans is a possible alternative as it gives access to the full set of options at the expense of conciseness. As a warm up, below are some common configurations, declared through raw beans definitions. @@ -714,7 +953,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages. For scenarios where a CacheServer is used and - clients need to be configured and the namespace is not an option, SGF offers a + clients need to be configured and the namespace is not an option, Spring Data GemFire offers a dedicated configuration class named: ClientRegionFactoryBean. This allows client interests to be registered in both key and regex @@ -734,7 +973,7 @@ redundancy. Each copy provides extra backup at the expense of extra storages. Users that need fine control over a region, can configure it in Spring by using the attributes property. To ease declarative configuration in Spring, - SGF provides two FactoryBeans for creating RegionAttributes and PartitionAttributes, + Spring Data GemFire provides two FactoryBeans for creating RegionAttributes and PartitionAttributes, namely RegionAttributesFactory and PartitionAttributesFactory. See below an example of configuring a partitioned region through Spring XML: @@ -755,25 +994,25 @@ redundancy. Each copy provides extra backup at the expense of extra storages. Advantages of using Spring over GemFire <literal>cache.xml</literal> - With SGF, GemFire regions, pools and cache can be configured either through Spring or directly inside GemFire, native, cache.xml file. While both are valid + With Spring Data GemFire, GemFire regions, pools and cache can be configured either through Spring or directly inside GemFire, native, cache.xml file. While both are valid approaches, it's worth pointing out that Spring's powerful DI container and AOP functionality makes it very easy to wire GemFire into an application. For example configuring a region cache loader, listener and writer through the Spring container is preferred since the same instances can be reused across multiple regions and additionally are either to configure due to the presence of the DI and eliminates the need of implementing GemFire's Declarable interface (see on chapter on how you can still use them yet benefit from Spring's DI container). - Whatever route one chooses to go, SGF supports both approaches allowing for easy migrate between them without forcing an upfront decision. + Whatever route one chooses to go, Spring Data GemFire supports both approaches allowing for easy migrate between them without forcing an upfront decision.
Creating Indecies - GemFire allows creation on indices (or indexes) to improve the performance of (common) queries. SGF allows indecies to be declared through the index element: + GemFire allows creation on indices (or indexes) to improve the performance of (common) queries. Spring Data GemFire allows indecies to be declared through the index element: ]]> - Before creating an index, SGF will verify whether one with the same name already exists. If it does, it will compare the properties and if they don't match, will remove the old one to create - a new one. If the properties match, SGF will simply return the index (in case it does not exist it will simply create one). To prevent the update of the index, even if the properties do not match, + Before creating an index, Spring Data GemFire will verify whether one with the same name already exists. If it does, it will compare the properties and if they don't match, will remove the old one to create + a new one. If the properties match, Spring Data GemFire will simply return the index (in case it does not exist it will simply create one). To prevent the update of the index, even if the properties do not match, set the property override to false. diff --git a/docs/src/reference/docbook/reference/cq-container.xml b/docs/src/reference/docbook/reference/cq-container.xml index 63e752b8..33d14484 100644 --- a/docs/src/reference/docbook/reference/cq-container.xml +++ b/docs/src/reference/docbook/reference/cq-container.xml @@ -114,7 +114,7 @@ <!-- and this is the event listener container... --> <bean id="gemfireListenerContainer" class="org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer"> - <property name="cache" ref="gemfire-cache"/> + <property name="cache" ref="gemfireCache"/> <property name="queryListeners"> <!-- set of listeners --> <set> diff --git a/docs/src/reference/docbook/reference/data.xml b/docs/src/reference/docbook/reference/data.xml index 4fbc4017..a7d37c39 100644 --- a/docs/src/reference/docbook/reference/data.xml +++ b/docs/src/reference/docbook/reference/data.xml @@ -116,7 +116,7 @@ <gfe:transaction-manager id="tx-manager" cache-ref="cache"/> The example above can be simplified even more by eliminating the cache-ref attribute if the GemFire cache is defined under the default - name gemfire-cache. As with the other SGF namespace elements, if the cache name is not configured, the aforementioned naming convention will used. + name gemfireCache. As with the other SGF namespace elements, if the cache name is not configured, the aforementioned naming convention will used. Additionally, the transaction manager name, if not specified is gemfire-transaction-manager. or if you prefer bean declarations: diff --git a/docs/src/reference/docbook/reference/introduction.xml b/docs/src/reference/docbook/reference/introduction.xml index 212c464f..6e5eb127 100644 --- a/docs/src/reference/docbook/reference/introduction.xml +++ b/docs/src/reference/docbook/reference/introduction.xml @@ -1,23 +1,28 @@ Document structure - This part of the reference documentation explains the core functionality - offered by Spring GemFire integration. + The following chapters explain the core functionality offered by Spring Data GemFire. describes the configuration support provided for - bootstrapping, initializing and accessing a GemFire cache or region. + bootstrapping, initializing, configuring, and accessing GemFire caches, regions and distributed system components. - explains the integration between GemFire API and - the various "data" features available in Spring, such as transaction management + explains the integration between the GemFire APIs and + the various data access features available in Spring, such as transaction management and exception translation. describes the enhancements for GemFire - (de)serialization process and management of associated objects. + (de)serialization and management of associated objects. + + + describes persistence mapping for POJOs stored in GemFire using Spring Data + + + describes how to create and use GemFire Repositories using Spring Data describes the samples provided with the distribution - for showcasing the various features available in Spring GemFire. + to illustrate the various features available in Spring GemFire. +The name of the cache definition (by default "gemfireCache").]]> +The name of the transaction manager definition (by default "gemfireTransactionManager").]]> + use="optional" default="gemfireCache"> @@ -853,10 +853,10 @@ The id of the region bean definition. + use="optional" default="gemfireCache"> @@ -1500,9 +1500,9 @@ The name of the disk store bean definition. This is also used as the disk store + use="optional" default="gemfireCache"> - + @@ -1748,7 +1748,7 @@ Note that in order to instantiate a pool, a GemFire cache needs to be already st use="optional"> +The name of the pool definition (by default "gemfirePool").]]> - + + use="optional" default="gemfireCache"> - + @@ -1909,10 +1909,10 @@ Container for continuous query listeners. All listeners will be hosted by the sa minOccurs="0" maxOccurs="unbounded" /> + default="gemfireCache"> @@ -2052,10 +2052,10 @@ Indicates whether the index is created even if there is an index with the same n + use="optional" default="gemfireCache"> @@ -2384,7 +2384,7 @@ The id of this bean definition use="optional"> @@ -2461,7 +2461,7 @@ The id of this bean definition. use="optional"> @@ -2486,7 +2486,7 @@ The id of this bean definition. use="optional"> @@ -2629,7 +2629,7 @@ The port for this hub (integer value, if not specified, Gemfire will select an o use="optional"> diff --git a/src/test/java/org/springframework/data/gemfire/SubRegionTest.java b/src/test/java/org/springframework/data/gemfire/SubRegionTest.java index 2d1c0af9..8fdc374a 100644 --- a/src/test/java/org/springframework/data/gemfire/SubRegionTest.java +++ b/src/test/java/org/springframework/data/gemfire/SubRegionTest.java @@ -45,6 +45,7 @@ public class SubRegionTest extends RecreatingContextTest { @SuppressWarnings({ "rawtypes", "unchecked" }) private void testBasic() throws Exception { CacheFactoryBean cfb = new CacheFactoryBean(); + cfb.setBeanName("gemfireCache"); cfb.setUseBeanFactoryLocator(false); cfb.afterPropertiesSet(); GemFireCache cache = cfb.getObject(); diff --git a/src/test/java/org/springframework/data/gemfire/config/CacheNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/CacheNamespaceTest.java index c7c6dbba..37a60ca5 100644 --- a/src/test/java/org/springframework/data/gemfire/config/CacheNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/CacheNamespaceTest.java @@ -58,8 +58,11 @@ public class CacheNamespaceTest extends RecreatingContextTest { } private void testBasicCache() throws Exception { + assertTrue(ctx.containsBean("gemfireCache")); + //Check alias is registered assertTrue(ctx.containsBean("gemfire-cache")); - CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfire-cache"); + // + CacheFactoryBean cfb = (CacheFactoryBean) ctx.getBean("&gemfireCache"); assertNull(TestUtils.readField("cacheXml", cfb)); assertNull(TestUtils.readField("properties", cfb)); } diff --git a/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java index df38496a..15e9c6a3 100644 --- a/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/ClientRegionNamespaceTest.java @@ -21,6 +21,10 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.FilenameFilter; + +import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -64,6 +68,20 @@ public class ClientRegionNamespaceTest { testOverflowToDisk(); } + @AfterClass + public static void tearDown() { + + for (String name : new File(".").list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.startsWith("BACKUP"); + } + })) { + new File(name).delete(); + } + } + private void testBasicClient() throws Exception { assertTrue(context.containsBean("simple")); } diff --git a/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java b/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java index ab81282b..d318008d 100644 --- a/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.FilenameFilter; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -80,6 +81,16 @@ public class DiskStoreAndEvictionRegionParsingTest { file.delete(); } diskStoreDir.delete(); + + for (String name : new File(".").list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.startsWith("BACKUPds"); + } + })) { + new File(name).delete(); + } } @Test @@ -98,7 +109,7 @@ public class DiskStoreAndEvictionRegionParsingTest { assertEquals(9999, diskStore1.getTimeInterval()); assertEquals(10, diskStore1.getMaxOplogSize()); assertEquals(diskStoreDir, diskStore1.getDiskDirs()[0]); - Cache cache = context.getBean("gemfire-cache", Cache.class); + Cache cache = context.getBean("gemfireCache", Cache.class); assertSame(diskStore1, cache.findDiskStore("diskStore1")); } diff --git a/src/test/java/org/springframework/data/gemfire/config/DynamicRegionNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/DynamicRegionNamespaceTest.java index a42ec237..e8af8813 100644 --- a/src/test/java/org/springframework/data/gemfire/config/DynamicRegionNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/DynamicRegionNamespaceTest.java @@ -44,7 +44,7 @@ public class DynamicRegionNamespaceTest extends RecreatingContextTest { DynamicRegionFactory drf = DynamicRegionFactory.get(); assertFalse(drf.isOpen()); assertNull(drf.getConfig()); - ctx.getBean("gemfire-cache", Cache.class); + ctx.getBean("gemfireCache", Cache.class); assertTrue(drf.isOpen()); DynamicRegionFactory.Config config = drf.getConfig(); assertFalse(config.persistBackup); diff --git a/src/test/java/org/springframework/data/gemfire/config/GemfireV6GatewayNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GemfireV6GatewayNamespaceTest.java index 2b21fde5..f6ebec7f 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GemfireV6GatewayNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GemfireV6GatewayNamespaceTest.java @@ -80,7 +80,7 @@ public class GemfireV6GatewayNamespaceTest extends RecreatingContextTest { @SuppressWarnings("rawtypes") private void testGatewaysInGemfire() { - Cache cache = ctx.getBean("gemfire-cache", Cache.class); + Cache cache = ctx.getBean("gemfireCache", Cache.class); GatewayHub gwh = cache.getGatewayHub("gateway-hub"); assertNotNull(gwh); diff --git a/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java index b3e7fec2..eaabaade 100644 --- a/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/GemfireV7GatewayNamespaceTest.java @@ -19,11 +19,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.io.FilenameFilter; import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.Set; +import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.springframework.data.gemfire.RecreatingContextTest; @@ -74,6 +77,19 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest { } } + @AfterClass + public static void tearDown() { + for (String name : new File(".").list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.startsWith("BACKUP"); + } + })) { + new File(name).delete(); + } + } + /** * */ diff --git a/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java index 44a48096..f530cc1b 100644 --- a/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java @@ -45,7 +45,7 @@ public class IndexNamespaceTest { @Before public void setUp() throws Exception { - Cache cache = (Cache) context.getBean("gemfire-cache"); + Cache cache = (Cache) context.getBean("gemfireCache"); if (cache.getRegion(name) == null) { cache.createRegionFactory().create("test-index"); } diff --git a/src/test/java/org/springframework/data/gemfire/config/JndiBindingsTest.java b/src/test/java/org/springframework/data/gemfire/config/JndiBindingsTest.java index 153bc962..251c0465 100644 --- a/src/test/java/org/springframework/data/gemfire/config/JndiBindingsTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/JndiBindingsTest.java @@ -37,7 +37,7 @@ public class JndiBindingsTest extends RecreatingContextTest { @Test public void testJndiBindings() throws Exception { - Cache cache = ctx.getBean("gemfire-cache", Cache.class); + Cache cache = ctx.getBean("gemfireCache", Cache.class); assertNotNull(cache.getJNDIContext().lookup("java:/SimpleDataSource")); GemFireBasicDataSource ds = (GemFireBasicDataSource) cache.getJNDIContext().lookup("java:/SimpleDataSource"); assertEquals("org.apache.derby.jdbc.EmbeddedDriver", ds.getJDBCDriver()); diff --git a/src/test/java/org/springframework/data/gemfire/config/PoolNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/PoolNamespaceTest.java index cb182055..230131a7 100644 --- a/src/test/java/org/springframework/data/gemfire/config/PoolNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/PoolNamespaceTest.java @@ -52,9 +52,12 @@ public class PoolNamespaceTest { } private void testBasicClient() throws Exception { + assertTrue(context.containsBean("gemfirePool")); + //Check old style alias also registered assertTrue(context.containsBean("gemfire-pool")); - assertEquals(context.getBean("gemfire-pool"), PoolManager.find("gemfire-pool")); - PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfire-pool"); + + assertEquals(context.getBean("gemfirePool"), PoolManager.find("gemfirePool")); + PoolFactoryBean pfb = (PoolFactoryBean) context.getBean("&gemfirePool"); Collection locators = TestUtils.readField("locators", pfb); assertEquals(1, locators.size()); PoolConnection locator = locators.iterator().next(); diff --git a/src/test/java/org/springframework/data/gemfire/config/TxEventHandlersTest.java b/src/test/java/org/springframework/data/gemfire/config/TxEventHandlersTest.java index 91df38a0..0bdb5074 100644 --- a/src/test/java/org/springframework/data/gemfire/config/TxEventHandlersTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/TxEventHandlersTest.java @@ -49,7 +49,7 @@ public class TxEventHandlersTest { @Autowired TestWriter txWriter; - @Resource(name = "gemfire-cache") + @Resource(name = "gemfireCache") Cache cache; @SuppressWarnings("rawtypes") diff --git a/src/test/java/org/springframework/data/gemfire/config/TxManagerNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/TxManagerNamespaceTest.java index babb5c3f..5d68b33b 100644 --- a/src/test/java/org/springframework/data/gemfire/config/TxManagerNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/TxManagerNamespaceTest.java @@ -35,8 +35,11 @@ public class TxManagerNamespaceTest extends RecreatingContextTest { @Test public void testBasicCache() throws Exception { + assertTrue(ctx.containsBean("gemfireTransactionManager")); + //Check old style alias also registered assertTrue(ctx.containsBean("gemfire-transaction-manager")); - GemfireTransactionManager tx = ctx.getBean("gemfire-transaction-manager", GemfireTransactionManager.class); + + GemfireTransactionManager tx = ctx.getBean("gemfireTransactionManager", GemfireTransactionManager.class); assertFalse(tx.isCopyOnRead()); } } \ No newline at end of file diff --git a/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java b/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java index e9743c4b..5c5e76bd 100644 --- a/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java +++ b/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupTest.java @@ -54,7 +54,7 @@ public class ContainerXmlSetupTest { ContinuousQueryListenerContainer container = ctx.getBean(ContinuousQueryListenerContainer.class); assertTrue(container.isRunning()); - Cache cache = ctx.getBean("gemfire-cache", Cache.class); + Cache cache = ctx.getBean("gemfireCache", Cache.class); Pool pool = ctx.getBean("client", Pool.class); CqQuery[] cqs = cache.getQueryService().getCqs(); diff --git a/src/test/java/org/springframework/data/gemfire/mapping/MappingPdxSerializerIntegrationTest.java b/src/test/java/org/springframework/data/gemfire/mapping/MappingPdxSerializerIntegrationTest.java index 92553a30..69129378 100644 --- a/src/test/java/org/springframework/data/gemfire/mapping/MappingPdxSerializerIntegrationTest.java +++ b/src/test/java/org/springframework/data/gemfire/mapping/MappingPdxSerializerIntegrationTest.java @@ -15,14 +15,16 @@ */ package org.springframework.data.gemfire.mapping; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import java.io.File; +import java.io.FilenameFilter; + +import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.data.gemfire.mapping.GemfireMappingContext; -import org.springframework.data.gemfire.mapping.MappingPdxSerializer; import org.springframework.data.gemfire.repository.sample.Address; import org.springframework.data.gemfire.repository.sample.Person; @@ -41,6 +43,8 @@ public class MappingPdxSerializerIntegrationTest { Region region; + static Cache cache; + @Before public void setUp() { @@ -50,8 +54,7 @@ public class MappingPdxSerializerIntegrationTest { CacheFactory factory = new CacheFactory(); factory.setPdxSerializer(serializer); factory.setPdxPersistent(true); - - Cache cache = factory.create(); + cache = factory.create(); RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); @@ -78,4 +81,22 @@ public class MappingPdxSerializerIntegrationTest { assertThat(reference.getLastname(), is(person.getLastname())); assertThat(reference.address, is(person.address)); } + + @AfterClass + public static void tearDown() { + try { + cache.close(); + } + catch (Exception e) { + } + for (String name : new File(".").list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.startsWith("BACKUP"); + } + })) { + new File(name).delete(); + } + } } diff --git a/src/test/java/org/springframework/data/gemfire/support/AbstractRegionFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/support/AbstractRegionFactoryBeanTest.java index a9684e9b..241e2ef3 100644 --- a/src/test/java/org/springframework/data/gemfire/support/AbstractRegionFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/support/AbstractRegionFactoryBeanTest.java @@ -15,10 +15,13 @@ */ package org.springframework.data.gemfire.support; +import java.io.File; +import java.io.FilenameFilter; import java.util.HashMap; import java.util.Map; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.springframework.data.gemfire.CacheFactoryBean; @@ -38,7 +41,7 @@ public abstract class AbstractRegionFactoryBeanTest { @Before public void setUp() throws Exception { CacheFactoryBean cfb = new CacheFactoryBean(); - cfb.setBeanName("gemfire-cache"); + cfb.setBeanName("gemfireCache"); cfb.setUseBeanFactoryLocator(false); cfb.afterPropertiesSet(); cache = cfb.getObject(); @@ -52,6 +55,19 @@ public abstract class AbstractRegionFactoryBeanTest { } } + @AfterClass + public static void cleanUp() { + for (String name : new File(".").list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.startsWith("BACKUP"); + } + })) { + new File(name).delete(); + } + } + protected void addRFBConfig(RegionFactoryBeanConfig rfbc) { if (regionFactoryBeanConfigs.containsKey(rfbc.regionName)) { throw new RuntimeException("duplicate region name " + rfbc.regionName); diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties index bdaf64ef..6db93321 100644 --- a/src/test/resources/log4j.properties +++ b/src/test/resources/log4j.properties @@ -6,7 +6,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n log4j.category.org.springframework.data.gemfire.listener=TRACE log4j.category.org.springframework.data.gemfire=DEBUG -log4j.category.org.springframework.beans.=DEBUG +log4j.category.org.springframework.beans=DEBUG # for debugging datasource initialization # log4j.category.test.jdbc=DEBUG diff --git a/src/test/resources/org/springframework/data/gemfire/basic-region.xml b/src/test/resources/org/springframework/data/gemfire/basic-region.xml index 2d447767..508a0f39 100644 --- a/src/test/resources/org/springframework/data/gemfire/basic-region.xml +++ b/src/test/resources/org/springframework/data/gemfire/basic-region.xml @@ -9,7 +9,7 @@ - + diff --git a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml index 5cfeb3ae..c47bb027 100644 --- a/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml +++ b/src/test/resources/org/springframework/data/gemfire/client/client-cache.xml @@ -1,17 +1,10 @@ - - diff --git a/src/test/resources/org/springframework/data/gemfire/config/tx-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/tx-ns.xml index 0aa063f2..ffeb4a37 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/tx-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/tx-ns.xml @@ -7,5 +7,5 @@ - + \ No newline at end of file diff --git a/src/test/resources/org/springframework/data/gemfire/listener/container.xml b/src/test/resources/org/springframework/data/gemfire/listener/container.xml index f3791508..b3d54f10 100644 --- a/src/test/resources/org/springframework/data/gemfire/listener/container.xml +++ b/src/test/resources/org/springframework/data/gemfire/listener/container.xml @@ -24,7 +24,7 @@ - +