SGF-465 - Moved project build to Maven.

Introduced Maven pom.xml basically mimicking what's been previously defined in build.gradle. Moved Asciidoctor files into places expected by the Spring Data build parent. Moved notice.txt etc. to src/main/resources. Switched to Logback for test logging.
This commit is contained in:
Oliver Gierke
2016-01-28 14:22:45 +01:00
parent c543109197
commit 4a6adbadb6
33 changed files with 187 additions and 72 deletions

View File

@@ -0,0 +1,19 @@
[[appendix-schema]]
[appendix]
= Spring Data GemFire Schema
:resourcesDir: ../../main/resources
== Spring Data GemFire Core Schema (gfe)
[source,xml]
----
include::{resourcesDir}/org/springframework/data/gemfire/config/spring-gemfire-1.3.xsd[]
----
== Spring Data GemFire Data Access Schema (gfe-data)
[source,xml]
----
include::{resourcesDir}/org/springframework/data/gemfire/config/spring-data-gemfire-1.3.xsd[]
----

View File

@@ -0,0 +1,69 @@
= Spring Data GemFire Reference Guide
Costin Leau , David Turanski , John Blum , Oliver Gierke
:baseDir: .
:revnumber: {version}
:revdate: {localdate}
:toc:
:toc-placement!:
:spring-data-commons-docs: {baseDir}/../../../spring-data-commons/src/main/asciidoc
(C) 2011-2015 The original authors.
NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not
charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed
in print or electronically.
toc::[]
[[spring-gemfire-reference]]
include::{baseDir}/preface.adoc[]
:leveloffset: 0
:leveloffset: +1
include::{baseDir}/introduction/introduction.adoc[]
include::{baseDir}/introduction/requirements.adoc[]
include::{baseDir}/introduction/new-features.adoc[]
:leveloffset: -1
[[reference]]
= Reference Guide
:leveloffset: +1
include::{baseDir}/reference/introduction.adoc[]
include::{baseDir}/reference/bootstrap.adoc[]
include::{baseDir}/reference/data.adoc[]
include::{baseDir}/reference/serialization.adoc[]
include::{baseDir}/reference/mapping.adoc[]
include::{baseDir}/reference/repositories.adoc[]
include::{baseDir}/reference/function-annotations.adoc[]
include::{baseDir}/reference/gemfire-bootstrap.adoc[]
include::{baseDir}/reference/samples.adoc[]
:leveloffset: -1
[[resources]]
= Other Resources
In addition to this reference documentation, there are a number of other resources that may help you learn how to use GemFire and Spring framework. These additional, third-party resources are enumerated in this section.
:leveloffset: +1
include::{baseDir}/links.adoc[]
:leveloffset: -1
[[appendices]]
= Appendices
:numbered!:
:leveloffset: +1
include::{spring-data-commons-docs}/repository-namespace-reference.adoc[]
include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[]
include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[]
include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[]
include::{baseDir}/appendix/appendix-schema.adoc[]
:leveloffset: -1

View File

@@ -0,0 +1,9 @@
[[introduction]]
= Introduction
This reference guide for Spring Data GemFire explains how to use the Spring Framework to configure
and develop applications with Pivotal GemFire. It presents the basic concepts, semantics and provides numerous examples
to help you get started.
NOTE: Spring Data GemFire started as a top-level Spring project called Spring GemFire (SGF) and since then
has been moved under the Spring Data umbrella project and renamed accordingly.

View File

@@ -0,0 +1,121 @@
[[new-features]]
= New Features
NOTE: 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 http://projects.spring.io/spring-data/[Spring Data] project.
[[new-in-1-2-0]]
== New in the 1.2 Release
* Full support for GemFire configuration via the SDG *gfe* namespace. Now GemFire components may be configured completely without requiring a native *cache.xml* file.
* WAN Gateway support for GemFire 6.6.x. See <<bootstrap:gateway>>.
* Spring Data Repository support using a dedicated SDG namespace, *gfe-data*. See <<gemfire-repositories>>
* Namespace support for registering GemFire Functions. See <<bootstrap:function>>
* A top-level `<disk-store>` element has been added to the SDG *gfe* namespace to allow sharing of persist stores among Regions,
and other components that support persistent backup or overflow. See <<bootstrap-diskstore>>
+
WARNING: The `<*-region>` elements no longer allow a nested `<disk-store>` element.
+
* GemFire Sub-Regions are supported via nested `<*-region>` elements.
* A `<local-region>` element has been added to configure a Local Region.
* Support for the re-designed WAN Gateway in GemFire 7.0.
[[new-in-1-3-0]]
== New in the 1.3 Release
* Annotation support for GemFire Functions. It is now possible to declare and register Functions written as POJOs using annotations. In addition, Function executions are defined as
annotated interfaces, similar to the way Spring Data Repositories work. See <<function-annotations>>.
* Added a `<datasource>` element to the SDG *gfe-data* namespace to simplify establishing a basic <<data-access:datasource,client connection>> to a GemFire data grid.
* Added a `<json-region-autoproxy>` element to the SDG *gfe-data* namespace to <<bootstrap:region:json,support JSON>> features introduced
in GemFire 7.0, enabling Spring AOP to perform the necessary conversions automatically on Region operations.
* Upgraded to GemFire 7.0.1 and added namespace support for new AsyncEventQueue attributes.
* Added support for setting subscription interest policy on Regions.
* Support for void returns on Function executions. See <<function-annotations>> for complete details.
* Support for persisting Local Regions. See <<bootstrap:region:local>> and <<bootstrap:region:common:attributes>>.
* Support for entry time-to-live and entry idle-time on a GemFire Client Cache. See <<bootstrap:cache:client>>.
* Support for multiple Spring Data GemFire web-based applications using a single GemFire cluster, operating concurrently inside tc Server.
* Support for concurrency-checks-enabled on all GemFire Cache Region definitions using the SDG *gfe* namespace. See <<bootstrap:region:common:attributes>>.
* Support for Cache Loaders and Cache Writers on Client, Local Regions. See <<bootstrap:region:common:loaders-writers>>.
* Support for registering CacheListeners, AsyncEventQueues and Gateway Senders on GemFire Cache Sub-Regions.
* Support for PDX persistent keys in GemFire Regions.
* Support for correct Partition Region bean creation in a Spring context when collocation is specified with the *colocated-with* attribute.
* Full support for GemFire Cache Sub-Regions using proper, nested `<*-region>` element syntax in the SDG *gfe* namespace.
* Upgraded Spring Data GemFire to Spring Framework 3.2.8.
* Upgraded Spring Data GemFire to Spring Data Commons 1.7.1.
[[new-in-1-4-0]]
== New in the 1.4 Release
* Upgrades Spring Data GemFire to GemFire 7.0.2.
* Upgrades Spring Data GemFire to Spring Data Commons 1.8.0.
* Upgrades Spring Data GemFire to Spring Framework 3.2.9.
* Integrates Spring Data GemFire with Spring Boot, which includes both a *spring-boot-starter-data-gemfire* POM
along with a Spring Boot sample application demonstrating GemFire Cache Transactions configured with SDG
and bootstrapped with Spring Boot.
* Support for bootstrapping a Spring Context in a GemFire Server when started from Gfsh.
See <<gemfire-bootstrap>> for more details.
* Support for persisting application domain object/entities to multiple GemFire Cache Regions.
See <<mapping.entities>> for more details.
* Support for persisting application domain object/entities to GemFire Cache Sub-Regions, avoiding collisions
when Sub-Regions are uniquely identifiable, but identically named.
See <<mapping.entities>> for more details.
* Adds strict XSD type rules to, and full support for, Data Policies and Region Shortcuts on all GemFire
Cache Region types.
* Changed the default behavior of SDG `<*-region>` elements from lookup to always create a new Region
along with an option to restore old behavior using the *ignore-if-exists* attribute.
See <<bootstrap:region:common:attributes,Common Region Attributes>> and <<bootstrap:region:common:regions-subregions-lookups-caution>>
for more details.
* Enables Spring Data GemFire to be fully built and ran on JDK 7 and JDK 8 (Note, however, GemFire has not yet
been fully tested and supported on JDK 8;
See http://gemfire.docs.pivotal.io/latest/userguide/index.html#supported_configs/supported_configs_and_system_reqs.html[GemFire User Guide]
for additional details.
[[new-in-1-5-0]]
== New in the 1.5 Release
* Upgrades Spring Data GemFire to Spring Data Commons 1.9.0
* Upgrades Spring Data GemFire to Spring Framework 4.0.7
* Reference Guide migrated to Asciidoc
* Renewed support for deploying Spring Data GemFire in an OSGi container.
* Removed all default values in the Spring Data GemFire XML namespace Region-type elements, relying on GemFire defaults
instead.
* Added convenience to automatically create Disk Store directory locations without the need to create them manually,
as required by GemFire.
* SDG annotated Functions can now be executed from Gfsh.
* Enable GemFire GatewayReceivers to be started manually.
* Support for Auto Region Lookups. See <<bootstrap:region:auto-lookup>> for further details.
* Support for Region Templates See <<bootstrap:region:common:region-templates>> for further details.
[[new-in-1-6-0]]
== New in the 1.6 Release
* Upgrades Spring Data GemFire to GemFire 8.0.
* Adds support for GemFire 8's new Cluster-based Configuration.
* Enables 'auto-reconnect' functionality to be employed in Spring-configured GemFire Servers.
* Allows the creation of concurrent and parallel Async Event Queues and Gateway Senders.
* Adds support for GemFire 8's Region data compression.
* Adds attributes to set both critical and warning percentages on Disk Store usage.
* Supports the capability to add the new EventSubstitutionFilters to GatewaySenders.
[[new-in-1-7-0]]
== New in the 1.7 Release
* Upgrades Spring Data GemFire to GemFire 8.1.0.
* Early Access support for Apache Geode.
* Support for adding Spring defined Cache Listeners, Loaders and Writers on "existing" GemFire Regions configured in Spring XML,
`cache.xml` or even with GemFire's _Cluster Config_.
* Spring JavaConfig support added to `SpringContextBootstrappingInitializer`.
* Support for custom `ClassLoaders` in `SpringContextBootstrappingInitializer` to load Spring-defined bean classes.
* Support for `LazyWiringDeclarableSupport` re-initialization and complete replacement for `WiringDeclarableSupport`.
* Adds `locators` and `servers` attributes to the `<gfe:pool>` element allowing variable Locator/Server
endpoint lists configured with Spring's property placeholders.
* Enables the use of `<gfe-data:datasource>` element with non-Spring configured GemFire Servers.
* Multi-Index definition and creation support.
* <<bootstrap:region:expiration:annotation>>
* <<gemfire-repositories.oql-extension>>
* <<bootstrap:snapshot>>
[[new-in-1-8-0]]
== New in the 1.8 Release
* Upgrades Spring Data GemFire to GemFire 8.2.0.

View File

@@ -0,0 +1,5 @@
[[requirements]]
= Requirements
Spring Data GemFire requires JDK 6.0 or above, http://projects.spring.io/spring-framework[Spring Framework] 3
and http://www.pivotal.io/big-data/pivotal-gemfire[Pivotal GemFire] 6.6 or above (version 7 or above is recommended).

View File

@@ -0,0 +1,12 @@
[[sgf-links]]
= Useful Links
* http://projects.spring.io/spring-data-gemfire[Spring Data GemFire Home Page]
* http://www.pivotal.io/big-data/pivotal-gemfire[Pivotal GemFire Home Page]
* http://gemfire.docs.pivotal.io/index.html[Pivotal GemFire Documentation]
* https://support.pivotal.io/hc/en-us/categories/200072748-Pivotal-GemFire-Knowledge-Base[Pivotal GemFire Knowledge Base]
* https://support.pivotal.io/hc/communities/public/topics/200053218-Pivotal-GemFire-General[Pivotal GemFire Community Home Page]
* http://communities.vmware.com/community/vmtn/appplatform/vfabric_gemfire[VMWare vFabric GemFire Community Home Page]
* http://stackoverflow.com/questions/tagged/spring-data-gemfire[Spring Data GemFire Forum (StackOverflow)]
* http://forum.spring.io/forum/spring-projects/data/gemfire[Spring Data GemFire Forum (spring.io archive)]

View File

@@ -0,0 +1,6 @@
= Preface
Spring Data GemFire focuses on integrating the Spring Framework's powerful, non-invasive programming model and concepts with Pivotal GemFire, simplifying configuration, development and providing high-level abstractions. This document assumes the reader already has a basic familiarity with the Spring Framework and Pivotal GemFire concepts and APIs.
While every effort has been made to ensure this documentation is comprehensive and there are no errors, 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, please do bring the errors to the attention of the Spring Data GemFire team by raising an https://jira.spring.io/browse/SGF[issue]. Thank you.

View File

@@ -0,0 +1,125 @@
[[bootstrap]]
= Bootstrapping GemFire through the Spring Container
Spring Data GemFire provides full configuration and initialization of the GemFire data grid through Spring's IoC container and 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.
NOTE: This section assumes basic familiarity with GemFire. For more information see the http://www.pivotal.io/big-data/pivotal-gemfire[product documentation].
[[bootstrap:region:spring:config]]
== Advantages of using Spring over GemFire `cache.xml`
As of release 1.2.0, Spring Data GemFire's XML namespace supports full configuration of the GemFire in-memory data grid.
In fact, Spring Data GemFire's XML namespace is considered to be the preferred way to configure GemFire.
GemFire will continue to support native `cache.xml` for legacy reasons, but GemFire application developers can now do
everything in Spring XML and take advantage of the many wonderful things Spring has to offer such as
modular XML configuration, property placeholders and overrides, SpEL, and environment profiles. Behind the
XML namespace, Spring Data GemFire makes extensive use of Spring's `FactoryBean` pattern to simplify the creation,
configuration and initialization of GemFire components.
For example, GemFire provides several callback interfaces, such as `CacheListener`, `CacheWriter`, and `CacheLoader`,
that allow developers to add custom event handlers. Using Spring's IoC container, these callbacks may be configured
as normal Spring beans and injected into GemFire components. This is a significant improvement over native `cache.xml`,
which provides relatively limited configuration options and requires callbacks to implement GemFire's `Declarable` interface
(see <<apis:declarable>> to see how you can still use `Declarables` within Spring's IoC/DI container).
In addition, IDEs such as the Spring Tool Suite (STS) provide excellent support for Spring XML namespaces, such as
code completion, pop-up annotations, and real time validation, making them easy to use.
[[bootstrap:namespace]]
== Using the Core Spring Data GemFire Namespace
To simplify configuration, Spring Data GemFire provides a dedicated XML namespace for configuring core GemFire components.
It is also possible to configure beans directly using Spring's standard <bean> definition. However, as of
Spring Data GemFire 1.2.0, all bean properties are exposed via the XML namespace so there is little benefit to using
raw bean definitions. For more information about XML Schema-based configuration in Spring, see
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#xsd-config[this] appendix
in the Spring Framework reference documentation.
NOTE: Spring Data Repository support uses a separate XML namespace. See <<gemfire-repositories>> for more information
on how to configure Spring Data GemFire Repositories.
To use the Spring Data GemFire XML namespace, simply declare it in your Spring XML configuration meta-data:
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"<!--1--><!--2-->
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd"> <!--3-->
<bean id ... >
<gfe:cache ...> <!--4-->
</beans>
----
<1> Spring GemFire namespace prefix. Any name will do but through out the reference documentation, `gfe` will be used.
<2> The namespace URI.
<3> The namespace URI location. Note that even though the location points to an external address (which exists and is valid), Spring will resolve the schema locally as it is included in the Spring Data GemFire library.
<4> Declaration example for the GemFire namespace. Notice the prefix usage.
[NOTE]
====
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:
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/gemfire" <!--1-->
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<!--2-->
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
<beans:bean id ... > <!--3-->
<cache ...> <!--4-->
</beans>
----
<1> The default namespace declaration for this XML file points to the Spring Data GemFire namespace.
<2> The `beans` namespace prefix declaration.
<3> Bean declaration using the `beans` namespace. Notice the prefix.
<4> Bean declaration using the `gfe` namespace. Notice the lack of prefix (as the default namespace is used).
====
:leveloffset: +1
include::cache.adoc[]
include::data-access.adoc[]
include::region.adoc[]
:leveloffset: -1
[[bootstrap:indicies]]
== Creating an Index
GemFire allows the creation of indexes (or indices) to improve the performance of (common) queries.
Spring Data GemFire allows indices to be declared through the `index` element:
[source,xml]
----
<gfe:index id="myIndex" expression="someField" from="/someRegion"/>
----
Before creating an Index, Spring Data GemFire will verify whether an Index with the same name already exists.
If an Index with the same name does exist, by default, SDG will "override" the existing Index by removing the old Index
first followed by creating a new Index with the same name based on the new definition, regardless if the old definition
was the same or not. To prevent the named Index definition change, especially when the old and new Index definitions
may not match, set the `override` property to false, which effectively returns the existing Index definition by name.
Note that index declarations are not bound to a Region but rather are top-level elements (just like `gfe:cache`).
This allows one to declare any number of indices on any Region whether they are just created or already exist
- an improvement over GemFire's native `cache.xml`. By default, the index relies on the default cache declaration
but one can customize it accordingly or use a pool (if need be) - see the namespace schema for the full set of options.
:leveloffset: +1
include::diskstore.adoc[]
include::snapshot.adoc[]
include::function.adoc[]
include::gateway.adoc[]
:leveloffset: -1

View File

@@ -0,0 +1,296 @@
[[bootstrap:cache]]
= Configuring a GemFire Cache
In order to use GemFire, a developer needs to either create a new `Cache` or connect to an existing one.
In the current version of GemFire, there can be only one open Cache per VM (or per `ClassLoader` to be
technically correct). In most cases the Cache should only be created once.
NOTE: This section describes the creation and configuration of a full Cache member, appropriate for peer-to-peer
cache topologies and cache servers. A full cache is also commonly used for standalone applications, integration tests
and proofs of concept. In a typical production system, most application processes will act as cache clients
and will create a `ClientCache` instance instead. This is described in the sections <<bootstrap:cache:client>>
and <<bootstrap:region:client>>
A cache with default configuration can be created with a very simple declaration:
[source,xml]
----
<gfe:cache/>
----
Upon initialization, a Spring application context containing this cache definition will register a `CacheFactoryBean`
to create a Spring bean named `gemfireCache` referencing a GemFire `Cache` instance. This will either be an
existing cache, or if one does not already 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 that 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 dependency explicit via the `cache-ref`
attribute provided by various namespace elements. Also, you can easily override the cache's bean name:
[source,xml]
----
<gfe:cache id="my-cache"/>
----
Starting with Spring Data GemFire 1.2.0, the GemFire `Cache` may be fully configured using Spring. However, GemFire's
native XML configuration file, `cache.xml`, is also supported. For scenarios in which the GemFire Cache needs to be
configured natively, simply provide a reference to the GemFire configuration file using the `cache-xml-location`
attribute:
[source,xml]
----
<gfe:cache id="cache-using-native-xml" cache-xml-location="classpath:cache.xml"/>
----
In this example, if the cache needs to be created, it will use the file named `cache.xml` located in the classpath root.
NOTE: Note that the configuration makes use of Spring's http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#resources[`Resource`]
abstraction to locate the file. This allows various search patterns to 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 http://gemfire.docs.pivotal.io/latest/userguide/index.html#reference/topics/gemfire_properties.html[properties]
using any of Spring's common properties support features. For example, one can use the `properties` element
defined in the `util` namespace to define properties directly or load properties from a properties file. The latter is
recommended for externalizing environment specific settings outside the application configuration:
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<util:properties id="gemfireProperties" location="file:/pivotal/gemfire/gemfire.properties"/>
<gfe:cache properties-ref="gemfireProperties"/>
</beans>
----
NOTE: The cache settings apply only if a new cache needs to be created. If an open cache already exists in the VM,
these settings will be ignored.
[[bootstrap:cache:advanced]]
== Advanced Cache Configuration
For advanced cache configuration, the `cache` element provides a number of configuration options exposed as attributes
or child elements:
[source,xml]
----
<!--1-->
<gfe:cache
close="false"
copy-on-read="true"
critical-heap-percentage="70"
eviction-heap-percentage="60"
enable-auto-reconnect="false" <!--2-->
lock-lease="120"
lock-timeout="60"
message-sync-interval="1"
pdx-serializer-ref="myPdxSerializer"
pdx-persistent="true"
pdx-disk-store="diskStore"
pdx-read-serialized="false"
pdx-ignore-unread-fields="true"
search-timeout="300"
use-cluster-configuration="false" <!--3-->
lazy-init="true">
<gfe:transaction-listener ref="myTransactionListener"/> <!--4-->
<gfe:transaction-writer> <!--5-->
<bean class="org.springframework.data.gemfire.example.TransactionListener"/>
</gfe:transaction-writer>
<gfe:gateway-conflict-resolver ref="myGatewayConflictResolver"/> <!--6-->
<gfe:dynamic-region-factory/> <!--7-->
<gfe:jndi-binding jndi-name="myDataSource" type="ManagedDataSource"/> <!--8-->
</gfe:cache>
----
<1> Various cache options are supported by attributes. For further information regarding anything shown in this example, please consult the GemFire http://gemfire.docs.pivotal.io/index.html[product documentation].
The `close` attribute determines if the cache should be closed when the Spring application context is closed. The default is `true` however for cases in which multiple application contexts use the cache (common in web applications), set this value to `false`.
The `lazy-init` attribute determines if the cache should be initialized before another bean references it. The default is `true` however in some cases it may be convenient to set this value to `false`.
<2> Setting the `enable-auto-reconnect` attribute to true (default is false), allows a disconnected GemFire member to automatically reconnect and rejoin a GemFire cluster.
See the GemFire http://gemfire.docs.pivotal.io/latest/userguide/index.html#relnotes/release_notes.html#topic_5mbwjl__section_wxb_v35_v4[product documentation] for more details.
<3> Setting the `use-cluster-configuration` attribute to true (default is false) to enable a GemFire member to retrieve the common, shared Cluster-based configuration from a Locator.
See the GemFire http://gemfire.docs.pivotal.io/latest/userguide/index.html#relnotes/release_notes.html#topic_5mbwjl__section_zk2_p35_v4[product documentation] for more details.
<4> An example of a `TransactionListener` callback declaration using a bean reference. The referenced bean must implement
http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/TransactionListener.html[TransactionListener].
`TransactionListener(s)` can be implemented to handle transaction related events.
<5> An example of a `TransactionWriter` callback declaration using an inner bean declaration this time. The bean must implement
http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/TransactionWriter.html[TransactionWriter].
`TransactionWriter` is a callback that is allowed to veto a transaction.
<6> An example of a `GatewayConflictResolver` declaration using a bean reference. The referenced bean must implement
http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/util/GatewayConflictResolver.html[GatewayConflictResolver].
GatewayConflictResolver is a Cache-level plugin that is called upon to decide what to do with events that originate in other systems and arrive through the WAN Gateway.
<7> Enable GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/DynamicRegionFactory.html[DynamicRegionFactory],
which provides a distributed region creation service.
<8> Declares a JNDI binding to enlist an external DataSource in a GemFire transaction.
NOTE: The `use-bean-factory-locator` attribute (not shown) deserves a mention. The factory bean responsible for
creating the cache uses an internal Spring type called a `BeanFactoryLocator` to enable user classes declared in
GemFire's native `cache.xml` to be registered as Spring beans. The `BeanFactoryLocator` implementation also permits
only one bean definition for a cache with a given id. In certain situations, such as running JUnit integration tests
from within Eclipse, it is necessary to disable the `BeanFactoryLocator` by setting this value to false to prevent
an exception. This exception may also arise during JUnit tests running from a build script. In this case the test runner
should be configured to fork a new JVM for each test (in maven, set `<forkmode>always</forkmode>`) . Generally, there is
no harm in setting this value to false.
=== Enabling PDX Serialization
The example above includes a number of attributes related to GemFire's enhanced serialization framework, PDX.
While a complete discussion of PDX is beyond the scope of this reference guide, it is important to note that PDX
is enabled by registering a PDX serializer which is done via the `pdx-serializer` attribute. GemFire provides
an implementation class `com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer`, however it is common for developers
to provide their own implementation. The value of the attribute is simply a reference to a Spring bean that implements
the required interface. More information on serialization support can be found in <<serialization>>
[[boostrap:cache:auto-reconnect]]
=== Enabling auto-reconnect
Setting the `<gfe:cache enable-auto-reconnect="[true|false*]>` attribute to true should be done with care.
Generally, enabling 'auto-reconnect' should only be done in cases where Spring Data GemFire's XML namespace is used to
configure and bootstrap a new GemFire Server data node to add to the cluster. In other words, 'auto-reconnect'
should not be used when Spring Data GemFire is used to develop and build an GemFire application that also happens
to be a peer cache member of the GemFire cluster.
The main reason is most GemFire applications use references to the GemFire cache or regions in order to perform
data access operations. The references are "injected" by the Spring container into application components (e.g. DAOs
or Repositories) for use by the application. When a member (such as the application) is forcefully disconnected
from the rest of the cluster, presumably because the member (the application) has become unresponsive for
a period of time, or network partition separates one or more members (along with the application peer cache member) into
a group that is too small to act as the distributed system, the member will shutdown and all GemFire component references
(e.g. Cache, Regions, etc) become invalid.
Essentially, the current forced-disconnect processing in each member dismantles the system from the ground up.
It shuts down the JGroups stack, puts the Distributed System in a shut-down state and then closes the Cache.
This effectively loses all in-memory information.
After being disconnected from a distributed system and successfully shutting down, the GemFire member then restarts in a
"reconnecting" state, while periodically attempting to rejoin the distributed system. If the member succeeds in reconnecting,
the member rebuilds its "view" of the distributed system from existing members and receives a new distributed system ID.
This means the cache, regions and other GemFire components are reconstructed and all old references that may have been
injected into application are now stale and no longer valid.
GemFire makes no guarantee, even when using the GemFire public Java API, that application cache, region or other
component references will be automatically refreshed by the reconnect operation. As such, applications must take care
to refresh their own references.
Unfortunately there is no way to be "notified" of a disconnect and subsequently a reconnect event. If so, the application
developer would then have a clean way to know when to call ConfigurableApplicationContext.refresh(), if even applicable
for an application to do so, which is why this "feature" of GemFire 8 is not recommended for peer cache GemFire applications.
For more information about 'auto-reconnect', see GemFire's http://gemfire.docs.pivotal.io/latest/userguide/index.html#managing/autoreconnect/member-reconnect.html#concept_22EE6DDE677F4E8CAF5786E17B4183A9[product documentation].
[[bootstrap:cache:cluster-configuration]]
=== Using Cluster-based Configuration
GemFire 8's new Cluster-based Configuration Service is a convenient way for a member joining the cluster to get a
"consistent view" of the cluster, by using the shared, persistent configuration maintained by a Locator, ensuring
the member's configuration will be compatible with the GemFire distributed system when the member joins.
This feature of Spring Data GemFire (setting the `use-cluster-configuration` attribute to true) works in the same way
as the `cache-xml-location` attribute, except the source of the GemFire configuration meta-data comes from a network
Locator as opposed to a native `cache.xml` file.
All GemFire native configuration meta-data, whether from `cache.xml` or from the Cluster Configuration Service,
gets applied before any Spring XML configuration meta-data. As such, Spring's config serves to "augment" the
native GemFire configuration meta-data, which would most likely be specific to the application.
Again, to enable this feature, just specify the following in the Spring XML config:
[source,xml]
----
<gfe:cache use-cluster-configuration="true"/>
----
NOTE: While certain GemFire tools, like Gfsh, have their actions "recorded" when any schema-like change is made
(e.g. `gfsh>create region --name=Example --type=PARTITION`) to the cluster, Spring Data GemFire's configuration meta-data
specified with the XML namespace is not recorded. The same is true when using GemFire's public Java API directly;
it too is not recorded.
For more information on GemFire's Cluster Configuration Service, see the
http://gemfire.docs.pivotal.io/latest/userguide/index.html#deploying/gfsh/gfsh_persist.html[product documentation].
[[bootstrap:cache:server]]
== Configuring a GemFire Cache Server
In Spring Data GemFire 1.1 dedicated support for configuring a http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/server/CacheServer.html[CacheServer] was added, allowing complete configuration through the Spring container:
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:context="http://www.springframework.org/schema/context"
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/context http://www.springframework.org/schema/context/spring-context.xsd">
<gfe:cache />
<!-- Advanced example depicting various cache server configuration options -->
<gfe:cache-server id="advanced-config" auto-startup="true"
bind-address="localhost" port="${gfe.port.6}" host-name-for-clients="localhost"
load-poll-interval="2000" max-connections="22" max-threads="16"
max-message-count="1000" max-time-between-pings="30000"
groups="test-server">
<gfe:subscription-config eviction-type="ENTRY" capacity="1000" disk-store="file://${java.io.tmpdir}"/>
</gfe:cache-server>
<context:property-placeholder location="classpath:cache-server.properties"/>
</beans>
----
The configuration above illustrates the `cache-server` element and the many options available.
NOTE: Rather than hard-coding the port, this configuration uses Spring's http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#xsd-config-body-schemas-context[context] namespace to declare a `property-placeholder`. http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-factory-placeholderconfigurer[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 http://docs.spring.io/spring/docs/3.2.11.RELEASE/spring-framework-reference/htmlsingle/#new-feature-el[SpEL] and the http://docs.spring.io/spring/docs/3.2.11.RELEASE/spring-framework-reference/htmlsingle/#new-in-3.1-environment-abstraction[environment abstraction] one to support externalization of environment specific properties from the main code base, easing the deployment across multiple machines.
NOTE: To avoid initialization problems, the `CacheServer`s started by Spring Data GemFire will start *after* the container has been fully initialized. This allows potential regions, listeners, writers or instantiators defined declaratively to be fully initialized and registered before the server starts accepting connections. Keep this in mind when programmatically configuring these items as the server might start after your components and thus not be seen by the clients connecting right away.
[[bootstrap:cache:client]]
== Configuring a GemFire Client Cache
Another configuration addition in Spring Data GemFire 1.1 is the dedicated support for configuring http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/client/ClientCache.html[ClientCache]. This is similar to a <<bootstrap:cache,cache>> in both usage and definition and supported by `org.springframework.data.gemfire.clientClientCacheFactoryBean`.
[source,xml]
----
<beans>
<gfe:client-cache />
</beans>
----
`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` element; The client side `pool` 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:
[source,xml]
----
<beans>
<gfe:client-cache id="simple" pool-name="my-pool"/>
<gfe:pool id="my-pool" subscription-enabled="true">
<gfe:locator host="${locatorHost}" port="${locatorPort}"/>
</gfe:pool>
</beans>
----
The <client-cache> tag also includes a `ready-for-events` attribute. If set to `true`, the client cache initialization will include http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/client/ClientCache.html#readyForEvents()[ClientCache.readyForEvents()].
Client side configuration is covered in more detail in <<bootstrap:region:client>>.

View File

@@ -0,0 +1,103 @@
[[apis:cq-container]]
= GemFire Continuous Query Container
A powerful functionality offered by GemFire is http://community.gemstone.com/display/gemfire/Continuous+Querying[continuous querying] (or CQ). In short, CQ allows one to create a query and automatically be notified when new data that gets added to GemFire matches the query. Spring GemFire provides dedicated support for CQs through the `org.springframework.data.gemfire.listener` package and its *listener container*; very similar in functionality and naming to the JMS integration in Spring Framework; in fact, users familiar with the JMS support in Spring, should feel right at home. Basically Spring Data GemFire allows methods on POJOs to become end-points for CQ - simply define the query and indicate the method that should be notified when there is a match - Spring Data GemFire takes care of the rest. This is similar Java EE's message-driven bean style, but without any requirement for base class or interface implementations, based on GemFire.
NOTE: Currently, continuous queries are supported by GemFire only in client/server topologies. Additionally the pool used is required to have the `subscription` property enabled. Please refer to the documentation for more information.
[[apis:cq-container:containers]]
== Continuous Query Listener Container
Spring Data GemFire simplifies the creation, registration, life-cycle and dispatch of CQs by taking care of the infrastructure around them through `ContinuousQueryListenerContainer` which does all the heavy lifting on behalf of the user - users familiar with EJB and JMS should find the concepts familiar as it is designed as close as possible to the support in Spring Framework and its message-driven POJOs (MDPs)
`ContinuousQueryListenerContainer` acts as an event (or message) listener container; it is used to receive the events from the registered CQs and drive the POJOs that are injected into it. The listener container is responsible for all threading of message reception and dispatches into the listener for processing. It acts as the intermediary between an EDP (Event Driven POJO) and the event provider and takes care of creation and registration of CQs (to receive events), resource acquisition and release, exception conversion and the like. This allows you as an application developer to write the (possibly complex) business logic associated with receiving an event (and reacting to it), and delegates boilerplate GemFire infrastructure concerns to the framework.
The container is fully customizable - one can chose either to use the CQ thread to perform the dispatch (synchronous delivery) or a new thread (from an existing pool for examples) for an asynchronous approach by defining the suitable `java.util.concurrent.Executor` (or Spring's `TaskExecutor`). Depending on the load, the number of listeners or the runtime environment, one should change or tweak the executor to better serve her needs - in particular in managed environments (such as app servers), it is highly recommended to pick a a proper `TaskExecutor` to take advantage of its runtime.
[[apis:cq-container:adapter]]
== The `ContinuousQueryListenerAdapter` and `ContinuousQueryListener`
The `ContinuousQueryListenerAdapter` class is the final component in Spring Data GemFire CQ support: in a nutshell, it allows you to expose almost *any* class as a EDP (there are of course some constraints) - it implements `ContinuousQueryListener`, a simpler listener interface similar to GemFire http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/query/CqListener.html[CqListener].
Consider the following interface definition. Notice the various event handling methods and their parameters:
[source,java]
----
public interface EventDelegate {
void handleEvent(CqEvent event);
void handleEvent(Operation baseOp);
void handleEvent(Object key);
void handleEvent(Object key, Object newValue);
void handleEvent(Throwable th);
void handleQuery(CqQuery cq);
void handleEvent(CqEvent event, Operation baseOp, byte[] deltaValue);
void handleEvent(CqEvent event, Operation baseOp, Operation queryOp, Object key, Object newValue);
}
----
[source,java]
----
public class DefaultEventDelegate implements EventDelegate {
// implementation elided for clarity...
}
----
In particular, note how the above implementation of the `EventDelegate` interface (the above `DefaultEventDelegate` class) has *no* GemFire dependencies at all. It truly is a POJO that we will make into an EDP via the following configuration (note that the class doesn't have to implement an interface, one is present only to better show case the decoupling between contract and implementation).
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
<gfe:client-cache pool-name="client"/>
<gfe:pool id="client" subscription-enabled="true">
<gfe:server host="localhost" port="40404"/>
</gfe:pool>
<gfe:cq-listener-container>
<!-- default handle method -->
<gfe:listener ref="listener" query="SELECT * from /region"/ >
<gfe:listener ref="another-listener" query="SELECT * from /another-region" name="my-query" method="handleQuery"/>
</gfe:cq-listener-container>
<bean id="listener" class="gemfireexample.DefaultMessageDelegate"/>
<bean id="another-listener" class="gemfireexample.DefaultMessageDelegate"/>
...
<beans>
----
NOTE: The example above shows some of the various forms that a listener can have; at its minimum the listener reference and the actual query definition are required. It's possible however to specify a name for the resulting continuous query (useful for monitoring) but also the name of the method (the default is `handleEvent`). The specified method can have various argument types, the `EventDelegate` interface lists the allowed types.
The example above uses the Spring Data GemFire namespace to declare the event listener container and automatically register the listeners. The full blown, *beans* definition is displayed below:
[source,xml]
----
<!-- this is the Event Driven POJO (MDP) -->
<bean id="eventListener" class="org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter">
<constructor-arg>
<bean class="gemfireexample.DefaultEventDelegate"/>
</constructor-arg>
</bean>
<!-- and this is the event listener container... -->
<bean id="gemfireListenerContainer" class="org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer">
<property name="cache" ref="gemfireCache"/>
<property name="queryListeners">
<!-- set of listeners -->
<set>
<bean class="org.springframework.data.gemfire.listener.ContinuousQueryDefinition" >
<constructor-arg value="SELECT * from /region" />
<constructor-arg ref="eventListener" />
</bean>
</set>
</property>
</bean>
----
Each time an event is received, the adapter automatically performs type translation between the GemFire event and the required method argument(s) transparently. Any exception caused by the method invocation is caught and handled by the container (by default, being logged).

View File

@@ -0,0 +1,30 @@
[[data-access]]
= Using the GemFire Data Access Namespace
In addition to the core `gfe` namespace, Spring Data GemFire provides a `gfe-data` namespace intended primarily to simplify the development of GemFire client applications. This namespace currently supports for GemFire <<gemfire-repositories,repositories>> and function <<function-execution,execution>> and a `<datasource>` tag that offers a convenient way to connect to the data grid.
[[data-access:datasource]]
== An Easy Way to Connect to GemFire
For many applications, A basic connection to a GemFire grid, using default values is sufficient. Spring Data GemFire's `<datasource>` tag provides a simple way to access data. The data source creates a client cache and connection pool. In addition, it will query the member servers for all existing root regions and create a proxy (empty) client region for each one.
[source,xml]
----
<gfe-data:datasource>
<locator host="somehost" port="1234"/>
</gfe-data:datasource>
----
The datasource tag is syntactically similar to `<gfe:pool>`. It may be configured with one or more locator or server tags to connect to an existing data grid. Additionally, all attributes available to configure a pool are supported. This configuration will automatically create ClientRegion beans for each region defined on members connected to the locator, so they may be seamlessly referenced by Spring Data mapping annotations, GemfireTemplate, and wired into application classes.
Of course, you can explicitly configure client regions. For example, if you want to cache data in local memory:
[source,xml]
----
<gfe-data:datasource>
<locator host="somehost" port="1234"/>
</gfe-data:datasource>
<gfe:client-region id="Customer" shortcut="CACHING_PROXY"/>
----

View File

@@ -0,0 +1,242 @@
[[apis]]
= Working with the GemFire APIs
Once the GemFire Cache and Regions have been configured they can be injected and used inside application objects. This chapter describes the integration with Spring's Transaction Management functionality and `DaoException` hierarchy. It also covers support for dependency injection of GemFire managed objects.
[[apis:exception-translation]]
== Exception Translation
Using a new data access technology requires not only accommodating a new API but also handling exceptions specific to that technology. To accommodate this case, Spring Framework provides a technology agnostic, consistent http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#dao-exceptions[exception hierarchy] that abstracts the application from proprietary (and usually checked) exceptions to a set of focused runtime exceptions. As mentioned in the Spring Framework documentation, http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#orm-exception-translation[exception translation] can be applied transparently to your data access objects through the use of the `@Repository` annotation and AOP by defining a `PersistenceExceptionTranslationPostProcessor` bean. The same exception translation functionality is enabled when using GemFire as long as at least a `CacheFactoryBean` is declared, e.g. using a `<gfe:cache/>` declaration, as it acts as an exception translator which is automatically detected by the Spring infrastructure and used accordingly.
[[apis:template]]
== GemfireTemplate
As with many other high-level abstractions provided by the Spring projects, Spring Data GemFire provides a *template* that simplifies GemFire data access. The class provides several *one-line* methods, for common region operations but also the ability to *execute* code against the native GemFire API without having to deal with GemFire checked exceptions for example through the `GemfireCallback`.
The template class requires a GemFire `Region` instance and once configured is thread-safe and should be reused across multiple classes:
[source,xml]
----
<bean id="gemfireTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="someRegion"/>
----
Once the template is configured, one can use it alongside `GemfireCallback` to work directly with the GemFire `Region`, without having to deal with checked exceptions, threading or resource management concerns:
[source,java]
----
template.execute(new GemfireCallback<Iterable<String>>() {
public Iterable<String> doInGemfire(Region reg) throws GemFireCheckedException, GemFireException {
// working against a Region of String
Region<String, String> region = reg;
region.put("1", "one");
region.put("3", "three");
return region.query("length < 5");
}
});
----
For accessing the full power of the GemFire query language, one can use the `find` and `findUnique` which, as opposed to the `query` method, can execute queries across multiple regions, execute projections, and the like. The `find` method should be used when the query selects multiple items (through`SelectResults`) and the latter, `findUnique`, as the name suggests, when only one object is returned.
[[apis:spring-cache-abstraction]]
== Support for Spring Cache Abstraction
Since 1.1, Spring Data GemFire provides an implementation of the Spring 3.1 http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#cache[cache abstraction]. To use GemFire as a backing implementation, simply add `GemfireCacheManager` to your configuration:
[source,xml]
----
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<!-- turn on declarative caching -->
<cache:annotation-driven/>
<gfe:cache id="gemfire-cache"/>
<!-- declare GemFire Cache Manager -->
<bean id="cacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager" p:cache-ref="gemfire-cache">
</beans>
----
[[apis:tx-mgmt]]
== Transaction Management
One of the most popular features of Spring Framework is http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#transaction[transaction management]. If you are not familiar with it, we strongly recommend http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#transaction-motivation[reading] about it as it offers a consistent programming model that works transparently across multiple APIs and can be configured either programmatically or declaratively (the most popular choice).
For GemFire, Spring Data GemFire provides a dedicated, per-cache, transaction manager that, once declared, allows Region operations to be executed atomically through Spring:
[source,xml]
----
<gfe:transaction-manager id="tx-manager" cache-ref="cache"/>
----
NOTE: The example above can be simplified even more by eliminating the `cache-ref` attribute if the GemFire Cache is defined under the default name`gemfireCache`. As with the other Spring Data GemFire namespace elements, if the Cache bean name is not configured, the aforementioned naming convention will used. Additionally, the transaction manager name is`gemfireTransactionManager` if not explicitly specified.
Currently, GemFire supports optimistic transactions with *read committed* isolation. Furthermore, to guarantee this isolation, developers should avoid making *in-place* changes that manually modify values present in the Cache. To prevent this from happening, the transaction manager configures the Cache to use *copy on read* semantics, meaning a clone of the actual value is created, each time a read is performed. This behavior can be disabled if needed through the `copyOnRead` property. For more information on the semantics of the underlying GemFire transaction manager, see the GemFire http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/CacheTransactionManager.html[documentation].
:leveloffset: +1
include::cq-container.adoc[]
:leveloffset: -1
[[apis:declarable]]
== Wiring `Declarable` components
GemFire XML configuration (usually named `cache.xml` allows *user* objects to be declared as part of the configuration. Usually these objects are `CacheLoader`s or other pluggable callback components supported by GemFire. Using native GemFire configuration, each user type declared through XML must implement the `Declarable` interface which allows arbitrary parameters to be passed to the declared class through a `Properties` instance.
In this section we describe how you can configure these pluggable components defined in `cache.xml` using Spring while keeping your Cache/Region configuration defined in `cache.xml` This allows your pluggable components to focus on the application logic and not the location or creation of DataSources or other collaboration objects.
However, if you are starting a green field project, it is recommended that you configure Cache, Region, and other pluggable components directly in Spring. This avoids inheriting from the `Declarable` interface or the base class presented in this section. See the following sidebar for more information on this approach.
.Eliminate `Declarable` components
****
One can configure custom types entirely through Spring as mentioned in <<bootstrap:region>>. That way, one does not have to implement the `Declarable` interface and also benefits from all the features of the Spring IoC container (not just dependency injection but also life-cycle and instance management).
****
As an example of configuring a `Declarable` component using Spring, consider the following declaration (taken from the `Declarable` javadoc):
[source,xml]
----
<cache-loader>
<class-name>com.company.app.DBLoader</class-name>
<parameter name="URL">
<string>jdbc://12.34.56.78/mydb</string>
</parameter>
</cache-loader>
----
To simplify the task of parsing, converting the parameters and initializing the object, Spring Data GemFire offers a base class (`WiringDeclarableSupport`) that allows GemFire user objects to be wired through a *template* bean definition or, in case that is missing, perform autowiring through the Spring container. To take advantage of this feature, the user objects need to extend `WiringDeclarableSupport` which automatically locates the declaring `BeanFactory` and performs wiring as part of the initialization process.
.Why is a base class needed?
****
In the current GemFire release there is no concept of an *object factory* and the types declared are instantiated and used as is. In other words, there is no easy way to manage object creation outside GemFire.
****
[[apis:declarable:template-wiring]]
=== Configuration using *template* definitions
When used, `WiringDeclarableSupport` tries to first locate an existing bean definition and use that as wiring template. Unless specified, the component class name will be used as an implicit bean definition name. Let's see how our `DBLoader` declaration would look in that case:
[source,java]
----
public class DBLoader extends WiringDeclarableSupport implements CacheLoader {
private DataSource dataSource;
public void setDataSource(DataSource ds){
this.dataSource = ds;
}
public Object load(LoaderHelper helper) { ... }
}
----
[source,xml]
----
<cache-loader>
<class-name>com.company.app.DBLoader</class-name>
<!-- no parameter is passed (use the bean implicit name
that is the class name) -->
</cache-loader>
----
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" ... />
<!-- template bean definition -->
<bean id="com.company.app.DBLoader" abstract="true" p:dataSource-ref="dataSource"/>
</beans>
----
In the scenario above, as no parameter was specified, a bean with the id/name `com.company.app.DBLoader` was used as a template for wiring the instance created by GemFire. For cases where the bean name uses a different convention, one can pass in the `bean-name` parameter in the GemFire configuration:
[source,xml]
----
<cache-loader>
<class-name>com.company.app.DBLoader</class-name>
<!-- pass the bean definition template name
as parameter -->
<parameter name="bean-name">
<string>template-bean</string>
</parameter>
</cache-loader>
----
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" ... />
<!-- template bean definition -->
<bean id="template-bean" abstract="true" p:dataSource-ref="dataSource"/>
</beans>
----
NOTE: The *template* bean definitions do not have to be declared in XML - any format is allowed (Groovy, annotations, etc..).
[[apis:declarable:autowiring]]
=== Configuration using auto-wiring and annotations
If no bean definition is found, by default, `WiringDeclarableSupport` will http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-factory-autowire[autowire] the declaring instance. This means that unless any dependency injection *metadata* is offered by the instance, the container will find the object setters and try to automatically satisfy these dependencies. However, one can also use JDK 5 annotations to provide additional information to the auto-wiring process. We strongly recommend reading the dedicated http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-annotation-config[chapter] in the Spring documentation for more information on the supported annotations and enabling factors.
For example, the hypothetical `DBLoader` declaration above can be injected with a Spring-configured `DataSource` in the following way:
[source,java]
----
public class DBLoader extends WiringDeclarableSupport implements CacheLoader {
// use annotations to 'mark' the needed dependencies
@javax.inject.Inject
private DataSource dataSource;
public Object load(LoaderHelper helper) { ... }
}
----
[source,xml]
----
<cache-loader>
<class-name>com.company.app.DBLoader</class-name>
<!-- no need to declare any parameters anymore
since the class is auto-wired -->
</cache-loader>
----
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- enable annotation processing -->
<context:annotation-config/>
</beans>
----
By using the JSR-330 annotations, the cache loader code has been simplified since the location and creation of the DataSource has been externalized and the user code is concerned only with the loading process. The `DataSource` might be transactional, created lazily, shared between multiple objects or retrieved from JNDI - these aspects can be easily configured and changed through the Spring container without touching the `DBLoader` code.

View File

@@ -0,0 +1,18 @@
[[bootstrap-diskstore]]
= Configuring a Disk Store
As of Release 1.2.0, Spring Data GemFire supports disk store configuration via a top level `disk-store` element.
NOTE: Prior to Release 1.2.0, `disk-store` was a child element of `*-region`. If you have regions configured with disk storage using a prior release of Spring Data GemFire and want to upgrade to the latest release, move the disk-store element to the top level, assign an id and use the region's `disk-store-ref` attribute. Also, `disk-synchronous` is now a region level attribute.
[source,xml]
----
<gfe:disk-store id="diskStore1" queue-size="50" auto-compact="true"
max-oplog-size="10" time-interval="9999">
<gfe:disk-dir location="/gemfire/store1/" max-size="20"/>
<gfe:disk-dir location="/gemfire/store2/" max-size="20"/>
</gfe:disk-store>
----
Disk stores are used by regions for file system persistent backup or overflow storage of evicted entries, and persistent backup of WAN gateways. Note that multiple components may share the same disk store. Also multiple directories may be defined for a single disk store. Please refer to the GemFire documentation for an explanation of the configuration options.

View File

@@ -0,0 +1,394 @@
[[function-annotations]]
= Annotation Support for Function Execution
== Introduction
Spring Data GemFire 1.3.0 introduces annotation support to simplify working with
http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/function_exec/chapter_overview.html[GemFire Function Execution].
The GemFire API provides classes to implement and register http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/Function.html[Functions]
deployed to Cache servers that may be invoked remotely by member applications, typically cache clients.
Functions may execute in parallel, distributed among multiple servers, combining results in a map-reduce pattern,
or may be targeted at a single server. A Function execution may be also be targeted to a specific Region.
GemFire also provides APIs to support remote execution of Functions targeted to various defined scopes
(Region, member groups, servers, etc.) and the ability to aggregate results. The API also provides certain
runtime options. The implementation and execution of remote Functions, as with any RPC protocol, requires
some boilerplate code. Spring Data GemFire, true to Spring's core value proposition, aims to hide the mechanics
of remote Function execution and allow developers to focus on POJO programming and business logic. To this end,
Spring Data GemFire introduces annotations to declaratively register public methods as GemFire Functions, and
the ability to invoke registered Functions remotely via annotated interfaces.
== Implementation vs Execution
There are two separate concerns to address. First is the Function implementation (server) which must interact with
the http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/FunctionContext.html[FunctionContext]
to obtain the invocation arguments, the http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/ResultSender.html[ResultsSender]
and other execution context information. The Function implementation typically accesses the Cache and or Region
and is typically registered with the http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/FunctionService.html[FunctionService]
under a unique Id. The application invoking a Function (the client) does not depend on the implementation. To invoke
a Function remotely, the application instantiates an http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/Execution.html[Execution]
providing the Function ID, invocation arguments, the Function target or scope (Region, server, servers,
member, members). If the Function produces a result, the invoker uses a http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/ResultCollector.html[ResultCollector]
to aggregate and acquire the execution results. In certain scenarios, a custom ResultCollector implementation
is required and may be registered with the Execution.
NOTE: 'Client' and 'Server' are used here in the context of Function execution which may have a different meaning
than client and server in a client-server Cache topology. While it is common for a member with a Client Cache
to invoke a Function on one or more Cache Server members it is also possible to execute Functions in a peer-to-peer
(P2P) configuration
== Implementing a Function
Using GemFire APIs, the FunctionContext provides a runtime invocation context including the client's calling arguments
and a ResultSender interface to send results back to the client. Additionally, if the Function is executed on a Region,
the FunctionContext is an instance of RegionFunctionContext which provides additional context such as the target Region
and any Filter (set of specific keys) associated with the Execution. If the Region is a PARTITION Region, the Function
should use the PartitionRegionHelper to extract only the local data.
Using Spring, a developer can write a simple POJO and enable the Spring container to bind one or more of it's
public methods to a Function. The signature for a POJO method intended to be used as a Function must generally
conform to the the client's execution arguments. However, in the case of a Region execution, the Region data
must also be provided (presumably the data held in the local partition if the Region is a PARTITION Region).
Additionally the Function may require the Filter that was applied, if any. This suggests that the client and server
may share a contract for the calling arguments but that the method signature may include additional parameters
to pass values provided by the FunctionContext. One possibility is that the client and server share a common interface,
but this is not required. The only constraint is that the method signature includes the same sequence
of calling arguments with which the Function was invoked after the additional parameters are resolved.
For example, suppose the client provides a String and int as the calling arguments. These are provided
by the FunctionContext as an array:
`Object[] args = new Object[]{"hello", 123}`
Then the Spring container should be able to bind to any method signature similar to the following. Let's ignore
the return type for the moment:
[source,java]
----
public Object method1(String s1, int i2) {...}
public Object method2(Map<?,?> data, String s1, int i2) {...}
public Object method3(String s1, Map<?,?>data, int i2) {...}
public Object method4(String s1, Map<?,?> data, Set<?> filter, int i2) {...}
public void method4(String s1, Set<?> filter, int i2, Region<?,?> data) {...}
public void method5(String s1, ResultSender rs, int i2);
public void method6(FunctionContest fc);
----
The general rule is that once any additional arguments, i.e. Region data and Filter, are resolved,
the remaining arguments must correspond exactly, in order and type, to the expected calling parameters.
The method's return type must be void or a type that may be serialized (either java.io.Serializable,
DataSerializable, or PDX serializable). The latter is also a requirement for the calling arguments.
The Region data should normally be defined as a Map, to facilitate unit testing, but may also be of type Region
if necessary. As shown in the example above, it is also valid to pass the FunctionContext itself, or the ResultSender,
if you need to control how the results are returned to the client.
=== Annotations for Function Implementation
The following example illustrates how annotations are used to expose a POJO as a GemFire Function:
[source,java]
----
@Component
public class ApplicationFunctions {
@GemfireFunction
public String function1(String value, @RegionData Map<?,?> data, int i2) { ... }
@GemfireFunction("myFunction", HA=true, optimizedForWrite=true, batchSize=100)
public List<String> function2(String value, @RegionData Map<?,?> data, int i2, @Filter Set<?> keys) { ... }
@GemfireFunction(hasResult=true)
public void functionWithContext(FunctionContext functionContext) { ... }
}
----
Note that the class itself must be registered as a Spring bean. Here the `@Component` annotation is used, but you may
register the bean by any method provided by Spring (e.g. XML configuration or Java configuration class). This allows
the Spring container to create an instance of this class and wrap it in a
https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/function/PojoFunctionWrapper.java[PojoFunctionWrapper] (PFW).
Spring creates one PFW instance for each method annotated with `@GemfireFunction`. Each will all share the same
target object instance to invoke the corresponding method.
NOTE: The fact that the Function class is a Spring bean may offer other benefits since it shares the ApplicationContext
with GemFire components such as a Cache and Regions. These may be injected into the class if necessary.
Spring creates the wrapper class and registers the Function with GemFire's Function Service. The Function id used
to register the Functions must be unique. By convention it defaults to the simple (unqualified) method name. Note that
this annotation also provides configuration attributes, `HA` and `optimizedForWrite` which correspond to properties
defined by GemFire's Function interface. If the method's return type is void, then the `hasResult` property
is automatically set to `false`; otherwise it is set to `true`.
For `void` return types, the annotation provides a `hasResult` attribute that can be set to true to override
this convention, as shown in the `functionWithContext` method above. Presumably, the intention is to use the
ResultSender directly to send results to the caller.
The PFW implements GemFire's Function interface, binds the method parameters, and invokes the target method in
its `execute()` method. It also sends the method's return value using the ResultSender.
==== Batching Results
If the return type is a Collection or Array, then some consideration must be given to how the results are returned.
By default, the PFW returns the entire Collection at once. If the number of items is large, this may incur
a performance penalty. To divide the payload into small sections (sometimes called chunking), you can set
the `batchSize` attribute, as illustrated in `function2`, above.
NOTE: If you need more control of the ResultSender, especially if the method itself would use too much memory
to create the Collection, you can pass the ResultSender, or access it via the FunctionContext, to use it directly
within the method.
==== Enabling Annotation Processing
In accordance with Spring standards, you must explicitly activate annotation processing for @GemfireFunction using XML:
[source,xml]
----
<gfe:annotation-driven/>
----
or by annotating a Java configuration class:
[source,java]
----
@EnableGemfireFunctions
----
[[function-execution]]
== Executing a Function
A process invoking a remote Function needs to provide calling arguments, a Function id, the execution target
(onRegion, onServers, onServer, onMember, onMembers) and optionally a Filter set. All a developer need do is
define an interface supported by annotations. Spring will create a dynamic proxy for the interface which will
use the FunctionService to create an Execution, invoke the Execution and coerce the results to a defined return type,
if necessary. This technique is very similar to the way Spring Data Repositories work, thus some of the configuration
and concepts should be familiar. Generally a single interface definition maps to multiple Function executions,
one corresponding to each method defined in the interface.
=== Annotations for Function Execution
To support client-side Function execution, the following annotations are provided: `@OnRegion`, `@OnServer`,
`@OnServers`, `@OnMember`, `@OnMembers`. These correspond to the Execution implementations GemFire's FunctionService
provides. Each annotation exposes the appropriate attributes. These annotations also provide an optional
`resultCollector` attribute whose value is the name of a Spring bean implementing
http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/ResultCollector.html[ResultCollector]
to use for the execution.
NOTE: The proxy interface binds all declared methods to the same execution configuration. Although it is expected
that single method interfaces will be common, all methods in the interface are backed by the same proxy instance
and therefore all share the same configuration.
Here are some examples:
[source,java]
----
@OnRegion(region="someRegion", resultCollector="myCollector")
public interface FunctionExecution {
@FunctionId("function1")
String doIt(String s1, int i2);
String getString(Object arg1, @Filter Set<Object> keys) ;
}
----
By default, the Function id is the simple (unqualified) method name. `@FunctionId` is used to bind this invocation
to a different Function id.
==== Enabling Annotation Processing
The client-side uses Spring's component scanning capability to discover annotated interfaces. To enable
Function execution annotation processing, you can use XML:
[source,xml]
----
<gfe-data:function-executions base-package="org.example.myapp.functions"/>
----
Note that the `function-executions` element is provided in the `gfe-data` namespace. The `base-package` attribute
is required to avoid scanning the entire classpath. Additional filters are provided as described in the Spring
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-scanning-filters[reference].
Optionally, a developer can annotate her Java configuration class:
[source,java]
----
@EnableGemfireFunctionExecutions(basePackages = "org.example.myapp.functions")
----
== Programmatic Function Execution
Using the annotated interface as described in the previous section, simply wire your interface into a bean
that will invoke the Function:
[source,java]
----
@Component
public class MyApp {
@Autowired FunctionExecution functionExecution;
public void doSomething() {
functionExecution.doIt("hello", 123);
}
}
----
Alternately, you can use a Function Execution template directly. For example `GemfireOnRegionFunctionTemplate` creates
an `onRegion` Function execution. For example:
[source,java]
----
Set<?,?> myFilter = getFilter();
Region<?,?> myRegion = getRegion();
GemfireOnRegionOperations template = new GemfireOnRegionFunctionTemplate(myRegion);
String result = template.executeAndExtract("someFunction",myFilter,"hello","world",1234);
----
Internally, Function executions always return a List. `executeAndExtract` assumes a singleton List containing the result
and will attempt to coerce that value into the requested type. There is also an `execute` method that returns the List
itself. The first parameter is the Function id. The Filter argument is optional. The following arguments are a
variable argument List.
== Function Execution with PDX
When using Spring Data GemFire's Function annotation support combined with GemFire's http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/data_serialization/gemfire_pdx_serialization.html[PDX serialization],
there are a few logistical things to keep in mind.
As explained above, and by way of example, typically developers will define GemFire Functions using POJO classes
annotated with Spring Data GemFire http://docs.spring.io/spring-data-gemfire/docs/1.6.0.M1/api/org/springframework/data/gemfire/function/annotation/package-frame.html[Function annotations]
as so...
[source,java]
----
public class OrderFunctions {
@GemfireFunction(...)
Order process(@RegionData data, Order order, OrderSource orderSourceEnum, Integer count);
}
----
NOTE: the Integer count parameter is an arbitrary argument as is the separation of the Order and OrderSource Enum,
which might be logical to combine. However, the arguments were setup this way to demonstrate the problem with
Function executions in the context of PDX.
Your Order and OrderSource enum might be as follows...
[source,java]
----
public class Order ... {
private Long orderNumber;
private Calendar orderDateTime;
private Customer customer;
private List<Item> items
...
}
public enum OrderSource {
ONLINE,
PHONE,
POINT_OF_SALE
...
}
----
Of course, a developer may define a Function Execution interface to call the 'process' GemFire Server Function...
[source,java]
----
@OnServer
public interface OrderProcessingFunctions {
Order process(Order order, OrderSource orderSourceEnum, Integer count);
}
----
Clearly, this `process(..)` Order Function is being called from a client-side, client Cache (`<gfe:client-cache/>`)
member-based application. This means that the Function arguments must be serializable. The same is true when
invoking peer-to-peer member Functions (`@OnMember(s)) between peers in the cluster. Any form of `distribution`
requires the data transmitted between client and server, or peers to be serializable.
Now, if the developer has configured GemFire to use PDX for serialization (instead of Java serialization, for instance)
it is common for developers to set the `read-serialized` attribute to *true* on the GemFire server(s)...
`<gfe:cache ... pdx-read-serialized="true"/>`
This causes all values read from the Cache (i.e. Regions) as well as information passed between client and servers,
or peers to remain in serialized form, include, but not limited to Function arguments.
GemFire will only serialize application domain object types that you have specifically configured (registered),
either using GemFire's http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/data_serialization/auto_serialization.html[ReflectionBasedAutoSerializer],
or specifically (and recommended) using a "custom" GemFire http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/data_serialization/use_pdx_serializer.html[PdxSerializer]
for your application domain types.
What is less than apparent, is that GemFire automatically handles Java Enum types regardless of whether they are
explicitly configured (registered with a `ReflectionBasedAutoSerializer` regex pattern to the `classes` parameter,
or handled by a "custom" GemFire `PdxSerializer`) or not, and despite the fact that Java Enums implement
`java.io.Serializable`.
So, when a developer has `pdx-read-serialized` set to *true* on the GemFire Servers on which the GemFire Functions
(including Spring Data GemFire registered, Function annotated POJO classes), then the developer may encounter surprising
behavior when invoking the Function Execution.
What the developer may pass as arguments when invoking the Function is...
[source,java]
----
orderProcessingFunctions.process(new Order(123, customer, Calendar.getInstance(), items), OrderSource.ONLINE, 400);
----
But, in actuality, what GemFire executes the Function on the Server is...
[source,java]
----
process(regionData, order:PdxInstance, :PdxInstanceEnum, 400);
----
Notice that the `Order` and `OrderSource` have passed to the Function as http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/pdx/PdxInstance.html[PDX instances].
Again, this is all because `read-serialized` is set to true on the GemFire Server, which may be necessary in cases
where the GemFire Servers are interacting with multiple different client types (e.g. native clients).
This flies in the face of Spring Data GemFire's, "strongly-typed", Function annotated POJO class method signatures,
as the developer is expecting application domain object types (not PDX serialized objects).
So, as of Spring Data GemFire (SDG) *1.6*, SDG introduces enhanced Function support to automatically convert method
arguments that are of type PDX to the desired application domain object types when the developer of the Function
expects his Function arguments to be "strongly-typed".
However, this also requires the developer to explicitly register a GemFire `PdxSerializer` on the GemFire Servers
where the SDG annotated POJO Function is registered and used, e.g. ...
[source,java]
----
<bean id="customPdxSerializer" class="x.y.z.serialization.pdx.MyCustomPdxSerializer"/>
<gfe:cache ... pdx-serializer-ref="customPdxSerializeer" pdx-read-serialized="true"/>
----
Alternatively, a developer my use GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/pdx/ReflectionBasedAutoSerializer.html[ReflectionBasedAutoSerializer].
Of course, it is recommend to use a "custom" `PdxSerializer` where possible to maintain finer grained control over your
serialization strategy.
Finally, Spring Data GemFire is careful not to convert your Function arguments if you really want to treat your
Function arguments generically, or as one of GemFire's PDX types...
[source,java]
----
@GemfireFunction
public Object genericFunction(String value, Object domainObject, PdxInstanceEnum enum) {
...
}
----
Spring Data GemFire will only convert PDX type data to corresponding application domain object types
if and only if the corresponding application domain object types are on the classpath the the Function annotated
POJO method expects it.
For a good example of "custom", "composed" application-specific GemFire `PdxSerializers` as well as appropriate
POJO Function parameter type handling based on the method signature, see Spring Data GemFire's
https://github.com/spring-projects/spring-data-gemfire/blob/master/src/test/java/org/springframework/data/gemfire/function/ClientCacheFunctionExecutionWithPdxIntegrationTest.java[ClientCacheFunctionExecutionWithPdxIntegrationTest] class.

View File

@@ -0,0 +1,17 @@
[[bootstrap:function]]
= Configuring GemFire's Function Service
As of Release 1.3.0, Spring Data GemFire provides <<function-annotations,annotation>> support for implementing and registering functions. Spring Data GemFire also provides namespace support for registering GemFire http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/execute/Function.html[Functions] for remote function execution. Please refer to the GemFire documentation for more information on the function execution framework. Functions are declared as Spring beans and must implement the `com.gemstone.gemfire.cache.execute.Function` interface or extend `com.gemstone.gemfire.cache.execute.FunctionAdapter`. The namespace uses a familiar pattern to declare functions:
[source,xml]
----
<gfe:function-service>
<gfe:function>
<bean class="com.company.example.Function1"/>
<ref bean="function2"/>
</gfe:function>
</gfe:function-service>
<bean id="function2" class="com.company.example.Function2"/>
----

View File

@@ -0,0 +1,91 @@
[[bootstrap:gateway]]
= Configuring WAN Gateways
WAN gateways provide a way to synchronize GemFire distributed systems across geographic distributed areas. As of Release 1.2.0, Spring Data GemFire provides namespace support for configuring WAN gateways as illustrated in the following examples:
== WAN Configuration in GemFire 7.0
GemFire 7.0 introduces new APIs for WAN configuration. While the original APIs provided in GemFire 6 are still supported, it is recommended that you use the new APIs if you are using GemFire 7.0. The Spring Data GemFire namespace supports either. In the example below, `GatewaySender`s are configured for a partitioned region by adding child elements to the region (`gateway-sender` and `gateway-sender-ref`). The `GatewaySender` may register `EventFilter`s and `TransportFilters`. Also shown below is an example configuration of an `AsyncEventQueue` which must also be wired into a region (not shown).
[source,xml]
----
<gfe:partitioned-region id="region-inner-gateway-sender" >
<gfe:gateway-sender
remote-distributed-system-id="1">
<gfe:event-filter>
<bean class="org.springframework.data.gemfire.example.SomeEventFilter"/>
</gfe:event-filter>
<gfe:transport-filter>
<bean class="org.springframework.data.gemfire.example.SomeTransportFilter"/>
</gfe:transport-filter>
</gfe:gateway-sender>
<gfe:gateway-sender-ref bean="gateway-sender"/>
</gfe:partitioned-region>
<gfe:async-event-queue id="async-event-queue" batch-size="10" persistent="true" disk-store-ref="diskstore"
maximum-queue-memory="50">
<gfe:async-event-listener>
<bean class="org.springframework.data.gemfire.example.SomeAsyncEventListener"/>
</gfe:async-event-listener>
</gfe:async-event-queue>
<gfe:gateway-sender id="gateway-sender" remote-distributed-system-id="2">
<gfe:event-filter>
<ref bean="event-filter"/>
<bean class="org.springframework.data.gemfire.example.SomeEventFilter"/>
</gfe:event-filter>
<gfe:transport-filter>
<ref bean="transport-filter"/>
<bean class="org.springframework.data.gemfire.example.SomeTransportFilter"/>
</gfe:transport-filter>
</gfe:gateway-sender>
<bean id="event-filter" class="org.springframework.data.gemfire.example.AnotherEventFilter"/>
<bean id="transport-filter" class="org.springframework.data.gemfire.example.AnotherTransportFilter"/>
----
On the other end of a `GatewaySender` is a corresponding `GatewayReceiver` to receive gateway events. The `GatewayReceiver` may also be configured with `EventFilter`s and `TransportFilter`s.
[source,xml]
----
<gfe:gateway-receiver id="gateway-receiver"
start-port="12345" end-port="23456" bind-address="192.168.0.1">
<gfe:transport-filter>
<bean class="org.springframework.data.gemfire.example.SomeTransportFilter"/>
</gfe:transport-filter>
</gfe:gateway-receiver>
----
Please refer to the GemFire product document for a detailed explanation of all the configuration options.
== WAN Configuration in GemFire 6.6
[source,xml]
----
<gfe:cache/>
<gfe:replicated-region id="region-with-gateway" enable-gateway="true" hub-id="gateway-hub"/>
<gfe:gateway-hub id="gateway-hub" manual-start="true">
<gfe:gateway gateway-id="gateway">
<gfe:gateway-listener>
<bean class="com.company.example.MyGatewayListener"/>
</gfe:gateway-listener>
<gfe:gateway-queue maximum-queue-memory="5" batch-size="3"
batch-time-interval="10" />
</gfe:gateway>
<gfe:gateway gateway-id="gateway2">
<gfe:gateway-endpoint port="1234" host="host1" endpoint-id="endpoint1"/>
<gfe:gateway-endpoint port="2345" host="host2" endpoint-id="endpoint2"/>
</gfe:gateway>
</gfe:gateway-hub>
----
A region may synchronize all or part of its contents to a gateway hub used to access one or more remote systems. The region must set `enable-gateway` to `true` and specify the `hub-id`.
NOTE: If just a hub-id is specified, Spring Data GemFire automatically assumes that the gateway should be enabled.
Please refer to the GemFire product document for a detailed explanation of all the configuration options.

View File

@@ -0,0 +1,110 @@
[[gemfire-bootstrap]]
= Bootstrapping a Spring ApplicationContext in GemFire
== Introduction
Normally, a Spring-based application will <<bootstrap,bootstrap GemFire>> using Spring Data GemFire's XML namespace. Just by specifying a `<gfe:cache/>` element in Spring Data GemFire configuration meta-data, a single, peer GemFire Cache instance will be created and initialized with default settings in the same JVM process as your application.
However, sometimes it is a requirement, perhaps imposed by your IT operations team, that GemFire must be fully managed and operated using the provided GemFire tool suite, such as with http://gemfire.docs.pivotal.io/latest/userguide/index.html#tools_modules/gfsh/chapter_overview.html[Gfsh]. Using *Gfsh*, even though the application and GemFire will share the same JVM process, GemFire will bootstrap your Spring application context rather than the other way around. So, using this approach GemFire, instead of an application server, or a Java main class using Spring Boot, will bootstrap and host your application.
Keep in mind, however, that GemFire is not an application server. In addition, there are limitations to using this approach where GemFire Cache configuration is concerned.
== Using GemFire to Bootstrap a Spring Context Started with Gfsh
In order to bootstrap a Spring application context in GemFire when starting a GemFire Server process using Gfsh, a user must make use of GemFire's http://gemfire.docs.pivotal.io/latest/userguide/index.html#basic_config/the_cache/setting_cache_initializer.html[Initalizer] functionality. An *Initializer* can be used to specify a callback application that is launched after the Cache is initialized by GemFire.
An *Initializer* is specified within an http://gemfire.docs.pivotal.io/latest/userguide/index.html#reference/topics/cache_xml.html#initializer[initializer] element using a minimal snippet of GemFire's native configuration meta-data inside a `cache.xml` file. The `cache.xml` file is required in order to bootstrap the Spring application context, much like a minimal snippet of Spring XML config is needed to bootstrap a Spring application context configured with component scanning (e.g. `<context:component-scan base-packages="..."/>`)
As of Spring Data GemFire 1.4, such an *Initializer* is already conveniently provided by the framework, the `org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer`. The typical, yet minimal configuration for this class inside GemFire's `cache.xml` file will look like the following:
[source,xml]
----
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
"http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
<initializer>
<class-name>org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer</class-name>
<parameter name="contextConfigLocations">
<string>classpath:application-context.xml</string>
</parameter>
</initializer>
</cache>
----
The `SpringContextBootstrappingInitializer` class follows similar conventions as Spring's ContextLoaderListener class for bootstrapping a Spring context inside a Web Application, where application context configuration files are specified with the `contextConfigLocations` Servlet Context Parameter. In addition, the `SpringContextBootstrappingInitializer` class can also be used with a `basePackages` parameter to specify a comma-separated list of base package containing the appropriately annotated application components that the Spring container will search using component scanning and create Spring beans for:
[source,xml]
----
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
"http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
<initializer>
<class-name>org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer</class-name>
<parameter name="basePackages">
<string>org.mycompany.myapp.services,org.mycompany.myapp.dao,...</string>
</parameter>
</initializer>
</cache>
----
Then, with a properly configured and constructed `CLASSPATH` along with the `cache.xml` file shown above specified as a command-line option when starting a GemFire Server in Gfsh, the command-line would be:
[source]
----
gfsh>start server --name=Server1 --log-level=config ...
--classpath="/path/to/spring-data-gemfire-1.4.0.jar:/path/to/application/classes.jar"
--cache-xml-file="/path/to/gemfire/cache.xml"
----
The `application-context.xml` can be any valid Spring context configuration meta-data including all the SDG namespace elements. The only limitation with this approach is that the GemFire Cache cannot be configured using the Spring Data GemFire namespace. In other words, none of the `<gfe:cache/>` element attributes, such as `cache-xml-location`, `properties-ref`, `critical-heap-percentage`, `pdx-serializer-ref`, `lock-lease`, etc can be specified. If used, these attributes will be ignored. The main reason for this is that GemFire itself has already created an initialized the Cache before the *Initializer* gets invoked. As such, the Cache will already exist and since it is a "Singleton", it cannot be re-initialized or have any of it's configuration augmented.
== Lazy-Wiring GemFire Components
Spring Data GemFire already provides existing support for wiring GemFire components (such as CacheListeners, CacheLoaders or CacheWriters) that are declared and created by GemFire in `cache.xml` using the `WiringDeclarableSupport` class as described in <<apis:declarable:autowiring>>. However, this only works when Spring does the bootstrapping (i.e. bootstraps GemFire). When your Spring application context is the one bootstrapped by GemFire, then these GemFire components go unnoticed since the Spring application context does not even exist yet! The Spring application context will not get created until GemFire calls the *Initializer*, which occurs after all the other GemFire components and configuration have already been created and initialized.
So, in order to solve this problem, a new `LazyWiringDeclarableSupport` class was introduced, that is, in a sense, Spring application context aware. The intention of this abstract base class is that any implementing class will register itself to be configured by the Spring application context created by GemFire after the *Initializer* is called. In essence, this give your GemFire managed component a chance to be configured and auto-wired with Spring beans defined in the Spring application context.
In order for your GemFire application component to be auto-wired by the Spring container, create a application class that extends the `LazyWiringDeclarableSupport` and annotate any class member that needs to be provided as a Spring bean dependency, similar to:
[source,java]
----
public static final class UserDataSourceCacheLoader extends LazyWiringDeclarableSupport implements CacheLoader<String, User> {
@Autowired
private DataSource userDataSource;
...
}
----
As implied by the CacheLoader example above, you might necessarily (although, rare) have defined both a Region and CacheListener component in GemFire `cache.xml`. The CacheLoader may need access to an application DAO, or perhaps Spring application context defined JDBC Data Source for loading "Users" into a GemFire Cache `REPLICATE` Region on start. Of course, one should be careful in mixing the different life-cycles of GemFire and the Spring Container together in this manner as not all use cases and scenarios are supported. The GemFire `cache.xml` configuration would be similar to the following (which comes from SDG's test suite):
[source,xml]
----
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
"http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
<region name="Users" refid="REPLICATE">
<region-attributes initial-capacity="101" load-factor="0.85">
<key-constraint>java.lang.String</key-constraint>
<value-constraint>org.springframework.data.gemfire.repository.sample.User</value-constraint>
<cache-loader>
<class-name>org.springframework.data.gemfire.support.SpringContextBootstrappingInitializerIntegrationTest$UserDataStoreCacheLoader</class-name>
</cache-loader>
</region-attributes>
</region>
<initializer>
<class-name>org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer</class-name>
<parameter name="basePackages">
<string>org.springframework.data.gemfire.support.sample</string>
</parameter>
</initializer>
</cache>
----

View File

@@ -0,0 +1,21 @@
[[ref-introduction]]
= Document Structure
The following chapters explain the core functionality offered by Spring Data GemFire.
<<bootstrap>> describes the configuration support provided for bootstrapping, configuring, initializing and accessing GemFire Caches, Cache Servers, Regions, and related Distributed System components.
<<apis>> explains the integration between the GemFire APIs and the various data access features available in Spring, such as transaction management and exception translation.
<<serialization>> describes the enhancements for GemFire (de)serialization and management of associated objects.
<<mapping>> describes persistence mapping for POJOs stored in GemFire using Spring Data.
<<gemfire-repositories>> describes how to create and use GemFire Repositories using Spring Data.
<<function-annotations>> describes how to create and use GemFire Functions using annotations.
<<gemfire-bootstrap>> describes how to bootstrap a Spring ApplicationContext running in a GemFire Server using Gfsh.
<<samples>> describes the samples provided with the distribution to illustrate the various features available in Spring Data GemFire.

View File

@@ -0,0 +1,86 @@
[[mapping]]
= POJO mapping
[[mapping.entities]]
== Entity Mapping
Spring Data GemFire provides support to map entities that will be stored in a GemFire data grid. The mapping metadata is defined using annotations at the domain classes just like this:
.Mapping a domain class to a GemFire Region
====
[source,java]
----
@Region("People")
public class Person {
@Id Long id;
String firstname;
String lastname;
@PersistenceConstructor
public Person(String firstname, String lastname) {
// …
}
}
----
====
The first thing you see here is the `@Region` annotation that can be used to customize the Region in which the `Person` class is stored in. The `@Id` annotation can be used to annotate the property that shall be used as the Cache key. The `@PersistenceConstructor` annotation actually helps disambiguating multiple potentially available constructors taking parameters and explicitly marking the one annotated as the one to be used to create entities. With none or only a single constructor you can omit the annotation.
In addition to storing entities in top-level Regions, entities can be stored in GemFire Sub-Regions, as so:
[source,java]
----
@Region("/Users/Admin")
public class Admin extends User {
}
@Region("/Users/Guest")
public class Guest extends User {
}
----
Be sure to use the full-path of the GemFire Region, as defined in Spring Data GemFire XML namespace configuration meta-data, as specified in the `id` or `name` attributes of the `<*-region>` bean definition.
As alternative to specifying the Region in which the entity will be stored using the `@Region` annotation on the entity class, you can also specify the `@Region` annotation on the entity's `Repository` abstraction. See <<gemfire-repositories>> for more details.
However, let's say you want to store a Person in multiple GemFire Regions (e.g. `People` and `Customers`), then you can define your corresponding `Repository` interface abstractions like so:
[source,java]
----
@Region("People")
public interface PersonRepository extends GemfireRepository<Person, String> {
}
@Region("Customers")
public interface CustomerRepository extends GemfireRepository<Person, String> {
...
}
----
[[mapping.pdx-serializer]]
== Mapping PDX Serializer
Spring Data GemFire provides a custom `PDXSerializer` implementation that uses the mapping information to customize entity serialization. Beyond that it allows customizing the entity instantiation by using the Spring Data `EntityInstantiator` abstraction. By default the serializer uses a `ReflectionEntityInstantiator` that will use the persistence constructor of the mapped entity (either the single declared one or explicitly annoted with `@PersistenceConstructor`). To provide values for constructor parameters it will read fields with name of the constructor parameters from the `PDXReader` supplied.
.Using @Value on entity constructor parameters
====
[source,java]
----
public class Person {
public Person(@Value("#root.foo") String firstname, @Value("bean") String lastname) {
// …
}
}
----
====
The entity annotated as such will get the field `foo` read from the `PDXReader` and handed as constructor parameter value for `firstname`. The value for `lastname` will be the Spring bean with name `bean`.

View File

@@ -0,0 +1,979 @@
[[bootstrap:region]]
= Configuring a GemFire Region
A region is required to store and retrieve data from the cache. `Region` is an interface extending `java.util.Map` and enables basic data access using familiar key-value semantics. The `Region` interface is wired into classes that require it so the actual region type is decoupled from the programming model . Typically each region is associated with one domain object, similar to a table in a relational database.
GemFire implements the following types of regions:
* *Replicated* - Data is replicated across all cache members that define the region. This provides very high read performance but writes take longer to perform the replication.
* *Partioned* - Data is partitioned into buckets among cache members that define the region. This provides high read and write performance and is suitable for very large data sets that are too big for a single node.
* *Local* - Data only exists on the local node.
* *Client* - Technically a client region is a local region that acts as a proxy to a replicated or partitioned region hosted on cache servers. It may hold data created or fetched locally. Alternately, it can be empty. Local updates are synchronized to the cache server. Also, a client region may subscribe to events in order to stay synchronized with changes originating from remote processes that access the same region.
For more information about the various region types and their capabilities as well as configuration options, please refer to the GemFire Developer's http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/book_intro.html[Guide] and community http://www.pivotal.io/big-data/pivotal-gemfire[site].
[[bootstrap:region:lookup]]
== Using an externally configured Region
For referencing Regions already configured through GemFire `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 bean definition:
[source,xml]
----
<gfe:lookup-region id="region-bean" name="Orders"/>
----
If the `name` is not specified, the bean's `id` will be used. The example above becomes:
[source,xml]
----
<!-- lookup for a region called 'Orders' -->
<gfe:lookup-region id="Orders"/>
----
NOTE: If the Region does not exist, an initialization exception will be thrown. For configuring new GemFire Regions, proceed to the appropriate sections below.
Note, in the previous examples, since no cache name was defined, the default naming convention (`gemfireCache`) was used. Alternately, one can reference the cache bean through the `cache-ref` attribute:
[source,xml]
----
<gfe:cache id="cache"/>
<gfe:lookup-region id="region-bean" name="Orders" cache-ref="cache"/>
----
`lookup-region` provides a simple way of retrieving existing, pre-configured Regions without exposing the Region semantics or setup infrastructure.
[[bootstrap:region:auto-lookup]]
== Auto Region Lookup
New, as of Spring Data GemFire 1.5, is the ability to "auto-lookup" all Regions defined in GemFire's native cache.xml file, and imported into Spring config
using the`cache-xml-location` attribute on the `<gfe:cache>` element in the GFE XML namespace.
For instance, given a GemFire `cache.xml` file of...
[source,xml]
----
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
"http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
<region name="Parent" refid="REPLICATE">
<region name="Child" refid="REPLICATE"/>
</region>
</cache>
----
A user may import the `cache.xml` file as follows...
[source,xml]
----
<gfe:cache cache-xml-location="cache.xml"/>
----
A user can then use the `<gfe:lookup-region>` element (e.g. `<gfe:lookup-region id="Parent"/>`) to reference specific
GemFire Regions as beans in the Spring context, or the user may choose to import all GemFire Regions defined
in `cache.xml` with the new...
[source,xml]
----
<gfe:auto-region-lookup/>
----
Spring Data GemFire will automatically create Spring beans referencing all GemFire Regions defined in `cache.xml`
that have not been explicitly added to the Spring context with `<gfe:lookup-region>` bean declarations.
It is important to realize that Spring Data GemFire uses a Spring http://docs.spring.io/spring/docs/4.0.7.RELEASE/javadoc-api/org/springframework/beans/factory/config/BeanPostProcessor.html[BeanPostProcessor]
to post process the Cache after it is both created and initialized to determine the Regions defined in GemFire to add
as beans in the Spring context.
You may inject these "auto-looked-up" Regions like any other bean defined in the Spring context with 1 exception; you
may need to define a `depends-on` association with the '`gemfireCache`' bean as follows...
[source,java]
----
package example;
import ...
@Repository("appDao")
@DependsOn("gemfireCache")
public class ApplicationDao extends DaoSupport {
@Resource(name = "Parent")
private Region<?, ?> parent;
@Resource(name = "/Parent/Child")
private Region<?, ?> child;
...
}
----
The above Java example is applicable when using the Spring context's `component-scan` functionality.
If you are declaring your components using Spring XML, then you would do...
[source,xml]
----
<bean class="example.ApplicationDao" depends-on="gemfireCache"/>
----
This ensures the GemFire Cache and all the Regions defined in `cache.xml` get created before any components
with auto-wire references when using the new `<gfe:auto-region-lookup>` element.
[[bootstrap:region:overview]]
== Configuring Regions
Spring Data GemFire provides comprehensive support for configuring any type of GemFire Region via the following elements:
* Local Region `<local-region>`
* Replicated Region `<replicated-region>`
* Partitioned Region `<partitioned-region>`
* Client Region `<client-region>`
For a comprehensive description of http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/region_options/region_types.html[Region types] please consult the GemFire product documentation.
[[bootstrap:region:common:attributes]]
=== Common Region Attributes
The following table(s) list attributes available for various region types:
[cols="1,2,2", options="header"]
.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:false (Note: The default was true prior to 1.3.0)*
| Indicates whether the Region should be closed at shutdown.
| cloning-enabled
| *boolean, default:false*
| When true, the updates are applied to a clone of the value and then the clone is saved to the cache. When false, the value is modified in place in the cache.
| concurrency-checks-enabled
| *boolean, default:true*
| Determines whether members perform checks to provide consistent handling for concurrent or out-of-order updates to distributed Regions.
| data-policy
| *See GemFire's http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/index.html[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.
| disk-synchronous
| *boolean, default:true*
| Indicates whether Disk Store writes are synchronous.
| enable-gateway
| *boolean, default:false*
| Indicates whether the Region will synchronize entries over a WAN Gateway.
| hub-id
| *The name of the Gateway Hub.*
| 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-if-exists
| *boolean, default:false*
| Ignores this bean definition configuration if the Region already exists in the GemFire Cache, resulting in a lookup instead.
| ignore-jta
| *boolean, default:false*
| Indicates whether the Region participates in JTA transactions.
| index-update-type
| *synchronous or asynchronous, default:synchronous*
| Indicates whether indices will be updated synchronously or asynchronously on entry creation.
| initial-capacity
| *integer, default:16*
| The initial memory allocation for number of Region entries.
| key-constraint
| *Any valid, fully-qualified Java class name.*
| The expected key type.
| load-factor
| *float, default:.75*
| Sets the initial parameters on the underlying java.util.ConcurrentHashMap used for storing Region entries.
| name
| *Any valid Region name.*
| The name of the Region definition. If not 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 (disk).
| shorcut
| *See http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/com/gemstone/gemfire/cache/RegionShortcut.html
| The RegionShortcut for this Region. Allows easy initialization of the region based on pre-defined defaults.
| statistics
| *boolean, default:false*
| Indicates whether the Region reports statistics.
| template
| *The name of a Region Template.*
| A reference to a bean created via one of the `*region-template` elements.
| value-constraint
| *Any valid, fully-qualified Java class name.*
| The expected value type.
|===
[[bootstrap:region:common:cache-listener]]
=== Cache Listeners
`CacheListeners` are registered with a Region to handle Region events such as entries being created, updated, destroyed,
etc. A `CacheListener` can be any bean that implements the http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/com/gemstone/gemfire/cache/CacheListener.html[`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 `CacheListener's` declared. The first references a top-level named Spring bean;
the second is an anonymous inner bean definition.
[source,xml]
----
<gfe:replicated-region id="region-with-listeners">
<gfe:cache-listener>
<!-- nested cache listener reference -->
<ref bean="c-listener"/>
<!-- nested cache listener declaration -->
<bean class="some.pkg.AnotherSimpleCacheListener"/>
</gfe:cache-listener>
<bean id="c-listener" class="some.pkg.SimpleCacheListener"/>
</gfe:replicated-region>
----
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.
WARNING: 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.
[source,xml]
----
<beans>
<gfe:replicated-region id="region-with-one listener">
<gfe:cache-listener ref="c-listener"/>
</gfe:replicated-region>
<bean id="c-listener" class="some.pkg.SimpleCacheListener"/>
</beans>
----
.Bean Reference Conventions
[NOTE]
====
The `cache-listener` element is an example of a common pattern used in the namespace anywhere GemFire provides
a callback interface to be implemented in order to invoke custom code in response to Cache or Region events.
Using Spring's IoC container, the implementation is a standard Spring bean. In order to simplify the configuration,
the schema allows a single occurrence of the `cache-listener` element, but it may contain nested bean references
and inner bean definitions in any combination if multiple instances are permitted. The convention is to use
the singular form (i.e., `cache-listener` vs `cache-listeners`) reflecting that the most common scenario will in fact
be a single instance. We have already seen examples of this pattern in the <<null,advanced cache>> configuration example.
====
[[bootstrap:region:common:loaders-writers]]
=== 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 data source, a database for example. A `CacheWriter` is invoked before 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 http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/com/gemstone/gemfire/cache/CacheLoader.html[`CacheLoader`] and http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/com/gemstone/gemfire/cache/CacheWriter.html[`CacheWriter`] for more details.
[[bootstrap:region:common:subregions]]
=== 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. The subregion's name attribute is the simple name. The above example might be configured as: [source,nonxml]
----
<beans>
<gfe:replicated-region name="Customer">
<gfe:replicated-region name="Address"/>
</gfe:replicated-region>
<gfe:replicated-region name="Employee">
<gfe:replicated-region name="Address"/>
</gfe:replicated-region>
</beans>
----
Note that the `Monospaced ([id])` attribute is not permitted for a subregion. The subregions will be created with bean names */Customer/Address* and */Employee/Address*, respectively. So they may be injected using the full path name into other beans that use them, such as `GemfireTemplate`. The full path should also be used in OQL query strings.
[[bootstrap:region:common:region-templates]]
== Region Templates
Also new as of Spring Data GemFire 1.5 is Region Templates. This feature allows developers to define common Region
configuration settings and attributes once and reuse the configuration among many Region bean definitions declared
in the Spring context.
Spring Data GemFire introduces 5 new tags to the SDG XML namespace (XSD):
[cols="1,2", options="header"]
.Region Template Tags
|===
| Tag Name
| Description
| `<gfe:region-template>`
| Defines common, generic Region attributes; extends `regionType` in the SDG 1.5 XSD
| `<gfe:local-region-template>`
| Defines common, 'Local' Region attributes; extends `localRegionType` in the SDG 1.5 XSD
| `<gfe:partitioned-region-template>`
| Defines common, 'PARTITION' Region attributes; extends `partitionedRegionType` in the SDG 1.5 XSD
| `<gfe:replicated-region-template>`
| Defines common, 'REPLICATE' Region attributes; extends `replicatedRegionType` in the SDG 1.5 XSD
| `<gfe:client-region-template>`
| Defines common, 'Client' Region attributes; extends `clientRegionType` in the SDG 1.5 XSD
|===
In addition to the new tags, `<gfe:*-region>` elements along with the `<gfe:*-region-template>` elements have
a `template` attribute used to define the Region Template from which to inherit the Region configuration. Even
Region templates may inherit from other Region Templates.
Here is an example of 1 possible configuration...
[source,xml]
----
<gfe:async-event-queue id="AEQ" persistent="false" parallel="false" dispatcher-threads="4">
<gfe:async-event-listener>
<bean class="example.AeqListener"/>
</gfe:async-event-listener>
</gfe:async-event-queue>
<gfe:region-template id="BaseRegionTemplate" cloning-enabled="true"
concurrency-checks-enabled="false" disk-synchronous="false"
ignore-jta="true" initial-capacity="51" key-constraint="java.lang.Long"
load-factor="0.85" persistent="false" statistics="true"
value-constraint="java.lang.String">
<gfe:cache-listener>
<bean class="example.CacheListenerOne"/>
<bean class="example.CacheListenerTwo"/>
</gfe:cache-listener>
<gfe:entry-ttl timeout="300" action="INVALIDATE"/>
<gfe:entry-tti timeout="600" action="DESTROY"/>
</gfe:region-template>
<gfe:region-template id="ExtendedRegionTemplate" template="BaseRegionTemplate"
index-update-type="asynchronous" cloning-enabled="false"
concurrency-checks-enabled="true" key-constraint="java.lang.Integer"
load-factor="0.55">
<gfe:cache-loader>
<bean class="example.CacheLoader"/>
</gfe:cache-loader>
<gfe:cache-writer>
<bean class="example.CacheWriter"/>
</gfe:cache-writer>
<gfe:membership-attributes required-roles="readWriteNode" loss-action="limited-access" resumption-action="none"/>
<gfe:async-event-queue-ref bean="AEQ"/>
</gfe:region-template>
<gfe:partitioned-region-template id="PartitionRegionTemplate" template="ExtendedRegionTemplate"
copies="1" local-max-memory="1024" total-max-memory="16384" recovery-delay="60000"
startup-recovery-delay="15000" enable-async-conflation="false"
enable-subscription-conflation="true" load-factor="0.70"
value-constraint="java.lang.Object">
<gfe:partition-resolver>
<bean class="example.PartitionResolver"/>
</gfe:partition-resolver>
<gfe:eviction type="ENTRY_COUNT" threshold="8192000" action="OVERFLOW_TO_DISK"/>
</gfe:partitioned-region-template>
<gfe:partitioned-region id="TemplateBasedPartitionRegion" template="PartitionRegionTemplate"
copies="2" local-max-memory="8192" total-buckets="91" disk-synchronous="true"
enable-async-conflation="true" ignore-jta="false" key-constraint="java.util.Date"
persistent="true">
<gfe:cache-writer>
<bean class="example.CacheWriter"/>
</gfe:cache-writer>
<gfe:membership-attributes required-roles="admin,root" loss-action="no-access" resumption-action="reinitialize"/>
<gfe:partition-listener>
<bean class="example.PartitionListener"/>
</gfe:partition-listener>
<gfe:subscription type="ALL"/>
</gfe:partitioned-region>
----
Region Templates will even work for Subregions. Notice that 'TemplateBasedPartitionRegion' extends 'PartitionRegionTemplate'
which extends 'ExtendedRegionTemplate' which extends 'BaseRegionTemplate'. Attributes and sub-elements defined in
subsequent, inherited Region bean definitions override what is in the parent.
=== Under-the-hood...
Spring Data GemFire applies Region Templates when the Spring application context configuration meta-data is *parsed*,
and therefore, must be declared in the order of inheritance, in other words, parent templates before children. This
ensures the proper configuration is applied, especially when element attributes or sub-elements are "overridden".
IMPORTANT: It is equally important to remember the Region types must only inherit from other similar typed Regions.
For instance, it is not possible for a `<gfe:replicated-region>` to inherit from a `<gfe:partitioned-region-template>`.
NOTE: Region Templates are single-inheritance.
[[bootstrap:region:common:regions-subregions-lookups-caution]]
== A Word of Caution on Regions, Subregions and Lookups
Prior to Spring Data GemFire 1.4, one of the underlying properties of the high-level `replicated-region`,
`partitioned-region`, `local-region` and `client-region` elements in Spring Data GemFire's XML namespace,
which correspond to GemFire's Region types based on Data Policy, is that these elements perform a lookup first
before attempting to create the region. This is done in case the region already exists, which might be the case
if the region was defined in GemFire's native configuration, e.g. `cache.xml`, thereby avoiding any errors.
This was by design, though subject to change.
WARNING: The Spring team highly recommends that the `replicated-region`, `partitioned-region`, `local-region`
and `client-region` elements be strictly used only for defining new regions. One of the problems with these elements
doing a lookup first is, if the developer assumed that defining a bean definition for a REPLICATE region would create
a new region, however, consequently a region with the same name already exists having different semantics for
eviction, expiration, subscription and/or other attributes, this could adversely affect application logic
and/or expectations thereby violating application requirements.
IMPORTANT: Recommended Practice - Only use the `replicated-region`, `partitioned-region`, `local-region`
and `client-region` XML namespace elements for defining new regions.
However, because the high-level region elements perform a lookup first, this can cause problems for
dependency injected region resources to application code, like DAOs or Repositories.
Take for instance the following native GemFire configuration file (e.g. `cachel.xml`)...
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
"http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
<region name="Customers" refid="REPLICATE">
<region name="Accounts" refid="REPLICATE">
<region name="Orders" refid="REPLICATE">
<region name="Items" refid="REPLICATE"/>
</region>
</region>
</region>
</cache>
----
Also, consider that you might have defined a DAO as follows...
[source,java]
----
public class CustomerAccountDao extends GemDaoSupport {
@Resource(name = "Customers/Accounts")
private Region customersAccounts;
...
}
----
Here, we are injecting a reference to the `Customers/Accounts` GemFire Region in our DAO. As such, it is not uncommon for a developer to define beans for all or some of these regions in Spring XML configuration meta-data as follows...
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
<gfe:cache cache-xml-location="classpath:cache.xml"/>
<gfe:lookup-region name="Customers/Accounts"/>
<gfe:lookup-region name="Customers/Accounts/Orders"/>
</beans>
----
Here the `Customers/Accounts` and `Customers/Accounts/Orders` GemFire Regions are referenced as beans in the Spring context as "Customers/Accounts" and "Customers/Accounts/Orders", respectively. The nice thing about using the `lookup-region` element and the corresponding syntax above is that it allows a developer to reference a subregion directly without unnecessarily defining a bean for the parent region (e.g. `Customers`).
However, if now the developer changes his/her configuration meta-data syntax to using the nested format, like so...
[source,xml]
----
<gfe:lookup-region name="Customers">
<gfe:lookup-region name="Accounts">
<gfe:lookup-region name="Orders"/>
</gfe:lookup-region>
</gfe:lookup-region>
----
Or, perhaps the developer erroneously chooses to use the high-level `replicated-region` element, which will do a lookup first, as in...
[source,xml]
----
<gfe:replicated-region name="Customers" persistent="true">
<gfe:replicated-region name="Accounts" persistent="true">
<gfe:replicated-region name="Orders" persistent="true"/>
</gfe:replicated-region>
</gfe:replicated-region>
----
Then the region beans defined in the Spring context will consist of the following: `{ "Customers", "/Customers/Accounts", "/Customers/Accounts/Orders" }.` This means the dependency injected reference (i.e. `@Resource(name = "Customers/Accounts"))` is now broken since no bean with name "Customers/Accounts" is defined.
GemFire is flexible in referencing both parent regions and subregions. The parent can be referenced as "/Customers" or "Customers" and the child as "/Customers/Accounts" or just "Customers/Accounts". However, Spring Data GemFire is very specific when it comes to naming beans after regions, typically always using the forward slash (/) to represents subregions (e.g. "/Customers/Accounts").
Therefore, it is recommended that users use either the nested `lookup-region` syntax as illustrated above, or define direct references with a leading forward slash (/) like so...
[source,xml]
----
<gfe:lookup-region name="/Customers/Accounts"/>
<gfe:lookup-region name="/Customers/Accounts/Orders"/>
----
The example above where the nested `replicated-region` elements were used to reference the subregions serves to illustrate the problem stated earlier. Are the Customers, Accounts and Orders Regions/Subregions persistent or not? Not, since the regions were defined in native GemFire configuration (i.e. `cache.xml`) and will exist by the time the cache is initialized, or once the `<gfe:cache>` bean is created. Since the high-level region XML namespace abstractions, like `replicated-region`, perform the lookup first, it uses the regions as defined in the `cache.xml` configuration file.
[[bootstrap:region:persistence]]
== Data Persistence
Regions can be made persistent. GemFire ensures that all the data you put into a region that is configured for persistence will be written to disk in a way that it can be recovered the next time you create the region. This allows data to be recovered after a machine or process failure or after an orderly shutdown and restart of GemFire.
To enable persistence with Spring Data GemFire, simply set the `persistent` attribute to true:
[source,xml]
----
<gfe:partitioned-region id="persitent-partition" persistent="true"/>
----
IMPORTANT: Persistence for partitioned regions is supported from GemFire 6.5 onwards - configuring this option on a previous release will trigger an initialization exception.
Persistence may also be configured using the `data-policy` attribute, set to one of http://gemfire.docs.pivotal.io/7.0.2/javadocs/japi/com/gemstone/gemfire/cache/DataPolicy.html[GemFire's data policy settings]. For instance...
[source,xml]
----
<gfe:partitioned-region id="persitent-partition" data-policy="PERSISTENT_PARTITION"/>
----
The data policy must match the region type and must also agree with the `persistent` attribute if explicitly set. An initialization exception will be thrown if, for instance, the `persistent` attribute is set to false, yet a persistent data policy was specified.
When persisting regions, it is recommended to configure the storage through the `disk-store` element for maximum efficiency. The diskstore is referenced using the disk-store-ref attribute. Additionally, the region may perform disk writes synchronously or asynchronously:
[source,xml]
----
<gfe:partitioned-region id="persitent-partition" persistent="true" disk-store-ref="myDiskStore" disk-synchronous="true"/>
----
This is discussed further in <<bootstrap-diskstore>>
[[bootstrap:region:subscription]]
== Subscription Interest Policy
GemFire allows configuration of subscriptions to control http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/events/configure_p2p_event_messaging.html[peer to peer event handling]. Spring Data GemFire provides a `<gfe:subscription/>` to set the interest policy on replicated and partitioned regions to either `ALL` or `CACHE_CONTENT`.
[source,xml]
----
<gfe:partitioned-region id="subscription-partition">
<gfe:subscription type="CACHE_CONTENT"/>
</gfe:partitioned-region>
----
[[bootstrap:region:eviction]]
== Data Eviction and Overflowing
Based on various constraints, each region can have an eviction policy in place for evicting data from memory.
Currently, in GemFire, eviction applies to the least recently used entry (also known as
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used[LRU]). Evicted entries are either destroyed
or paged to disk (also known as *overflow*).
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:
[source,xml]
----
<gfe:partitioned-region id="overflow-partition">
<gfe:eviction type="MEMORY_SIZE" threshold="512" action="OVERFLOW_TO_DISK"/>
</gfe:partitioned-region>
----
IMPORTANT: Replicas cannot use a `local destroy` eviction since that would invalidate them. See the GemFire docs
for more information.
When configuring regions for overflow, it is recommended to configure the storage through the `disk-store` element
for maximum efficiency.
For a detailed description of eviction policies, see the GemFire documentation (such as
http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/eviction/how_eviction_works.html[this] page).
[[bootstrap:region:expiration]]
== Data Expiration
GemFire allows you to control how long entries exist in the cache. Expiration is driven by elapsed time, as opposed to
Eviction, which is driven by memory usage. Once an entry expires it may no longer be accessed from the cache.
GemFire supports the following Expiration types:
* *Time-to-Live (TTL)* - The amount of time, in seconds, the object may remain in the cache after the last creation
or update. For entries, the counter is set to zero for create and put operations. Region counters are reset when
the Region is created and when an entry has its counter reset.
* *Idle Timeout (TTI)* - The amount of time, in seconds, the object may remain in the cache after the last access.
The Idle Timeout counter for an object is reset any time its TTL counter is reset. In addition, an entrys Idle Timeout
counter is reset any time the entry is accessed through a get operation or a netSearch . The Idle Timeout counter for a
Region is reset whenever the Idle Timeout is reset for one of its entries.
Each of these may be applied to the Region itself or entries in the Region. Spring Data GemFire provides `<region-ttl>`,
`<region-tti>`, `<entry-ttl>` and `<entry-tti>` Region child elements to specify timeout values and expiration actions.
[[bootstrap:region:expiration:annotation]]
== Annotation-based Data Expiration
As of Spring Data GemFire 1.7, a developer now has the ability to define Expiration policies and settings on individual
Region Entry values, or rather, application domain objects directly. For instance, a developer might define Expiration
settings on a Session-based application domain object like so...
[source,java]
----
@Expiration(timeout = "1800", action = "INVALIDATE")
public static class SessionBasedApplicationDomainObject {
}
----
In addition, a developer may also specify Expiration type specific settings on Region Entries using `@IdleTimeoutExpiration`
and `@TimeToLiveExpiration` for Idle Timeout (TTI) and Time-to-Live (TTL) Expiration, respectively...
[source,java]
----
@TimeToLiveExpiration(timeout = "3600", action = "LOCAL_DESTROY")
@IdleTimeoutExpiration(timeout = "1800", action = "LOCAL_INVALIDATE")
@Expiration(timeout = "1800", action = "INVALIDATE")
public static class AnotherSessionBasedApplicationDomainObject {
}
----
Both `@IdleTimeoutExpiration` and `@TimeToLiveExpiration` take precedence over the generic `@Expiration` annotation
when more than one Expiration annotation type is specified, as shown above. Though, neither `@IdleTimeoutExpiration`
nor `@TimeToLiveExpiration` overrides the other; rather they may compliment each other when different Region Entry
Expiration types, such as TTL and TTI, are configured.
[NOTE]
====
All @Expiration-based annotations apply only to Region Entry values. Expiration for a "Region" is not covered
by Spring Data GemFire's Expiration annotation support. However, GemFire and Spring Data GemFire do allow you to set
Region Expiration using the SDG XML namespace, like so...
[source,xml]
----
<gfe:*-region id="Example" persistent="false">
<gfe:region-ttl timeout="600" action="DESTROY"/>
<gfe:region-tti timeout="300" action="INVALIDATE"/>
</gfe:*-region>
----
====
Spring Data GemFire's @Expiration annotation support is implemented with GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/CustomExpiry.html[`CustomExpiry`] interface.
See http://gemfire.docs.pivotal.io/latest/userguide/index.html#developing/expiration/configuring_data_expiration.html[GemFire's User Guide] for more details
The Spring Data GemFire `AnnotationBasedExpiration` class (and `CustomExpiry` implementation) is specifically responsible
for processing the SDG @Expiration annotations and applying the Expiration policy and settings appropriately
for Region Entry Expiration on request.
To use Spring Data GemFire to configure specific GemFire Regions to appropriately apply the Expiration policy
and settings applied to your application domain objects annotated with @Expiration-based annotations, you must...
1. Define a Spring bean in the Spring ApplicationContext of type `AnnotationBasedExpiration` using the appropriate
constructor or one of the convenient factory methods. When configuring Expiration for a specific Expiration type,
such as Idle Timeout or Time-to-Live, then you should use one of the factory methods of the `AnnotationBasedExpiration`
class, like so...
+
[source,xml]
----
<bean id="ttlExpiration" class="org.springframework.data.gemfire.support.AnnotationBasedExpiration"
factory-method="forTimeToLive"/>
<gfe:partitioned-region id="Example" persistent="false">
<gfe:custom-entry-ttl ref="ttlExpiration"/>
</gfe:partitioned-region>
----
+
[NOTE]
====
To configure Idle Timeout (TTI) Expiration instead, then you would of course use the `forIdleTimeout` factory method
along with the `<gfe:custom-entry-tti ref="ttiExpiration"/>` element to set TTI.
====
2. (optional) Annotate your application domain objects that will be stored in the Region with Expiration policies
and custom settings using one of Spring Data GemFire's @Expiration annotations: `@Expiration`, `@IdleTimeoutExpiration`
and/or `@TimeToLiveExpiration`
3. (optional) In cases where particular application domain objects have not been annotated with Spring Data GemFire's
@Expiration annotations at all, but the GemFire Region is configured to use SDG's custom `AnnotationBasedExpiration` class
to determine the Expiration policy and settings for objects stored in the Region, then it is possible to set "default"
Expiration attributes on the `AnnotationBasedExpiration` bean by doing the following...
[source,xml]
----
<bean id="defaultExpirationAttributes" class="com.gemstone.gemfire.cache.ExpirationAttributes">
<constructor-arg value="600"/>
<constructor-arg value="#{T(com.gemstone.gemfire.cache.ExpirationAction).DESTROY}"/>
</bean>
<bean id="ttiExpiration" class="org.springframework.data.gemfire.support.AnnotationBasedExpiration"
factory-method="forIdleTimeout">
<constructor-arg ref="defaultExpirationAttributes"/>
</bean>
<gfe:partitioned-region id="Example" persistent="false">
<gfe:custom-entry-tti ref="ttiExpiration"/>
</gfe:partitioned-region>
----
You may have noticed that the Spring Data GemFire's @Expiration annotations use String as the attributes type, rather
than and perhaps more appropriately being strongly typed, i.e. `int` for 'timeout' and SDG'S `ExpirationActionType`
for 'action'. Why is that?
Well, enter one of Spring Data GemFire's other features, leveraging Spring's core infrastructure
for configuration convenience: Property Placeholders and Spring Expression Language (SpEL).
For instance, a developer can specify both the Expiration 'timeout' and 'action' using Property Placeholders
in the @Expiration annotation attributes...
[source,java]
----
@TimeToLiveExpiration(timeout = "${gemfire.region.entry.expiration.ttl.timeout}"
action = "${gemfire.region.entry.expiration.ttl.action}")
public class ExampleApplicationDomainObject {
}
----
Then, in your Spring context XML or in JavaConfig, you would declare the following beans...
[source,xml]
----
<util:properties id="expirationSettings">
<prop key="gemfire.region.entry.expiration.ttl.timeout">600</prop>
<prop key="gemfire.region.entry.expiration.ttl.action">INVALIDATE</prop>
...
</util:properties>
<context:property-placeholder properties-ref="expirationProperties"/>
----
This is both convenient when multiple application domain objects might share similar Expiration policies and settings,
or when you wish to externalize the configuration.
However, a developer may want more dynamic Expiration configuration determined by the state of the running system.
This is where the power of SpEL comes in and is the recommended approach. Not only can you refer to beans
in the Spring context and access bean properties, invoke methods, etc, the values for Expiration 'timeout' and 'action'
can be strongly typed. For example (building on the example above)...
[source,xml]
----
<util:properties id="expirationSettings">
<prop key="gemfire.region.entry.expiration.ttl.timeout">600</prop>
<prop key="gemfire.region.entry.expiration.ttl.action">#{T(org.springframework.data.gemfire.ExpirationActionType).DESTROY}</prop>
<prop key="gemfire.region.entry.expiration.tti.action">#{T(com.gemstone.gemfire.cache.ExpirationAction).INVALIDATE}</prop>
...
</util:properties>
<context:property-placeholder properties-ref="expirationProperties"/>
----
Then, on your application domain object...
[source,java]
----
@TimeToLiveExpiration(timeout = "@expirationSettings['gemfire.region.entry.expiration.ttl.timeout']"
action = "@expirationSetting['gemfire.region.entry.expiration.ttl.action']")
public class ExampleApplicationDomainObject {
}
----
You can imagine that the 'expirationSettings' bean could be a more interesting and useful object rather than a simple
instance of `java.util.Properties`. In this example, even the Properties ('expirationSettings') using using SpEL
to based the action value on the actual Expiration action enumerated types leading to more quickly identified failures
if the types ever change.
All of this has been demonstrated and tested in the Spring Data GemFire test suite, by way of example. See the
https://github.com/spring-projects/spring-data-gemfire[source] for further details.
[[bootstrap:region:local]]
== Local Region
Spring Data GemFire offers a dedicated `local-region` element for creating local regions. Local regions, as the name
implies, are standalone meaning they do not share data with any other distributed system member. Other than that,
all common region configuration options are supported. A minimal declaration looks as follows (again, the example
relies on the Spring Data GemFire namespace naming conventions to wire the cache):
[source,xml]
----
<gfe:local-region id="myLocalRegion" />
----
Here, a local region is created (if one doesn't exist already). The name of the region is the same as the bean id
(myLocalRegion) and the bean assumes the existence of a GemFire cache named `gemfireCache`.
[[bootstrap:region:replicate]]
== Replicated Region
One of the common region types is a *replicated region* or *replica*. In short, when a region is configured to be
a replicated region, every member that hosts that region stores a copy of the region's entries locally. Any update to
a replicated region is distributed to all copies of the region. When a replica is created, it goes through
an initialization stage 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 replica.
Spring Data GemFire offers a `replicated-region` element. A minimal declaration looks as follows.
All common configuration options are available for replicated regions.
[source,xml]
----
<gfe:replicated-region id="simpleReplica" />
----
[[bootstrap:region:partition]]
== Partitioned Region
Another region type supported out of the box by the Spring Data GemFire namespace is the partitioned region. To quote the GemFire docs:
"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. When using a partitioned region, applications are presented with a logical view of the region that looks like a single map containing all of the data in the region. Reads or writes to this map are transparently routed to the peer that hosts the entry that is the target of the operation. [...] 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 is created using 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:
[source,xml]
----
<!-- bean definition named 'distributed-partition' backed by a region named 'redundant' with 2 copies
and a nested resolver declaration -->
<gfe:partitioned-region id="distributed-partition" copies="2" total-buckets="4" name="redundant">
<gfe:partition-resolver>
<bean class="some.pkg.SimplePartitionResolver"/>
</gfe:partition-resolver>
</gfe:partitioned-region>
----
[[bootstrap:region:partition:options]]
=== `partitioned-region` Options
The following table offers a quick overview of configuration options specific to partitioned regions. These are in addition to the common region configuration options described above.
[cols="1,2,2", options="header"]
.partitioned-region options
|===
| Name
| Values
| Description
| partition-resolver
| *bean name*
| The name of the partitioned resolver used by this region, for custom partitioning.
| partition-listener
| *bean name*
| The name of the partitioned listener used by this region, for handling partition events.
| copies
| 0..4
| The number of copies for each partition for high-availability. By default, no copies are created meaning there is no redundancy. Each copy provides extra backup at the expense of extra storage.
| colocated-with
| *valid region name*
| The name of the partitioned region with which this newly created partitioned region is colocated.
| local-max-memory
| *positive integer*
| The maximum amount of memory, in megabytes, to be used by the region in *this* process.
| total-max-memory
| *any integer value*
| The maximum amount of memory, in megabytes, to be used by the region in *all* processes.
| recovery-delay
| *any long value*
| The delay in milliseconds that existing members will wait before satisfying redundancy after another member crashes. -1 (the default) indicates that redundancy will not be recovered after a failure.
| startup-recovery-delay
| *any long value*
| The delay in milliseconds that new members will wait before satisfying redundancy. -1 indicates that adding new members will not trigger redundancy recovery. The default is to recover redundancy immediately when a new member is added.
|===
[[bootstrap:region:client]]
== Client Region
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 classified in short in: peer-to-peer (p2p), client-server, and wide area cache network (or WAN). In the last two scenarios, it is common to declare *client* regions which connect to a cache server. Spring Data GemFire offers dedicated support for such configuration through <<bootstrap:cache:client>>, `client-region` and `pool` elements. As the names imply, the former defines a client region while the latter defines connection pools to be used/shared by the various client regions.
Below is a typical client region configuration:
[source,xml]
----
<!-- client region using the default client-cache pool -->
<gfe:client-region id="simple">
<gfe:cache-listener ref="c-listener"/>
</gfe:client-region>
<!-- region using its own dedicated pool -->
<gfe:client-region id="complex" pool-name="gemfire-pool">
<gfe:cache-listener ref="c-listener"/>
</gfe:client-region>
<bean id="c-listener" class="some.pkg.SimpleCacheListener"/>
<!-- pool declaration -->
<gfe:pool id="gemfire-pool" subscription-enabled="true">
<gfe:locator host="someHost" port="40403"/>
</gfe:pool>
----
As with the other region types, `client-region` supports `CacheListener``s` as well as a single `CacheLoader` or `CacheWriter`. It also requires a connection `pool` for connecting to a server. Each client can have its own pool or they can share the same one.
NOTE: In the above example, the pool is configured with a `locator`. The locator is a separate process used to discover cache servers in the distributed system and are recommended for production systems. It is also possible to configure the pool to connect directly to one or more cache servers using the `server` element.
For a full list of options to set on the client and especially on the pool, please refer to the Spring Data GemFire schema (<<appendix-schema>>) and the GemFire documentation.
[[bootstrap:region:client:interests]]
=== Client Interests
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:
[source,xml]
----
<gfe:client-region id="complex" pool-name="gemfire-pool">
<gfe:key-interest durable="true" result-policy="KEYS">
<bean id="key" class="java.lang.String">
<constructor-arg value="someKey" />
</bean>
</gfe:key-interest>
<gfe:regex-interest pattern=".*" receive-values="false"/>
</gfe:client-region>
----
A special key `ALL_KEYS` means interest is registered for all keys (identical to a regex interest of `.*`). The `receive-values` attribute indicates whether or not the values are received for create and update events. If true, values are received; if false, only invalidation events are received - refer to the GemFire documentation for more details.
[[bootstrap:region:json]]
== JSON Support
Gemfire 7.0 introduced support for caching JSON documents with OQL query support. These are stored internally as http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/pdx/PdxInstance.html[PdxInstance] types using the http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/pdx/JSONFormatter.html[JSONFormatter] to perform conversion to and from JSON strings. Spring Data GemFire provides a `<gfe-data:json-region-autoproxy/>` tag to enable a http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#aop-introduction[AOP with Spring] component to advise appropriate region operations, effectively encapsulating the JSONFormatter, allowing your application to work directly with JSON strings. In addition, Java objects written to JSON configured regions will be automatically converted to JSON using the Jackson ObjectMapper. Reading these values will return a JSON string.
By default, `<gfe-data:json-region-autoproxy/>` will perform the conversion on all regions. To apply this feature to selected regions, provide a comma delimited list of their ids via the `region-refs` attribute. Other attributes include a `pretty-print` flag (false by default) and `convert-returned-collections`. By default the results of region operations getAll() and values() will be converted for configured regions. This is done by creating a parallel structure in local memory. This can incur significant overhead for large collections. Set this flag to false to disable automatic conversion for these operation. NOTE: Certain region operations, specifically those that use GemFire's proprietary Region.Entry such as entries(boolean), entrySet(boolean) and getEntry() type are not targeted for AOP advice. In addition, the entrySet() method which returns a Set<java.util.Map.Entry<?,?>> is not affected.
[source,xml]
----
<gfe-data:json-region-autoproxy pretty-print="true" region-refs="myJsonRegion" convert-returned-collections="true"/>
----
This feature also works with seamlessly with GemfireTemplate operations, provided that the template is declared as a Spring bean. Currently native QueryService operations are not supported.

View File

@@ -0,0 +1,269 @@
[[gemfire-repositories]]
= GemFire Repositories
== Introduction
Spring Data GemFire provides support to use the Spring Data Repository abstraction to easily persist entities
into GemFire and execute queries. A general introduction to the Repository programming model has been provided
http://docs.spring.io/spring-data/data-commons/docs/current/reference/html/#repositories[here].
[[gemfire-repositories.spring-configuration]]
== Spring Configuration
To bootstrap Spring Data Repositories you use the `<repositories/>` element from the GemFire Data namespace:
.Bootstrap GemFire Repositories
====
[source,xml]
----
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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.xsd>
<gfe-data:repositories base-package="com.acme.repository" />
</beans>
----
====
This configuration snippet will look for interfaces below the configured base package and create Repository instances
for those interfaces backed by a `SimpleGemFireRepository`. Note that you have to have your domain classes correctly
mapped to configured Regions or the bootstrap process will fail otherwise.
[[gemfire-repositories.executing-queries]]
== Executing OQL Queries
The GemFire Repositories allow the definition of query methods to easily execute OQL Queries against the Region
the managed entity is mapped to.
.Sample Repository
====
[source,java]
----
@Region("myRegion")
public class Person { … }
----
[source,java]
----
public interface PersonRepository extends CrudRepository<Person, Long> {
Person findByEmailAddress(String emailAddress);
Collection<Person> findByFirstname(String firstname);
@Query("SELECT * FROM /Person p WHERE p.firstname = $1")
Collection<Person> findByFirstnameAnnotated(String firstname);
@Query("SELECT * FROM /Person p WHERE p.firstname IN SET $1")
Collection<Person> findByFirstnamesAnnotated(Collection<String> firstnames);
}
----
====
The first method listed here will cause the following query to be derived: `SELECT x FROM /MyRegion x WHERE x.emailAddress = $1`.
The second method works the same way except it's returning all entities found whereas the first one expects
a single result value. In case the supported keywords are not sufficient to declare your query or the method name
gets to verbose you can annotate the query methods with `@Query` as seen for methods 3 and 4.
[cols="1,2,2", options="header"]
.Supported keywords for query methods
|===
| Keyword
| Sample
| Logical result
| `GreaterThan`
| `findByAgeGreaterThan(int age)`
| `x.age > $1`
| `GreaterThanEqual`
| `findByAgeGreaterThanEqual(int age)`
| `x.age >= $1`
| `LessThan`
| `findByAgeLessThan(int age)`
| `x.age < $1`
| `LessThanEqual`
| `findByAgeLessThanEqual(int age)`
| `x.age <= $1`
| `IsNotNull`, `NotNull`
| `findByFirstnameNotNull()`
| `x.firstname =! NULL`
| `IsNull`, `Null`
| `findByFirstnameNull()`
| `x.firstname = NULL`
| `In`
| `findByFirstnameIn(Collection<String> x)`
| `x.firstname IN SET $1`
| `NotIn`
| `findByFirstnameNotIn(Collection<String> x)`
| `x.firstname NOT IN SET $1`
| (No keyword)
| `findByFirstname(String name)`
| `x.firstname = $1`
| `Like`
| `findByFirstnameLike(String name)`
| `x.firstname LIKE $1`
| `Not`
| `findByFirstnameNot(String name)`
| `x.firstname != $1`
| `IsTrue`, `True`
| `findByActiveIsTrue()`
| `x.active = true`
| `IsFalse`, `False`
| `findByActiveIsFalse()`
| `x.active = false`
|===
[[gemfire-repositories.oql-extension]]
== OQL Query Extensions with Annotations
Many query languages, such as Pivotal GemFire's OQL (Object Query Language), have extensions that are not directly
supported by the Spring Data Commons Repository infrastructure.
One of Spring Data Commons' Repository infrastructure goals is to function as the lowest common denominator to maintain
support and portability across the widest array of data stores available and in use for application development today.
Technically, this means developers can access multiple different data stores supported by Spring Data Commons within
their applications by reusing their existing application-specific Repository interfaces, a very convenient and powerful
abstraction.
To support GemFire's OQL Query language extensions and maintain portability across data stores, Spring Data GemFire
adds support for OQL Query extensions by way of Java Annotations. These new Annotations will be ignored by other
Spring Data Repository implementations (e.g. Spring Data Redis) that don't have similar query language extensions.
For instance, many data stores will most likely not implement GemFire's OQL `IMPORT` keyword. By implementing `IMPORT`
as an Annotation (`@Import`) rather than as part of the query method signature (specifically, the method 'name'),
this will not interfere with the parsing infrastructure when evaluating the query method name to construct
the appropriate data store language appropriate query.
Currently, the set of OQL Query language extensions that are supported by Spring Data GemFire include:
[cols="1,2,2,2", options="header"]
.Supported OQL Query extensions for query methods
|===
| Keyword
| Annotation
| Description
| Arguments
| http://gemfire.docs.pivotal.io/latest/userguide/developing/query_index/query_index_hints.html#topic_cfb_mxn_jq[HINT]
| `@Hint`
| OQL Query Index Hints
| `String[]` (e.g. @Hint({ "IdIdx", "TxDateIdx" }))
| http://gemfire.docs.pivotal.io/latest/userguide/developing/query_select/the_import_statement.html#concept_2E9F15B2FE9041238B54736103396BF7[IMPORT]
| `@Import`
| Qualify application-specific types.
| `String` (e.g. @Import("org.example.app.domain.Type"))
| http://gemfire.docs.pivotal.io/latest/userguide/developing/query_select/the_select_statement.html#concept_85AE7D6B1E2941ED8BD2A8310A81753E__section_25D7055B33EC47B19B1B70264B39212F[LIMIT]
| `@Limit`
| Limit the returned query result set.
| `Integer` (e.g. @Limit(10); default is Integer.MAX_VALUE)
| http://gemfire.docs.pivotal.io/latest/userguide/developing/query_additional/query_debugging.html#concept_2D557E24AAB24044A3DB36B3124F6748[TRACE]
| `@Trace`
| Enable OQL Query specific debugging.
| NA
|===
As an example, suppose you have a `Customers` application domain type and corresponding GemFire Region along with a
`CustomerRepository` and a query method to lookup `Customers` by last name, like so...
.Sample Repository
====
[source,java]
----
package ...;
import org.springframework.data.annotation.Id;
import org.springframework.data.gemfire.mapping.Region;
...
@Region("Customers")
public class Customer ... {
@Id
private Long id;
...
}
----
[source,java]
----
package ...;
import org.springframework.data.gemfire.repository.GemfireRepository;
...
public interface CustomerRepository extends GemfireRepository<Customer, Long> {
@Trace
@Limit(10)
@Hint("LastNameIdx")
@Import("org.example.app.domain.Customer")
List<Customer> findByLastName(String lastName);
...
}
----
====
This will result in the following OQL Query:
`<TRACE> <HINT 'LastNameIdx'> IMPORT org.example.app.domain.Customer; SELECT * FROM /Customers c WHERE c.lastName = $1 LIMIT 10`
Spring Data GemFire's Repository extension support is careful not to create conflicting declaratives when
the Query Annotation extensions are used in combination with the `@Query` annotation.
For instance, suppose you have a raw `@Query` annotated query method defined in your `CustomerRepository` like so...
.CustomerRepository
====
[source,java]
----
public interface CustomerRepository extends GemfireRepository<Customer, Long> {
@Trace
@Limit(10)
@Hint("CustomerIdx")
@Import("org.example.app.domain.Customer")
@Query("<TRACE> <HINT 'ReputationIdx'> SELECT DISTINCT * FROM /Customers c WHERE c.reputation > $1 ORDER BY c.reputation DESC LIMIT 5")
List<Customer> findDistinctCustomersByReputationGreaterThanOrderByReputationDesc(Integer reputation);
}
----
====
This query method results in the following OQL Query:
`IMPORT org.example.app.domain.Customer; <TRACE> <HINT 'ReputationIdx'> SELECT DISTINCT * FROM /Customers c WHERE c.reputation > $1
ORDER BY c.reputation DESC LIMIT 5`
As you can see, the `@Limit(10)` annotation will +not+ override the `LIMIT` defined explicitly in the raw query. As well,
`@Hint("CustomerIdx")` annotation does +not+ override the `HINT` explicitly defined in the raw query. Finally, the
`@Trace` annotation is redundant and has no additional effect.
[NOTE]
====
The "ReputationIdx" Index is probably not the most sensible index given the number of Customers who will possibly have
the same value for their reputation, which will effectively reduce the effectiveness of the index. Please choose
indexes and other optimizations wisely as an improper or poorly choosen index and have the opposite effect on your
performance given the overhead in maintaining the index. The "ReputationIdx" was only used to serve the purpose
of the example.
====

View File

@@ -0,0 +1,88 @@
[[samples]]
= Sample Applications
NOTE: Sample applications are now maintained in the https://github.com/spring-projects/spring-gemfire-examples[Spring Data GemFire Examples] repository.
The Spring Data GemFire project also includes one sample application. Named "Hello World", the sample demonstrates how to configure and use GemFire inside a Spring application. At runtime, the sample offers a *shell* to the user allowing him to run various commands against the grid. It provides an excellent starting point for users unfamiliar with the essential components or the Spring and GemFire concepts.
The sample is bundled with the distribution and is Maven-based. One can easily import them into any Maven-aware IDE (such as https://spring.io/tools/sts[Spring Tool Suite]) or run them from the command-line.
[[samples:hello-world]]
== Hello World
The Hello World sample demonstrates the core functionality of the Spring GemFire project. It bootstraps GemFire, configures it, executes arbitrary commands against it and shuts it down when the application exits. Multiple instances can be started at the same time as they will work with each other sharing data without any user intervention.
.Running under Linux
NOTE: If you experience networking problems when starting GemFire or the samples, try adding the following system property `java.net.preferIPv4Stack=true` to the command line (insert `-Djava.net.preferIPv4Stack=true`). For an alternative (global) fix especially on Ubuntu see this https://jira.spring.io/browse/SGF-28[link]
[[samples:hello-world:start-stop]]
=== Starting and stopping the sample
Hello World is designed as a stand-alone java application. It features a `Main` class which can be started either from your IDE of choice (in Eclipse/STS through `Run As/Java Application`) or from the command line through Maven using `mvn exec:java`. One can also use `java` directly on the resulting artifact if the classpath is properly set.
To stop the sample, simply type `exit` at the command line or press `Ctrl+C` to stop the VM and shutdown the Spring container.
[[samples:hello-world:run]]
=== Using the sample
Once started, the sample will create a shared data grid and allow the user to issue commands against it. The output will likely look as follows:
[source]
----
INFO: Created GemFire Cache [Spring GemFire World] v. X.Y.Z
INFO: Created new cache region [myWorld]
INFO: Member xxxxxx:50694/51611 connecting to region [myWorld]
Hello World!
Want to interact with the world ? ...
Supported commands are:
get <key> - retrieves an entry (by key) from the grid
put <key> <value> - puts a new entry into the grid
remove <key> - removes an entry (by key) from the grid
...
----
For example to add new items to the grid one can use:
[source]
----
-> Bold Section qName:emphasis level:5, chunks:[put 1 unu] attrs:[role:bold]
INFO: Added [1=unu] to the cache
null
-> Bold Section qName:emphasis level:5, chunks:[put 1 one] attrs:[role:bold]
INFO: Updated [1] from [unu] to [one]
unu
-> Bold Section qName:emphasis level:5, chunks:[size] attrs:[role:bold]
1
-> Bold Section qName:emphasis level:5, chunks:[put 2 two] attrs:[role:bold]
INFO: Added [2=two] to the cache
null
-> Bold Section qName:emphasis level:5, chunks:[size] attrs:[role:bold]
2
----
Multiple instances can be created at the same time. Once started, the new VMs automatically see the existing region and its information:
[source]
----
INFO: Connected to Distributed System ['Spring GemFire World'=xxxx:56218/49320@yyyyy]
Hello World!
...
-> Bold Section qName:emphasis level:5, chunks:[size] attrs:[role:bold]
2
-> Bold Section qName:emphasis level:5, chunks:[map] attrs:[role:bold]
[2=two] [1=one]
-> Bold Section qName:emphasis level:5, chunks:[query length = 3] attrs:[role:bold]
[one, two]
----
Experiment with the example, start (and stop) as many instances as you want, run various commands in one instance and see how the others react. To preserve data, at least one instance needs to be alive all times - if all instances are shutdown, the grid data is completely destroyed (in this example - to preserve data between runs, see the GemFire documentations).
[[samples:hello-world:explained]]
=== Hello World Sample Explained
Hello World uses both Spring XML and annotations for its configuration. The initial boostrapping configuration is `app-context.xml` which includes the cache configuration, defined under `cache-context.xml` file and performs classpath http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-classpath-scanning[scanning] for Spring http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-annotation-config[components]. The cache configuration defines the GemFire cache, region and for illustrative purposes a simple cache listener that acts as a logger.
The main *beans* are `HelloWorld` and `CommandProcessor` which rely on the `GemfireTemplate` to interact with the distributed fabric. Both classes use annotations to define their dependency and life-cycle callbacks.

View File

@@ -0,0 +1,45 @@
[[serialization]]
= Working with GemFire Serialization
To improve overall performance of the data grid, GemFire supports a dedicated serialization protocol (PDX) that is both faster and offers more compact results over the standard Java serialization and works transparently across various language http://community.gemstone.com/display/gemfire/Interoperability[platforms] (such as http://community.gemstone.com/display/gemfire/Serialization+in+Java[Java], http://community.gemstone.com/display/gemfire/Serialization+in+.NET[.NET] and C++). This chapter discusses the various ways in which Spring Data GemFire simplifies and improves GemFire custom serialization in Java.
[[serialization:wiring]]
== Wiring deserialized instances
It is fairly common for serialized objects to have transient data. Transient data is often dependent on the node or environment where it lives at a certain point in time, for example a DataSource. Serializing such information is useless (and potentially even dangerous) since it is local to a certain VM/machine. For such cases, Spring Data GemFire offers a special http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/Instantiator.html[`Instantiator`] that performs wiring for each new instance created by GemFire during deserialization.
Through such a mechanism, one can rely on the Spring container to inject (and manage) certain dependencies making it easy to split transient from persistent data and have *rich domain objects* in a transparent manner (Spring users might find this approach similar to that of http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#aop-atconfigurable[`@Configurable`]). The `WiringInstantiator` works just like `WiringDeclarableSupport`, trying to first locate a bean definition as a wiring template and following to autowiring otherwise. Please refer to the previous section (<<apis:declarable>>) for more details on wiring functionality.
To use this `Instantiator`, simply declare it as a usual bean:
[source,xml]
----
<bean id="instantiator" class="org.springframework.data.gemfire.serialization.WiringInstantiator">
<!-- DataSerializable type -->
<constructor-arg>org.pkg.SomeDataSerializableClass</constructor-arg>
<!-- type id -->
<constructor-arg>95</constructor-arg>
</bean>
----
During the container startup, once it is being initialized, the `instantiator` will, by default, register itself with the GemFire system and perform wiring on all instances of `SomeDataSerializableClass` created by GemFire during deserialization.
[[serialization:instance-generator]]
== Auto-generating custom `Instantiator`s
For data intensive applications, a large number of instances might be created on each machine as data flows in. Out of the box, GemFire uses reflection to create new types but for some scenarios, this might prove to be expensive. As always, it is good to perform profiling to quantify whether this is the case or not. For such cases, Spring Data GemFire allows the automatic generation of `Instatiator` classes which instantiate a new type (using the default constructor) without the use of reflection:
[source,xml]
----
<bean id="instantiator-factory" class="org.springframework.data.gemfire.serialization.InstantiatorFactoryBean">
<property name="customTypes">
<map>
<entry key="org.pkg.CustomTypeA" value="1025"/>
<entry key="org.pkg.CustomTypeB" value="1026"/>
</map>
</property>
</bean>
----
The definition above, automatically generated two `Instantiator`s for two classes, namely `CustomTypeA` and `CustomTypeB` and registers them with GemFire, under user id `1025` and `1026`. The two instantiators avoid the use of reflection and create the instances directly through Java code.

View File

@@ -0,0 +1,234 @@
[[bootstrap:snapshot]]
= Using the GemFire Snapshot Service
Spring Data GemFire supports `Cache` and `Region` snapshots using http://gemfire81.docs.pivotal.io/latest/userguide/index.html#managing/cache_snapshots/chapter_overview.html[GemFire's Snapshot Service].
The out-of-the-box Snapshot Service support offers several convenient features to simply the use of GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/CacheSnapshotService.html[Cache]
and http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/RegionSnapshotService.html[Region] Snapshot Service APIs.
As http://gemfire81.docs.pivotal.io/latest/userguide/index.html#managing/cache_snapshots/chapter_overview.html[GemFire documentation] describes,
snapshots allow you to save and subsequently reload the data later, which can be useful for moving data between environments,
say from production to a staging or test environment in order to reproduce data-related issues in a controlled context.
You can imagine combining Spring Data GemFire's Snapshot Service support with http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#beans-definition-profiles[Spring's bean definition profiles]
to load snapshot data specific to the environment as necessary.
Spring Data GemFire's support for GemFire's Snapshot Service begins with the `<gfe-data:snapshot-service>` element
from the GFE Data Access Namespace. For example, I might define Cache-wide snapshots to be loaded as well as saved
with a couple snapshot imports and a single data export definition as follows:
[source,xml]
----
<gfe-data:snapshot-service id="gemfireCacheSnapshotService">
<gfe-data:snapshot-import location="/absolute/filesystem/path/to/import/fileOne.snapshot"/>
<gfe-data:snapshot-import location="relative/filesystem/path/to/import/fileTwo.snapshot"/>
<gfe-data:snapshot-export
location="/absolute/or/relative/filesystem/path/to/export/directory"/>
</gfe-data:snapshot-service>
----
You can define as many imports and/or exports as you like. You can define just imports or just exports. The file locations
and directory paths can be absolute, or relative to the Spring Data GemFire application JVM process's working directory.
This is a pretty simple example and the snapshot service defined in this case refers to the GemFire `Cache`, having a
default name of `gemfireCache` (as described in <<bootstrap:cache>>). If you name your cache bean definition something
different, than you can use the `cache-ref` attribute to refer to the cache bean by name:
[source,xml]
----
<gfe:cache id="myCache"/>
...
<gfe-data:snapshot-service id="mySnapshotService" cache-ref="myCache">
...
</gfe-data:snapshot-service>
----
It is also straightforward to define a snapshot service for a GemFire Region by specifying the `region-ref` attribute:
[source,xml]
----
<gfe:partitioned-region id="Example" persistent="false" .../>
...
<gfe-data:snapshot-service id="gemfireCacheRegionSnapshotService" region-ref="Example">
<gfe-data:snapshot-import location="relative/path/to/import/example.snapshot/>
<gfe-data:snapshot-export location="/path/to/export/example.snapshot/>
</gfe-data:snapshot-service>
----
When the `region-ref` attribute is specified the Spring Data GemFire `SnapshotServiceFactoryBean` resolves
the `region-ref` attribute to a Region bean defined in the Spring context and then proceeds to create a
http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/RegionSnapshotService.html[RegionSnapshotService].
Again, the snapshot import and export definitions function the same way, however, the `location` must refer to a file
on export.
NOTE: GemFire is strict about imported snapshot files actually existing before they are referenced. For exports,
GemFire will create the snapshot file if it does not already exist. If the snapshot file for export already exists,
the data will be overwritten.
NOTE: Spring Data GemFire includes a `suppress-import-on-init` attribute to the `<gfe-data:snapshot-service>` element
to suppress the configured snapshot service from trying to import data into the Cache or a Region on initialization.
This is useful when data exported from 1 Region is used to feed the import of another Region, for example.
[[bootstrap:snapshot:location]]
== Snapshot Location
For a `Cache`-based SnapshotService (i.e. a GemFire http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/CacheSnapshotService.html[CacheSnapshotService])
a developer would typically pass it a directory containing all the snapshot files to load rather than individual snapshot files,
as the overloaded http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/CacheSnapshotService.html#load(java.io.File,%20com.gemstone.gemfire.cache.snapshot.SnapshotOptions.SnapshotFormat)[load] method
in the `CacheSnapshotService` API indicates.
NOTE: Of course, a developer may use the other, overloaded `load(:File[], :SnapshotFormat, :SnapshotOptions)` method
variant to get specific about which snapshot files are to be loaded into the GemFire `Cache`.
However, Spring Data GemFire recognizes that a typical developer workflow might be to extract and export data from one environment
into several snapshot files, zip all of them up, and then conveniently move the ZIP file to another environment for import.
As such, Spring Data GemFire enables the developer to specify a JAR or ZIP file on import for a `Cache`-based SnapshotService
as follows:
[source,xml]
----
<gfe-data:snapshot-service id="cacheBasedSnapshotService" cache-ref="gemfireCache">
<gfe-data:snapshot-import location="/path/to/snapshots.zip"/>
</gfe-data:snapshot-service>
----
Spring Data GemFire will conveniently extract the provided ZIP file and treat it like a directory import (load).
[[bootstrap:snapshot:filters]]
== Snapshot Filters
The real power of defining multiple snapshot imports and exports is realized through the use of snapshot filters.
Snapshot filters implement GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/SnapshotFilter.html[SnapshotFilter] interface
and are used to filter Region entries for inclusion into the Region on import and for inclusion into the snapshot on export.
Spring Data GemFire makes it brain dead simple to utilize snapshot filters on import and export using the `filter-ref`
attribute or an anonymous, nested bean definition:
[source,xml]
----
<gfe:cache/>
<gfe:partitioned-region id="Admins" persistent="false"/>
<gfe:partitioned-region id="Guests" persistent="false"/>
<bean id="activeUsersFilter" class="org.example.app.gemfire.snapshot.filter.ActiveUsersFilter/>
<gfe-data:snapshot-service id="adminsSnapshotService" region-ref="Admins">
<gfe-data:snapshot-import location="/path/to/import/users.snapshot">
<bean class="org.example.app.gemfire.snapshot.filter.AdminsFilter/>
</gfe-data:snapshot-import>
<gfe-data:snapshot-export location="/path/to/export/active/admins.snapshot"
filter-ref="activeUsersFilter"/>
</gfe-data:snapshot-service>
<gfe-data:snapshot-service id="guestsSnapshotService" region-ref="Guests">
<gfe-data:snapshot-import location="/path/to/import/users.snapshot">
<bean class="org.example.app.gemfire.snapshot.filter.GuestsFilter/>
</gfe-data:snapshot-import>
<gfe-data:snapshot-export location="/path/to/export/active/guests.snapshot"
filter-ref="activeUsersFilter"/>
</gfe-data:snapshot-service>
----
In addition, more complex snapshot filters can be expressed with the `ComposableSnapshotFilter` Spring Data GemFire class.
This class implements GemFire's http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/snapshot/SnapshotFilter.html[SnapshotFilter] interface
as well as the https://en.wikipedia.org/wiki/Composite_pattern[Composite] software design pattern. In a nutshell, the
https://en.wikipedia.org/wiki/Composite_pattern[Composite] design pattern allows developers to compose multiple objects
of the same type and treat the conglomerate as single instance of the object type, a very powerful and useful abstraction
to be sure.
The `ComposableSnapshotFilter` has two factory methods, `'and'` and `'or'`, allowing developers to logically combine individual
snapshot filters using the AND and OR logical operators, respectively. The factory methods just take a list of snapshot filters.
One is only limited by his/her imagination to leverage this powerful construct, for instance:
[source,xml]
----
<bean id="activeUsersSinceFilter" class="org.springframework.data.gemfire.snapshot.filter.ComposableSnapshotFilter"
factory-method="and">
<constructor-arg index="0">
<list>
<bean class="org.example.app.gemfire.snapshot.filter.ActiveUsersFilter"/>
<bean class="org.example.app.gemfire.snapshot.filter.UsersSinceFilter"
p:since="2015-01-01"/>
</list>
</constructor-arg>
</bean>
----
You could then go onto combine the `activesUsersSinceFilter` with another filter using `'or'` like so:
[source,xml]
----
<bean id="covertOrActiveUsersSinceFilter" class="org.springframework.data.gemfire.snapshot.filter.ComposableSnapshotFilter"
factory-method="or">
<constructor-arg index="0">
<list>
<ref bean="activeUsersSinceFilter"/>
<bean class="org.example.app.gemfire.snapshot.filter.CovertUsersFilter"/>
</list>
</constructor-arg>
</bean>
----
[[bootstrap::snapshot::events]]
== Snapshot Events
By default, Spring Data GemFire uses GemFire's Snapshot Services on startup to import data and shutdown to export data.
However, you may want to trigger periodic, event-based snapshots, for either import or export from within your application.
For this purpose, Spring Data GemFire defines two additional Spring application events (extending Spring's http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/ApplicationEvent.html[ApplicationEvent] class)
for imports and exports, respectively: `ImportSnapshotApplicationEvent` and `ExportSnapshotApplicationEvent`.
The two application events can be targeted at the entire GemFire Cache, or individual GemFire Regions. The constructors
of these `ApplicationEvent` classes accept an optional Region pathname (e.g. "/Example") as well as 0 or more
`SnapshotMetadata` instances.
The array of `SnapshotMetadata` is used to override the snapshot meta-data defined by `<gfe-data:snapshot-import>`
and `<gfe-data:snapshot-export>` sub-elements in XML, which will be used in cases where snapshot application events
do not explicitly provide `SnapshotMetadata`. Each individual `SnapshotMetadata` instance can define it's own `location`
and `filters` properties.
Import/export snapshot application events are received by all snapshot service beans defined in the Spring application context.
However, import/export events are only processed by "matching" snapshot service beans.
A Region-based `[Import|Export]SnapshotApplicationEvent` matches if the snapshot service bean defined is a `RegionSnapshotService`
and it's Region reference (as determined by `region-ref`) matches the Region's pathname specified by the snapshot application event.
A Cache-based `[Import|Export]SnapshotApplicationEvent` (i.e. a snapshot application event without a Region pathname) triggers
all snapshot service beans, including any `RegionSnapshotService` beans, to perform either an import or export, respectively.
It is very easy to use Spring's http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/ApplicationEventPublisher.html[ApplicationEventPublisher] interface
to fire import and/or export snapshot application events from your application like so:
[source,java]
----
@Component
public class ExampleApplicationComponent {
@Autowired
private ApplicationEventPublisher eventPublisher;
@Resource(name = "Example")
private Region<?, ?> example;
public void someMethod() {
...
SnapshotFilter myFilter = ...;
SnapshotMetadata exportSnapshotMetadata = new SnapshotMetadata(new File(System.getProperty("user.dir"),
"/path/to/export/data.snapshot"), myFilter, null);
eventPublisher.publishEvent(new ExportSnapshotApplicationEvent(this, example.getFullPath(), exportSnapshotMetadata);
...
}
}
----
In this particular example, only the "/Example" Region's SnapshotService bean will pick up and handle the export event,
saving the filtered "/Example" Region's data to the "data.snapshot" file in a sub-direcrtory of the application's
working directory.
Using Spring application events and messaging subsystem is a good way to keep your application loosely coupled. It is
also not difficult to imagine that the snapshot application events could be fired on a periodic basis using Spring's
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#scheduling-task-scheduler[Scheduling] services.

View File

@@ -0,0 +1,641 @@
SPRING DATA GEMFIRE CHANGELOG
-----------------------------
http://www.springsource.org/spring-gemfire
=============================
Changes in version 1.7.2.RELEASE (2015-12-18)
---------------------------------------------
* SGF-456 - Release 1.7.2 (Gosling).
* SGF-455 - Fix creation of GemfireMappingContext for repositories.
* SGF-450 - GemfireRepositoryFactoryBean needs to explicitly register the "default" GemfireMappingContext when not explicitly defined as a bean in the application's Spring context.
* SGF-449 - GemfireRepositoryFactoryBean.setGemfireMappingContext needs to call RepositoryFactoryBeanSupport.setMappingContext.
* SGF-448 - GemfireRepositoryConfigurationExtension needs to override the RepositoryConfigurationExtensionSupport postProcess(:BeanDefinitionBuilder, :AnnotationRepositoryConfigurationSource) method.
* SGF-447 - Fix Spring Data GemFire due to recent changes to Apache Geode that removed various internal utility classes in favor of external Spring classes.
Changes in version 1.7.1.RELEASE (2015-11-15)
---------------------------------------------
* SGF-446 - Release 1.7.1 (Gosling).
* SGF-443 - Fix Spring Data GemFire apache-geode build due to recent changes to Apache Geode that removed the HDFS support.
* SGF-442 - Remove incorrect statements about GemFire Java Reflection-based (PDX) Serialization in the SDG Reference Guide.
* SGF-437 - Upgrade to Spring Framework 4.1.8.RELEASE.
* SGF-434 - Add a durable GemFire client cache test to assert proper behavior by SDG.
* SGF-433 - Fix improper resolution of Spring property placeholders in 'locators' and 'servers' attributes on the '<gfe:pool>' element(s) in Spring XML config.
* SGF-432 - IndexFactoryBean traps IndexExistsException instead of IndexNameConflictException.
* SGF-430 - Cleanup test failures on Windows due to incorrect Spring test context configuration resource resolution.
* SGF-429 - GemfirePersistentProperty considers a BigDecimal property an entity.
* SGF-427 - Update Spring Data GemFire Reference Guide 'New in the 1.7 Release' section.
Changes in version 1.5.4.RELEASE (2015-10-14)
---------------------------------------------
* SGF-436 - Release 1.5.4 (Evans).
Changes in version 1.7.0.RELEASE (2015-09-01)
---------------------------------------------
* SGF-426 - Release 1.7 GA (Gosling).
* SGF-425 - Allow early initialization and re-initialization of LazyWiringDeclarableSupport instances.
* SGF-423 - Handle improper ClassCastException thrown from SDG's Function Execution interface and annotation-based support when a GemFire Function throws an Exception.
* SGF-419 - Documentation error on page 22 in the Spring Data GemFire Reference PDF.
* SGF-408 - Provide support in the SDG XML namespace to load a pre-defined data set using GemFire Snapshot Service for development and testing purposes.
* SGF-392 - Add support for OQL Query statement extensions in Repository Query methods via Annotations.
Changes in version 1.7.0.RC1 (2015-08-04)
-----------------------------------------
* SGF-422 - Release 1.7 RC1 (Gosling).
* SGF-421 - Fix Spring Data GemFire's MappingPdxSerializer due to the package-private access modifier change on org.springframework.data.mapping.model.BeanWrapper.
* SGF-418 - Merge PR #83 updating the Spring IO Platform Plugin to perform compatibility checks.
* SGF-417 - Update apache-geode SDG branch based on the latest Apache Geode developments (snapshot 20150713182515).
* SGF-415 - Remove the ClientCacheFactory Pool configuration in ClientCacheFactoryBean.
* SGF-414 - Resolve incompatibility between the DistributedSystem created by the PoolFactoryBean and the DistributedSystem resolved by the ClientCacheFactoryBean when SSL is configured.
* SGF-410 - Enable the definition and creation of a generic, GemFire Cache Region with out-the-box defaults.
* SGF-409 - Modify the GemfireDataSourcePostProcessor (basis for <gfe:datasource>) to not assume a GemFire Server was configured and bootstrapped with Spring and subsequently that the SDG ListRegionsOnServerFunction was registered.
* SGF-407 - Modify the MappingPdxSerializer to allow for extensibility.
* SGF-406 - Fix JavaDoc build.
* SGF-404 - Enable Expiration settings and policies to be specified per application domain object using an @Expiration annotation and a "custom", SDG-provided CustomExpiry instance.
* SGF-398 - Provide early support of Apache Geode (Pivotal GemFire OSS).
* SGF-370 - Add multi-Index definition and creation support.
Changes in version 1.6.2.RELEASE (2015-07-28)
---------------------------------------------
* SGF-420 - Release 1.6.2 (Fowler).
* SGF-415 - Remove the ClientCacheFactory Pool configuration in ClientCacheFactoryBean.
* SGF-414 - Resolve incompatibility between the DistributedSystem created by the PoolFactoryBean and the DistributedSystem resolved by the ClientCacheFactoryBean when SSL is configured.
* SGF-409 - Modify the GemfireDataSourcePostProcessor (basis for <gfe:datasource>) to not assume a GemFire Server was configured and bootstrapped with Spring and subsequently that the SDG ListRegionsOnServerFunction was registered.
Changes in version 1.4.6.RELEASE (2015-07-01)
---------------------------------------------
* SGF-411 - Release 1.4.6 (Dijkstra).
* SGF-399 - Fix incorrect XSD appinfo annotation, expected 'type' attribute value on the 'error-handler' attribute of the 'cq-listener-container' element.
Changes in version 1.5.3.RELEASE (2015-07-01)
---------------------------------------------
* SGF-412 - Release 1.5.3 (Evans).
* SGF-407 - Modify the MappingPdxSerializer to allow for extensibility.
* SGF-406 - Fix JavaDoc build.
* SGF-399 - Fix incorrect XSD appinfo annotation, expected 'type' attribute value on the 'error-handler' attribute of the 'cq-listener-container' element.
* SGF-393 - Region scope not properly set for replicated region, prevents client CQ from registering properly.
* SGF-385 - Local region does remote put in addition to local put in client cache.
* SGF-384 - Issue with partitioned-region-template when persistence is enabled.
* SGF-382 - Add logging to the SpringContextBootstrappingInitializer init method to capture any Spring context/GemFire errors on startup.
* SGF-381 - Enable RegionFactoryBean to respect the Data Policy specified on a nested or referenced RegionAttributes bean definition.
* SGF-379 - Specifying multiple or a single Gateway Endpoint with one or more GatewayListeners is not permitted by the SDG XML namespace (XSD) gatewayType element definition.
* SGF-378 - SDG completely ignores the 'socket-read-timeout' attribute on the Gateway element nested in a GatewayHub.
* SGF-376 - The GemFire WAN GatewayHub support needs refactoring and test coverage.
* SGF-375 - The <gfe:gateway-hub> XML namespace element is missing the 'max-time-between-pings' attribute.
* SGF-374 - Specifying a disk-store on a GatewayHub forces the GatewayHub to be persistent.
Changes in version 1.6.1.RELEASE (2015-06-30)
---------------------------------------------
* SGF-413 - Release 1.6.1 (Fowler).
* SGF-407 - Modify the MappingPdxSerializer to allow for extensibility.
* SGF-406 - Fix JavaDoc build.
* SGF-400 - Enable the ability to set the ClassLoader used by the Spring ApplicationContext created in the SpringContextBootstrappingInitializer for loading bean definition classes and resolving resources.
* SGF-399 - Fix incorrect XSD appinfo annotation, expected 'type' attribute value on the 'error-handler' attribute of the 'cq-listener-container' element.
* SGF-396 - Enable support for variable Locator and Server endpoints on a SDG GFE Pool bean definition in a Spring Context.
* SGF-395 - Allow Spring JavaConfig @Configuration classes to be registered and used to configure the (AnnotationConfig)ApplicationContext created by the SpringContextBootstrappingInitializer.
* SGF-394 - Improve SDG Gradle build removing FindBug compilation warnings caused by GemFire.
* SGF-393 - Region scope not properly set for replicated region, prevents client CQ from registering properly.
Changes in version 1.7.0.M1 (2015-06-02)
----------------------------------------
* SGF-405 - Release 1.7 M1 (Gosling).
* SGF-403 - Simplify the process of adding custom methods to Spring Data GemFire Repositories.
* SGF-400 - Enable the ability to set the ClassLoader used by the Spring ApplicationContext created in the SpringContextBootstrappingInitializer for loading bean definition classes and resolving resources.
* SGF-399 - Fix incorrect XSD appinfo annotation, expected 'type' attribute value on the 'error-handler' attribute of the 'cq-listener-container' element.
* SGF-397 - Upgrade to Spring Framework 4.1.6.RELEASE.
* SGF-396 - Enable support for variable Locator and Server endpoints on a SDG GFE Pool bean definition in a Spring Context.
* SGF-395 - Allow Spring JavaConfig @Configuration classes to be registered and used to configure the (AnnotationConfig)ApplicationContext created by the SpringContextBootstrappingInitializer.
* SGF-394 - Improve SDG Gradle build removing FindBug compilation warnings caused by GemFire.
* SGF-393 - Region scope not properly set for replicated region, prevents client CQ from registering properly.
* SGF-391 - Simplify and improve the robustness of the JNDI DataSource Type matching used in the Cache FactoryBeans.
* SGF-390 - Improve unit test coverage for the PoolFactoryBean class.
* SGF-389 - Improve unit test coverage of the ClientCacheFactoryBean class.
* SGF-388 - Improve unit test coverage of the CacheFactoryBean class.
* SGF-383 - Refactor and make RegionFactoryBean and RegionLookupFactoryBean abstract.
* SGF-371 - The GatewayReceiverFactoryBean needs to set GatewayReceiverFactory.setManualStart(false) in GemFire 8.1 in order to enable manual starts on a GatewayReceiver.
* SGF-357 - Optimize SimpleGemfireRepository.deleteAll() by using the new Region.removeAll() operation.
* SGF-353 - Prepare SDG 1.7 and upgrade to GemFire 8.1.0 GA.
* SGF-345 - Add PDX Aliases support.
* SGF-322 - Add support for the newly added, retro 'max-connections' attribute on the <gfe:gateway-hub> element in the SDG XML namespace (XSD).
* SGF-196 - Support adding CacheListeners, CacheLoaders and CacheWriters, along with other mutable Region attributes to an existing Region.
Changes in version 1.6.0.RELEASE (2015-03-23)
---------------------------------------------
* SGF-386 - Release 1.6 GA.
* SGF-385 - Local region does remote put in addition to local put in client cache.
* SGF-384 - Issue with partitioned-region-template when persistence is enabled.
* SGF-382 - Add logging to the SpringContextBootstrappingInitializer init method to capture any Spring context/GemFire errors on startup.
* SGF-381 - Enable RegionFactoryBean to respect the Data Policy specified on a nested or referenced RegionAttributes bean definition.
Changes in version 1.6.0.RC1 (2015-03-05)
-----------------------------------------
* SGF-380 - Release 1.6 RC1.
* SGF-379 - Specifying multiple or a single Gateway Endpoint with one or more GatewayListeners is not permitted by the SDG XML namespace (XSD) gatewayType element definition.
* SGF-378 - SDG completely ignores the 'socket-read-timeout' attribute on the Gateway element nested in a GatewayHub.
* SGF-376 - The GemFire WAN GatewayHub support needs refactoring and test coverage.
* SGF-375 - The <gfe:gateway-hub> XML namespace element is missing the 'max-time-between-pings' attribute.
* SGF-374 - Specifying a disk-store on a GatewayHub forces the GatewayHub to be persistent.
* SGF-366 - Unable to create local-only, client-based Region Indexes using SDG's <gfe:index> and corresponding IndexFactoryBean functionality.
* SGF-364 - Move EvictionAttributesFactoryBean and SubscriptionAttributesFactoryBean along with supporting enum types from the ..data.gemfire.config package to ..data.gemfire.
* SGF-363 - Upgrade to Spring Framework 4.0.9.RELEASE.
* SGF-360 - Failures in SubRegionNamespaceTests when built with Java 8.
* SGF-358 - Enhance SDG's Function annotation support to allow strongly-typed arguments in the context of PDX even when read-serialized is set to true.
* SGF-354 - SimpleGemfireRepository.deleteAll that supports transactions.
* SGF-289 - Enumeration restrictions (xsd:enumeration) should be avoided in the XML schema.
Changes in version 1.5.2.RELEASE (2015-01-28)
---------------------------------------------
* SGF-368 - Release 1.5.2.
* SGF-366 - Unable to create local-only, client-based Region Indexes using SDG's <gfe:index> and corresponding IndexFactoryBean functionality.
* SGF-363 - Upgrade to Spring Framework 4.0.9.RELEASE.
* SGF-360 - Failures in SubRegionNamespaceTests when built with Java 8.
* SGF-358 - Enhance SDG's Function annotation support to allow strongly-typed arguments in the context of PDX even when read-serialized is set to true.
* SGF-354 - SimpleGemfireRepository.deleteAll that supports transactions.
* SGF-352 - Change all Artifact Repository URLs to use HTTPS.
* SGF-348 - Upgrade to Spring Framework 4.0.8.RELEASE.
Changes in version 1.4.5.RELEASE (2015-01-27)
---------------------------------------------
* SGF-369 - Fix Javadoc so that 1.4.x builds on Java 8.
* SGF-367 - Release 1.4.5.
* SGF-362 - Upgrade to Spring Framework 3.2.13.RELEASE.
* SGF-352 - Change all Artifact Repository URLs to use HTTPS.
* SGF-349 - Upgrade to Spring Framework 3.2.12.RELEASE.
* SGF-346 - Enable LazyWiringDeclarableSupport-based GemFire components to be used inside both cache.xml and Spring config, especially in the context of GemFire 8's Cluster Configuration.
* SGF-343 - Optimize the SDG implementation of CrudRepository.save(Iterable<S> enttiies) to use GemFire's Region.putAll(Map<K, V> values) operation.
* SGF-337 - SDG's XML Schema (XSD) does not allow the developer to specify 'timeout' and 'action' values for CustomExpiry (<gfe:custom-entry-[ttl|tti]>) on Region attributes.
* SGF-336 - Upgrade to Spring Framework 3.2.11.RELEASE.
* SGF-333 - The SpringContextBootstrappingInitializer needs to handle the case when it's init(:Properties) method maybe called more than once on initialization.
* SGF-330 - Add missing 'disk-synchronous' attribute to the <gfe:gateway-sender> element in the SDG XML namespace (XSD).
* SGF-328 - Add missing 'hostname-for-senders' attribute on the <gfe:gateway-receiver> element in the SDG XML namespace (XSD).
* SGF-327 - Avoid setting null values with GemFire's Cache Region put(key, value) operation when GemFire is used as the caching provider in Spring's Cache Abstraction (@Cacheable).
* SGF-317 - Improve GemfireCache implementation to be able to build on Spring 4.1.
Changes in version 1.6.0.M1 (2014-12-01)
----------------------------------------
* SGF-356 - local-region on client side.
* SGF-355 - Release 1.6 M1.
* SGF-350 - Upgrade to Spring Data Commons 1.10.
* SGF-348 - Upgrade to Spring Framework 4.0.8.RELEASE.
* SGF-346 - Enable LazyWiringDeclarableSupport-based GemFire components to be used inside both cache.xml and Spring config, especially in the context of GemFire 8's Cluster Configuration.
* SGF-343 - Optimize the SDG implementation of CrudRepository.save(Iterable<S> enttiies) to use GemFire's Region.putAll(Map<K, V> values) operation.
* SGF-342 - Update Spring Data GemFire Reference Guide with GemFire 8 functional support.
* SGF-340 - Change a SpringSource-based links in the SDG Reference Guide to Spring.io-based links.
* SGF-339 - Change all VMWare-based links in the SDG Reference Guide to Pivotal-based links.
* SGF-338 - Both <gfe:custom-entry-ttl> and <gfe:custom-entry-tti> SDG XML namespace elements allow for more than one 'CustomExpiry' bean to be set in the Region Expiration Attributes although GemFire only allows one!.
* SGF-337 - SDG's XML Schema (XSD) does not allow the developer to specify 'timeout' and 'action' values for CustomExpiry (<gfe:custom-entry-[ttl|tti]>) on Region attributes.
* SGF-333 - The SpringContextBootstrappingInitializer needs to handle the case when it's init(:Properties) method maybe called more than once on initialization.
* SGF-332 - Add support for the GatewaySender 'eventSubstitutionFilter' property in the SDG XSD and GatewaySenderFactoryBean API.
* SGF-331 - Pull common WAN attributes from GatewaySenders and AsyncEventQueues in the SDG XSD into the 'commonWANQueueAttributes' attributes group.
* SGF-330 - Add missing 'disk-synchronous' attribute to the <gfe:gateway-sender> element in the SDG XML namespace (XSD).
* SGF-328 - Add missing 'hostname-for-senders' attribute on the <gfe:gateway-receiver> element in the SDG XML namespace (XSD).
* SGF-327 - Avoid setting null values with GemFire's Cache Region put(key, value) operation when GemFire is used as the caching provider in Spring's Cache Abstraction (@Cacheable).
* SGF-326 - Create spring-gemfire-1.6.xsd and spring-data-gemfire-1.6.xsd for SDG 1.6.
* SGF-325 - Create spring-gemfire-2.0.xsd and spring-data-gemfire-2.0.xsd for SDG 2.
* SGF-323 - Add support for GemFire 8's DiskStore 'diskUsageCriticalPercentage' and 'diskUsageWarningPercentage' properties in the SDG XML namespace (XSD) and DiskStoreFactoryBean API.
* SGF-318 - Upgrade to Spring Framework 4.0.7.
* SGF-317 - Improve GemfireCache implementation to be able to build on Spring 4.1.
* SGF-316 - Update Spring Data GemFire Reference Guide with 1.5 changes (e.g. Auto Region Lookups, Region Templates).
* SGF-314 - Upgrade to Spring Framework 4.0.7.
* SGF-313 - SDG 1.6 support for both GemFire 7 and GemFire 8.
* SGF-309 - Add support for Region Data Compression with the new 'Compressor' property on the RegionAttributes class.
* SGF-291 - Upgrade Spring Data GemFire 1.5 to GemFire 8.0.
* SGF-270 - Remove the validation logic in the AsyncEventQueueFactoryBean restricting the specification of Dispatcher Threads when a 'Parallel' AsyncEventQueue is used.
* SGF-269 - Remove the validation logic in the GatewaySenderFactoryBean restricting the specification of Dispatcher Threads when a 'Parallel' GatewaySender is used.
* SGF-264 - Completely remove the 'data-policy' and 'shortcut' attributes from the SDG XML namespace Region elements.
* SGF-227 - Support for 'auto-reconnect' functionality when peers are forcefully disconnected from the cluster.
* SGF-226 - Support for requesting a peer member's configuration from a GemFire Locator/Manager using the new Cluster-based Configuration Service.
Changes in version 1.5.1.RELEASE (2014-10-30)
---------------------------------------------
* SGF-347 - Release 1.5.1.
* SGF-346 - Enable LazyWiringDeclarableSupport-based GemFire components to be used inside both cache.xml and Spring config, especially in the context of GemFire 8's Cluster Configuration.
* SGF-343 - Optimize the SDG implementation of CrudRepository.save(Iterable<S> enttiies) to use GemFire's Region.putAll(Map<K, V> values) operation.
* SGF-340 - Change a SpringSource-based links in the SDG Reference Guide to Spring.io-based links.
* SGF-339 - Change all VMWare-based links in the SDG Reference Guide to Pivotal-based links.
* SGF-337 - SDG's XML Schema (XSD) does not allow the developer to specify 'timeout' and 'action' values for CustomExpiry (<gfe:custom-entry-[ttl|tti]>) on Region attributes.
* SGF-333 - The SpringContextBootstrappingInitializer needs to handle the case when it's init(:Properties) method maybe called more than once on initialization.
* SGF-330 - Add missing 'disk-synchronous' attribute to the <gfe:gateway-sender> element in the SDG XML namespace (XSD).
* SGF-328 - Add missing 'hostname-for-senders' attribute on the <gfe:gateway-receiver> element in the SDG XML namespace (XSD).
* SGF-327 - Avoid setting null values with GemFire's Cache Region put(key, value) operation when GemFire is used as the caching provider in Spring's Cache Abstraction (@Cacheable).
Changes in version 1.5.0.RELEASE (2014-09-05)
---------------------------------------------
* IMPORTANT: Upgrade to Gemfire 8.0 has been postponed to a 2.0 release.
* SGF-319 - Release 1.5 GA.
* SGF-318 - Upgrade to Spring Framework 4.0.7.
* SGF-317 - Improve GemfireCache implementation to be able to build on Spring 4.1.
* SGF-316 - Update Spring Data GemFire Reference Guide with 1.5 changes (e.g. Auto Region Lookups, Region Templates).
* SGF-315 - Re-enable Bundlor plugin to create OSGi metadata.
* SGF-314 - Upgrade to Spring Framework 4.0.7.
* SGF-312 - The <gfe:partitioned-region> element in the SDG XSD does not properly support multiple PartitionListener bean definitions or references.
* SGF-311 - ClientRegionFactoryBean does not properly set the 'concurrency-checks-enabled' attribute and property of GemFire's ClientRegionFactory class.
* SGF-310 - The <gfe:client-region> element is missing the 'concurrency-level' attribute, which is supported by GemFire's ClientRegionFactory API.
* SGF-307 - Remove all default values on strongly-typed Region elements in the SDG Schema in support of Region Templates.
* SGF-305 - Move to Asciidoctor for reference documentation.
* SGF-254 - Template Regions which can be used to reuse the same Region configuration for all Regions that reference it.
* SGF-223 - Ability to create directories on-the-fly at runtime based on explicitly defined Disk Stores disk directory locations.
* SGF-207 - No support for hierarchical, inherited Region attributes like there is in GemFire's cache.xml.
* SGF-191 - Provide automated way to add all Regions defined in GemFire's cache.xml as beans in the Spring context.
Changes in version 1.4.4.RELEASE (2014-08-27)
---------------------------------------------
* SGF-308 - Release 1.4.4.
* SGF-304 - OnMembers function execution with Gemfire Group calls onMember (wrong method).
Changes in version 1.5.0.RC1 (2014-08-13)
-----------------------------------------
* SGF-306 - Release 1.5 RC1.
* SGF-304 - OnMembers function execution with Gemfire Group calls onMember (wrong method).
* SGF-291 - Upgrade Spring Data GemFire 1.5 to GemFire 8.0.
* SGF-227 - Ability to handle forced disconnects due to node failures with "Reconnect" functionality being added in GemFire.
* SGF-226 - Ability to request and get the member's configuration from a GemFire Locator/Manager using the cluster-wide configuration in the new Persistent Config feature.
Changes in version 1.4.2.RELEASE (2014-07-28)
---------------------------------------------
* SGF-303 - Release 1.4.2.
* SGF-297 - Executing SDG Functions annotated POJO methods from Gfsh does not work when "injecting" arguments during Function argument resolution.
* SGF-295 - Enable Local Region Eviction action to be set to 'LOCAL_DESTROY', which is allowed in GemFire using the public API or in cache.xml.
* SGF-294 - Enable GemFire GatewayReceivers to be started manually, the same as for GatewaySenders using SDG.
* SGF-284 - Modify SDG build (build.gradle script) to include SDG validation and compatibility checks for Spring IO.
Changes in version 1.5.0.M1 (2014-07-10)
----------------------------------------
* SGF-299 - Upgrade Spring Data GemFire 1.5 to Spring Framework 4.0.6.
* SGF-298 - Release 1.5 M1.
* SGF-297 - Executing SDG Functions annotated POJO methods from Gfsh does not work when "injecting" arguments during Function argument resolution.
* SGF-296 - Create spring-gemfire-1.5.xsd and spring-data-gemfire-1.5.xsd for SDG 1.5.
* SGF-295 - Enable Local Region Eviction action to be set to 'LOCAL_DESTROY', which is allowed in GemFire using the public API or in cache.xml.
* SGF-294 - Enable GemFire GatewayReceivers to be started manually, the same as for GatewaySenders using SDG.
* SGF-292 - Upgrade Spring Data GemFire 1.5 to Spring Framework 4.0.5.RELEASE.
* SGF-290 - SDG's Repository extension does not properly handle custom @Query annotated Repository methods returning non-Collection, non-Entity-based return values.
* SGF-215 - Ensure compatibility with Spring Framework 4.0.0.X.
Changes in version 1.4.1.RELEASE (2014-06-30)
---------------------------------------------
* SGF-293 - Release 1.4.1.
* SGF-290 - SDG's Repository extension does not properly handle custom @Query annotated Repository methods returning non-Collection, non-Entity-based return values.
* SGF-288 - CacheServer's "maximum-time-between-pings" is set to ZERO.
Changes in version 1.4.0.RELEASE (2014-05-20)
---------------------------------------------
* SGF-287 - Upgrade to Spring 3.2.9.
* SGF-286 - Release 1.4 GA.
* SGF-274 - Avoid the creation of temporary objects in the GemfireTemplate when used with Spring Data GemFire's Repository abstraction and extension.
* SGF-272 - Cleanup all Javadoc warnings.
Changes in version 1.4.0.RC1 (2014-05-02)
-----------------------------------------
* SGF-283 - Release 1.4 RC1.
* SGF-282 - The Eviction 'action', other than the default, for a PARTITION Region is not properly passed to the GemFire EvictionAttributes.createLRUEntryAttributes(..) factory method when the 'threshold' is not set.
* SGF-281 - Avoid setting the RegionAttributes Disk Store "Name" when the Region is neither "persistent" nor has an Eviction policy set to "OVERFLOW_TO_DISK".
* SGF-280 - The ContinuousQueryListenerContainer class is not Thread-safe!.
* SGF-279 - The <cq-listener-container> element is missing the 'error-handler' attribute.
* SGF-278 - The ContinuousQueryListenerContainer class's 'taskExecutor' property is not set properly by the GemfireListenerContainerParser.
* SGF-277 - OQL Join in Repository interface.
* SGF-276 - LIKE operator does not work.
* SGF-275 - The <cq-listener-container> element's 'phase' attribute is ignored.
* SGF-274 - Avoid the creation of temporary objects in the GemfireTemplate when used with Spring Data GemFire's Repository abstraction and extension.
* SGF-273 - OrderBy (static) and Sort parameter (dynamic) Repository Queries do not work!.
* SGF-271 - The <cq-listener-container> element is missing the 'auto-startup' attribute.
* SGF-268 - Make it possible to run the build on Java 7 and/or Java 8.
* SGF-265 - Upgrade to the latest version GemFire (7.0.2).
Changes in version 1.4 M1 (2014-03-31)
--------------------------------------
** Bug
* [SGF-225] - Inconsistent data policy defaults for subregions that are replicated regions
* [SGF-230] - Cannot specify a Disk Store to be used for overflow on a Gateway Sender without enabling persistence.
* [SGF-231] - Unable to specify Ordering Policy for Serial GW Sender
* [SGF-232] - Unable to specify Order Policy for Serial Async Event Queue
* [SGF-233] - Cannot specify a Disk Store to be used for overflow on an Async Event Queue without enabling persistence.
* [SGF-234] - The docs indicate that the PDX attribute pdx-persistent defaults to true, however this does not seem to be the case.
* [SGF-235] - NPE in DefaultFunctionArgumentResolver.resolveFunctionArguments(30) when a Function has no arguments and none are provided.
* [SGF-238] - "jndi-prop" is not parced correctly
* [SGF-239] - The value "XaPooledDataSource" of jndi-binding "type" attribute should be changed to "XAPooledDataSource"
* [SGF-240] - XML schema type restrictions should be avoided in order to support placeholders (al types should be xs:string)
* [SGF-242] - When defining "membership-attributes" for a Region, the bean definition "required-roles" attribute is required and, when specified, causes a BeanCreationException in the Spring container during initialization.
* [SGF-244] - The nested <gfe:gateway-sender/>, <gfe:event-filter/> element is missing the ref attribute in the XSD.
* [SGF-245] - <gfe:cache> always creates cache with default values ignoring all the specified attributes
* [SGF-246] - execute function always assumes arguments are passed
* [SGF-247] - boolean based repository queries generate UnsupportedOperationException in non PDX serialized entities
* [SGF-249] - The SDG XSD is restricting the use of property placeholder values on <gfe:disk-store/>, compaction-threshold attributes given the attribute type is a short and not string.
* [SGF-251] - Creating and using GemFire Repositories based on the Spring Data Commons Repository abstraction does not work properly for domain objects stored in Subregions.
* [SGF-252] - Spring GemFire's Repository extension does not properly handle multiple, identically named Subregions for persisting corresponding application domain objects associated by way of the @Region annotation.
* [SGF-255] - The <gfe:eviction> element's 'threshold' attribute is required even when the Eviction type is 'HEAP_PERCENTAGE'.
* [SGF-258] - The SDG XML namespace <partitioned-region> element is missing the 'data-policy' attribute.
* [SGF-263] - The 'disk-synchronous' Region attribute does not get successfully applied when explicitly set to false.
** Improvement
* [SGF-88] - Create Regions in Spring Context with Region Shortcuts
* [SGF-187] - Consider appending to the list of listener a new listener defined by another peer member
* [SGF-201] - Create a Spring Boot Starter POM for Spring Data GemFire
* [SGF-204] - The existing RegionFactoryBean does a lookup of a Region before trying to create one.
* [SGF-209] - GemfireTemplate creates a temporary object for every operation.
* [SGF-210] - GemfireRepository requires that there be an attribute in the entity class for the key.
* [SGF-236] - Sub-Region Bean names require prepended "/" (vs. previous use of gfe:lookup-region for sub-regions)
* [SGF-241] - Add support for defining client sub-Regions using nested <gfe:client-region/> SDG XML namespace elements.
* [SGF-256] - Upgrade to the latest version of the Spring Framework (3.2.8) and Spring Data Commons (1.8.0)
* [SGF-257] - Specify strict type rules in the Spring Data GemFire XSD for peer Region 'data-policy' and 'shortcut' attributes as currently enforced by the <gfe:client-region> element's 'shortcut' attribute.
* [SGF-259] - Handle cyclic bean dependencies in SDG XML config between Async Event Queues and Async Event Listeners.
* [SGF-260] - Add the ability to set @Id to a method name.
* [SGF-261] - Add ability to persist application domain objects (entities) to multiple Regions in a GemFire Cache.
* [SGF-265] - Upgrade to the latest version GemFire (7.0.2)
** New Feature
* [SGF-132] - Being able to get cacheservers overall status on the client
* [SGF-248] - Ability to bootstrap a Spring context inside a GemFire Server JVM process by starting the GemFire Server with Gfsh.
** Task
* [SGF-266] - Release 1.4 M1
Changes in Version 1.3.4 (2014-04-04)
-------------------------------------
General
* This is a maintenance/patch release to address bugs and other minor improvements.
Bugs
* [SGF-235] - NPE in DefaultFunctionArgumentResolver.resolveFunctionArguments(30) when a Function has no arguments and none are provided.
* [SGF-238] - "jndi-prop" is not parced correctly.
* [SGF-239] - The value "XaPooledDataSource" of jndi-binding "type" attribute should be changed to "XAPooledDataSource".
* [SGF-240] - XML schema type restrictions should be avoided in order to support placeholders (al types should be xs:string).
* [SGF-246] - execute function always assumes arguments are passed.
* [SGF-249] - The SDG XSD is restricting the use of property placeholder values on <gfe:disk-store/>, compaction-threshold attributes given the attribute type is a short and not string.
* [SGF-255] - The <gfe:eviction> element's 'threshold' attribute is required even when the Eviction type is 'HEAP_PERCENTAGE'.
Improvements
* Upgrades SDG to Spring Framework 3.2.8 and Spring Data Commons 1.7.1.
Changes in Version 1.3.3 (2013-11-13)
-------------------------------------
General
* This is a maintenance/patch release to address bugs and other minor improvements.
* See [1.3.3 release notes](https://jira.springsource.org/secure/ReleaseNote.jspa?projectId=10462&version=14257).
Bugs
* [SGF-174] - DynamicRegion usage causes ApplicationContext to fail to load when using non-dynamic parent
* [SGF-178] - parent attribute causes endless loop in hashCode
* [SGF-194] - Nested region do not work
* [SGF-195] - colocated-with fails on partition region
* [SGF-197] - A Cache (Region) created using Spring configuration with persistent PDX keys fails to start.
* [SGF-198] - BeanCurrentlyInCreationException when injecting async-event-queue to a Gemfire replicated region
* [SGF-200] - Extra unnecessary directory for disk store created when an embedded sender starts up
* [SGF-203] - The treatment of 'persistence' is wrong.
* [SGF-211] - Property placeholders don't work for copies attribute on partitioned-region
* [SGF-216] - FunctionContextInjectingArgumentResolver only injects arguments for RegionFunctionContext
* [SGF-217] - When configuring CacheServer with a Disk Store (used for client subscription queue overflow), the Cache Server fails to start up with an error.
* [SGF-218] - The Eviction Policy on Client Subscription when configuring a GemFire Cache Server is not being properly set; always defaults to "NONE".
* [SGF-219] - Unable to register GemFire CacheListeners on SubRegions.
* [SGF-220] - Unable to register GemFire Gateway Senders on SubRegions.
* [SGF-221] - Unable to register GemFire Async Event Listeners on SubRegions.
Improvements
* [SGF-214] - OnMembersFunctionExecutionTemplate constructors should be public
New Features
* [SGF-193] - concurrency-checks-enabled is not supported in SGF.
* [SGF-206] - CacheLoader and CacheWriter are not supported on client local regions.
Changes in Version 1.3.2 (2013-08-06)
--------------------------------------
General
* This is a patch release to address bugs and minor enhancements
see [1.3.2 release notes](https://jira.springsource.org/secure/ReleaseNote.jspa?version=14219&projectId=10462)
** Bug
* [SGF-168] - Race condition when using Spring data gemfire with tc Server parallel deployment
* [SGF-176] - Missing Functionality: time to live and entry idle time on a local client region
* [SGF-185] - @OnServers fails when pool attribute is set - cannot specify both pool and cache
* [SGF-186] - BeanFactoryLocator reports cache already exists when ClientCache, Pool, and Functions are configured
* [SGF-188] - Documentation mistake
* [SGF-189] - Spring Gemfire does not allow persistence for a local region even though this is supported in Gemfire
* [SGF-192] - client region ignores destroy and close settings
** Improvement
* [SGF-180] - If nothing references the cache bean it doesn't get initialized
* [SGF-183] - Little or no logging in Spring Gemfire
Changes in version 1.3.1.RELEASE(2013-04-18)
** Bug
* [SGF-159] - isRollbackOnCommitFailure flag is ignored by GemfireTransactionManager when transaction fails.
* [SGF-169] - Unidirectional Gateway hubs cannot be created and fail with an exception
* [SGF-173] - Function Execution throws exception on void return.
Changes in version 1.3.0.RELEASE (2013-03-14)
---------------------------------------------
General
* Added annotation support for GemFire functions
* Added 'datasource' element to gfe-data namespace to simplify client connection
* Added support for JSON
See [1.3.0.M1 release notes](https://jira.springsource.org/secure/ReleaseNote.jspa?projectId=10462&version=13300)
See [1.3.0 release notes](https://jira.springsource.org/secure/ReleaseNote.jspa?projectId=10462&version=14023)
Changes in version 1.2.1.RELEASE (2012-10-26)
---------------------------------------------
General
* Upgraded to GemFire 7.0
* Added support for GemFire 7.0 WAN Configuration
Changes in version 1.2.0.RELEASE (2012-08-15)
---------------------------------------------
General
* Added support for Spring Data repositories
* The Spring Data GemFire project, formerly Spring GemFire, is now a component of the Spring Data project
* Upgraded to Spring 3.1.2.RELEASE
* Upgraded to Spring Data Commons 1.4.0.RELEASE
* The XML namespace provides support for everything that can be configured natively with Cache XML
* A separate XML namespace has been created for Spring Data Repository support
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-103] - Replace xsd:id type with xsd:string to support Spring environment profiles
* [SGF-104] - The repository deleteAll() method only works for replicated regions
* [SGF-109] - Separate repository support into its own namespace
* [SGF-111] - Change default bean names from hyphenated to camel case to support @Autowired
* [SGF-112] - Repositories should reject PagingAndSorting and Pageable parameters
* [SGF-113] - Repositories should support single entities returned from a query method
* [SGF-115] - Add support for 'Like', 'StartsWith','EndsWith', and 'Containing' repository queries
Bug Fixes
* [SGF-85] - Pdx disk store does not work when trying to references a disk store created in cache.xml
* [SGF-89] - Continuous query container fails when implementing the ContinuousQueryListener interface
* [SGF-101] - The repository deleteAll() method only works for replicated regions
Changes in version 1.1.2.RELEASE (2012-07-04)
---------------------------------------------
General
* Upgraded to GemFire 6.6.3
Package org.springframework.data.gemfire.config
* Fixed incorrect parsing of pdx-disk-store attribute
Changes in version 1.1.1.RELEASE (2012-03-20)
---------------------------------------------
General
* Upgraded to GemFire 6.6.2
* Upgraded to Spring Framework 3.1.1 GA
Package org.springframework.data.gemfire
* Fixed incorrect parsing of pdx-serializer (from value to reference)
* Fixed incorrect parsing of use-bean-factory-locator
* Fixed GemfireTransactionCommitException class hierarchy
* Improved handling of GemFire 6.5+ transaction exceptions
Package org.springframework.data.gemfire.client
* Fixed bug that caused client namespace to create only local regions
Changes in version 1.1.0.RELEASE (2011-12-14)
---------------------------------------------
General
* Upgraded to Spring Framework 3.1 GA
Changes in version 1.1.0.RC1 (2011-11-13)
-----------------------------------------
General
* Upgraded to GemFire 6.6.1
* Aligned Maven naming to Spring Data conventions (changed ids to 'org.springframework.data'/'spring-data-gemfire')
* Introduced PDX options for 'cache' and 'client-cache' elements
Changes in version 1.1.0.M3 (2011-09-25)
----------------------------------------
General
* Upgraded to GemFire 6.6 GA
* Introduced support for GemFire Indecies
* Reintroduced samples in zip distribution
Package org.springframework.data.gemfire
* Improved region creation by removing the use of GemFire 6.0 API (replaced with 6.5+)
Package org.springframework.data.gemfire.client
* Added missing properties to PoolFactoryBean and pool namespace
* Fixed registration of custom listeners specified through region attributes
* Added missing 'receive-values' property to region interests
Changes in version 1.1.0.M2 (2011-08-29)
----------------------------------------
General
* Introduced support for GemFire Continuous Query (CQ)
* Introduced support for client cache
* Introduced namespace support for region expiration attributes
Package org.springframework.data.gemfire
* Added find methods (based on the query service) inside GemFireTemplate
* Improved detection of local client regions without pools configured
Package org.springframework.data.gemfire.server
* Fixed bug occuring when applying defaults for disk stores
* Delayed CacheServer start up to allow declared regions to properly initialize
Changes in version 1.1.0.M1 (2011-07-20)
----------------------------------------
General
* Changed build system to Gradle
* Added support for GemFire 6.6
* Dropped support for GemFire 6.0 (GemFire 6.5 or higher required)
* Introduced support for CacheServer
* Introduced GemFire implementation for Spring 3.1 cache abstraction
* Upgraded to Spring Framework 3.1 M2
Package org.springframework.data.gemfire
* Introduced cache option for disabling bean factory locator; useful for multi cache definitions, in the same VM
* Added more region methods to GemfireTemplate
* Introduced support for queries with variable parameters in GemfireTemplate
* Improved handling of optimistic exception in a transaction scenario
Changes in version 1.0.1 (2011-04-26)
-------------------------------------
General
* Upgraded to GemFire 6.5.1.4
* Fix networking issue with the sample on some Linux distributions (Ubuntu)
* Loosen type constraints in the schema to allow placeholders
* Added 'statistics' attribute to all write regions
Package org.springframework.data.gemfire
* Introduced auto-close (configurable) on RegionFactoryBean
Package org.springframework.data.gemfire.config
* Fixed bug causing region names to be used as aliases for region beans
Package org.springframework.data.gemfire.client
* Improved dependency initialization between cache and pools
Package org.springframework.data.gemfire.serialization
* Improved cache-wide registration of custom instantiators
Package org.springframework.data.gemfire.support
* Introduced GemfireDaoSupport
Changes in version 1.0.0 (2011-02-02)
-------------------------------------
Changes in version 1.0.0.RC1 (2010-12-20)
-----------------------------------------
General
* Upgraded to GemFire 6.5.1
* Upgraded to Spring 3.0.5
Changes in version 1.0.0.M2 (2010-12-08)
----------------------------------------
General
* Introduced namespace for all the major SGF components
* Improved documentation to accomodate the SGF namespace
Package org.springframework.data.gemfire
* Introduced RegionLookupFactoryBean for retrieving (but not creating) regions
Package org.springframework.data.gemfire.client
* Refactored client-specific classes into a dedicated package
* Introduced support for configuring GemFire Pools
Changes in version 1.0.0.M1 (2010-08-03)
----------------------------------------
General
* Configuration support for GemFire Cache, Region
* Exception translation
* GemFire Template for exception translation
* Declarative transaction management
* Auto-generation of non-reflection based GemFire instantiators

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@@ -0,0 +1,22 @@
======================================================================
== NOTICE file corresponding to section 4 d of the Apache License, ==
== Version 2.0, for the Spring Framework distribution. ==
======================================================================
This product includes software developed by
the Apache Software Foundation (http://www.apache.org).
The end-user documentation included with a redistribution, if any,
must include the following acknowledgement:
"This product includes software developed by the Spring Framework
Project (http://www.springframework.org)."
Alternately, this acknowledgement may appear in the software itself,
if and wherever such third-party acknowledgements normally appear.
The names "Spring", "Spring Framework", and "Spring GemFire" must
not be used to endorse or promote products derived from this
software without prior written permission. For written permission,
please contact enquiries@springsource.com.

View File

@@ -0,0 +1,24 @@
SPRING DATA GEMFIRE
-------------------
http://www.springsource.org/spring-gemfire
1. INTRODUCTION
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
This release comes with complete reference documentation. For further
details, consult the provided javadoc for specific packages and classes.
3. GETTING STARTED
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 Data GemFire Homepage : http://www.springsource.org/spring-gemfire
VMware vFabric GemFire Documentation: http://www.vmware.com/products/application-platform/vfabric-gemfire/overview.html
VMware vFabric GemFire product page: http://www.vmware.com/products/application-platform/vfabric-gemfire