diff --git a/src/main/asciidoc/appendix/appendix-schema.adoc b/src/main/asciidoc/appendix/appendix-schema.adoc index 794d5d7e..dc6edc73 100644 --- a/src/main/asciidoc/appendix/appendix-schema.adoc +++ b/src/main/asciidoc/appendix/appendix-schema.adoc @@ -2,5 +2,5 @@ [appendix] = Spring Data for {data-store-name} Schema -* http://www.springframework.org/schema/gemfire/spring-gemfire.xsd[Spring Data for {data-store-name} Core Schema (`gfe` namespace)] -* http://www.springframework.org/schema/gemfire/spring-data-gemfire.xsd[Spring Data for {data-store-name} Data Access Schema (`gfe-data` namespace)] +* {spring-data-schema-location}[Spring Data for {data-store-name} Core Schema (`gfe` namespace)] +* {spring-data-access-schema-location}[Spring Data for {data-store-name} Data Access Schema (`gfe-data` namespace)] diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index 7721c2da..7d2fe7e9 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -22,9 +22,13 @@ Costin Leau; David Turanski; John Blum; Oliver Gierke; Jay Bryant :pivotal-gemfire-javadoc: http://gemfire-{pivotal-gemfire-version}-javadocs.docs.pivotal.io/ :pivotal-gemfire-website: https://pivotal.io/pivotal-gemfire :sdg-name: Spring Data for {data-store-name} +:spring-data-access-schema-location: http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd +:spring-data-access-schema-namespace: http://www.springframework.org/schema/data/gemfire :spring-data-commons-docs: https://docs.spring.io/spring-data/commons/docs/current/reference :spring-data-commons-docs-html: {spring-data-commons-docs}/html :spring-data-commons-javadoc: https://docs.spring.io/spring-data/commons/docs/current/api +:spring-data-schema-location: http://www.springframework.org/schema/gemfire/spring-gemfire.xsd +:spring-data-schema-namespace: http://www.springframework.org/schema/gemfire :spring-data-website: https://spring.io/projects/spring-data :spring-framework-docs: https://docs.spring.io/spring/docs/current/spring-framework-reference :spring-framework-javadoc: https://docs.spring.io/spring/docs/current/javadoc-api diff --git a/src/main/asciidoc/reference/bootstrap.adoc b/src/main/asciidoc/reference/bootstrap.adoc index 1a28d944..fb2a540b 100644 --- a/src/main/asciidoc/reference/bootstrap.adoc +++ b/src/main/asciidoc/reference/bootstrap.adoc @@ -51,14 +51,16 @@ To use the Spring Data for {data-store-name} XML namespace, declare it in your S as the following example shows: [source,xml] +[subs="verbatim,attributes"] ---- - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" + xmlns:gfe="{spring-data-schema-namespace}" + 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/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd"> + {spring-data-schema-namespace} {spring-data-schema-location} +"> @@ -80,14 +82,16 @@ composed mainly of {data-store-name} components, as it avoids declaring the pref prefix declaration shown earlier, as the following example shows: [source,xml] +[subs="verbatim,attributes"] ---- - - xmlns:beans="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" + + xmlns:beans="http://www.springframework.org/schema/beans" + 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/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd"> + {spring-data-schema-namespace} {spring-data-schema-location} +"> diff --git a/src/main/asciidoc/reference/cache.adoc b/src/main/asciidoc/reference/cache.adoc index 86aa32e8..852e329d 100644 --- a/src/main/asciidoc/reference/cache.adoc +++ b/src/main/asciidoc/reference/cache.adoc @@ -57,16 +57,18 @@ For example, you can use the `properties` element defined in the `util` namespac directly or load properties from a properties file, as follows: [source,xml] +[subs="verbatim,attributes"] ---- + {spring-data-schema-namespace} {spring-data-schema-location} + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd +"> @@ -230,7 +232,7 @@ Again, to enable this feature, specify the following in the Spring XML config: [source,xml] ---- - + ---- NOTE: While certain {data-store-name} tools, such as `Gfsh`, have their actions "`recorded`" when schema-like changes are made @@ -248,16 +250,17 @@ Spring Data for {data-store-name} includes dedicated support for configuring a allowing complete configuration through the Spring container, as the following example shows: [source,xml] +[subs="verbatim,attributes"] ---- diff --git a/src/main/asciidoc/reference/cq-container.adoc b/src/main/asciidoc/reference/cq-container.adoc index 2b8f5e1b..e7998c5d 100644 --- a/src/main/asciidoc/reference/cq-container.adoc +++ b/src/main/asciidoc/reference/cq-container.adoc @@ -83,14 +83,15 @@ NOTE: the class does not have to implement an interface; an interface is only us between the contract and the implementation. [source,xml] +[subs="verbatim,attributes"] ---- diff --git a/src/main/asciidoc/reference/data.adoc b/src/main/asciidoc/reference/data.adoc index a79af7a6..dcb1a1e5 100644 --- a/src/main/asciidoc/reference/data.adoc +++ b/src/main/asciidoc/reference/data.adoc @@ -136,7 +136,7 @@ NOTE: #1 above is independent of your Spring [Boot] and/or [Data for {data-store and must be completed successfully. 2) Referring to Step 5 in {data-store-name}'s http://gemfire90.docs.pivotal.io/geode/developing/transactions/JTA_transactions.html#concept_csy_vfb_wk[documentation], -_Spring Data for {data-store-name}'s_ Annotation support will attempt to set the `GemFireCache`, {x-data-store-javadoc}/org/apache/geode/cache/GemFireCache.html#setCopyOnRead-boolean-[`copyOnRead`] +Spring Data for {data-store-name}'s Annotation support will attempt to set the `GemFireCache`, {x-data-store-javadoc}/org/apache/geode/cache/GemFireCache.html#setCopyOnRead-boolean-[`copyOnRead`] property for you when using the `@EnableGemFireAsLastResource` annotation. However, if SDG's auto-configuration is unsuccessful then you must explicitly set the `copy-on-read` attribute on the @@ -147,46 +147,46 @@ Peer Cache XML: [source,xml] ---- - + ---- Peer Cache JavaConfig: [source,java] ---- - @Bean - CacheFacatoryBean gemfireCache() { +@Bean +CacheFacatoryBean gemfireCache() { - CacheFactoryBean gemfireCache = new CacheFactoryBean(); + CacheFactoryBean gemfireCache = new CacheFactoryBean(); - gemfireCache.setClose(true); - gemfireCache.setCopyOnRead(true); + gemfireCache.setClose(true); + gemfireCache.setCopyOnRead(true); - return gemfireCache; - } + return gemfireCache; +} ---- Client Cache XML: [source,xml] ---- - + ---- Client Cache JavaConfig: [source,java] ---- - @Bean - ClientCacheFacatoryBean gemfireCache() { +@Bean +ClientCacheFacatoryBean gemfireCache() { - ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean(); + ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean(); - gemfireCache.setClose(true); - gemfireCache.setCopyOnRead(true); + gemfireCache.setClose(true); + gemfireCache.setCopyOnRead(true); - return gemfireCache; - } + return gemfireCache; +} ---- NOTE: explicitly setting the `copy-on-read` attribute or optionally the `copyOnRead` property @@ -196,7 +196,7 @@ really should not be necessary. and let _Spring Data Geode_ work its magic. All you need do is annotate your Spring `@Configuration` class with Spring Data for {data-store-name}'s *new* `@EnableGemFireAsLastResource` annotation and a combination of Spring's http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#transaction[Transaction Management] -infrastructure and _Spring Data for {data-store-name}'s_ `@EnableGemFireAsLastResource` configuration does the trick. +infrastructure and Spring Data for {data-store-name}'s `@EnableGemFireAsLastResource` configuration does the trick. The configuration looks like this... @@ -236,14 +236,14 @@ public JtaTransactionManager transactionManager(UserTransaction userTransaction) ---- NOTE: The configuration in section <> does *not* apply here. -The use of _Spring Data for {data-store-name}'s_ `GemfireTransactionManager` is applicable only in "Local", Cache Transactions, +The use of Spring Data for {data-store-name}'s `GemfireTransactionManager` is applicable only in "Local", Cache Transactions, *not* "Global", JTA Transactions. Therefore, you do *not* configure the SDG `GemfireTransactionManager` in this case. You configure Spring's `JtaTransactionManager` as shown above. For more details on using _Spring's Transaction Management_ with JTA, see http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#transaction-application-server-integration[here]. -Effectively, _Spring Data for {data-store-name}'s_ `@EnableGemFireAsLastResource` annotation imports configuration containing 2 Aspect +Effectively, Spring Data for {data-store-name}'s `@EnableGemFireAsLastResource` annotation imports configuration containing 2 Aspect bean definitions that handles the {data-store-name} `o.a.g.ra.GFConnectionFactory.getConnection()` and `o.a.g.ra.GFConnection.close()` operations at the appropriate points during the transactional operation. @@ -272,7 +272,7 @@ Thankfully, Spring does the heavy lifting for you and all you need do after appl class MyTransactionalService ... { @Transactional - public someTransactionalMethod() { + public someTransactionalServiceMethod() { // perform business logic interacting with and accessing multiple JTA resources atomically, here } @@ -281,7 +281,7 @@ class MyTransactionalService ... { ---- #1 & #4 above are appropriately handled for you by Spring's JTA based `PlatformTransactionManager` once the -`@Transactional` boundary is entered by your application (i.e. when the `MyTransactionSerivce.someTransactionalMethod()` +`@Transactional` boundary is entered by your application (i.e. when the `MyTransactionSerivce.someTransactionalServiceMethod()` is called). #2 & #3 are handled by Spring Data for {data-store-name}'s new Aspects enabled with the `@EnableGemFireAsLastResource` annotation. @@ -408,7 +408,7 @@ class DBLoader extends WiringDeclarableSupport implements CacheLoader { 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/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> @@ -440,7 +440,7 @@ one can pass in the `bean-name` parameter in the {data-store-name} configuration 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/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> @@ -497,8 +497,8 @@ class DBLoader extends WiringDeclarableSupport implements CacheLoader { xmlns:context="http://www.springframework.org/schema/context" 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/context http://www.springframework.org/schema/context/spring-context.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 "> @@ -524,15 +524,18 @@ To use {data-store-name} as a backing implementation, a "_caching provider_" _in simply add `GemfireCacheManager` to your configuration: [source,xml] +[subs="verbatim,attributes"] ---- + xmlns:cache="http://www.springframework.org/schema/cache" + xmlns:gfe="{spring-data-schema-namespace}" + 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/cache http://www.springframework.org/schema/cache/spring-cache.xsd + {spring-data-schema-namespace} {spring-data-schema-location} +"> @@ -575,15 +578,18 @@ Then you will need the following config. XML: [source,xml] +[subs="verbatim,attributes"] ---- + xmlns:cache="http://www.springframework.org/schema/cache" + xmlns:gfe="{spring-data-schema-namespace}" + 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/cache http://www.springframework.org/schema/cache/spring-cache.xsd + {spring-data-schema-namespace} {spring-data-schema-location} +"> diff --git a/src/main/asciidoc/reference/mapping.adoc b/src/main/asciidoc/reference/mapping.adoc index 3cd61fec..b24110aa 100644 --- a/src/main/asciidoc/reference/mapping.adoc +++ b/src/main/asciidoc/reference/mapping.adoc @@ -363,16 +363,14 @@ The following example shows the `Predicate` API in use: [source,java] ---- +Predicate> customerTypes = + type -> Customer.class.getPackage().getName().startsWith(type.getName()); - Predicate> customerTypes = - type -> Customer.class.getPackage().getName().startsWith(type.getName()); - - Predicate typeFilters = customerTypes - .or(type -> User.class.isAssignble(type)) // Include User sub-types (e.g. Admin, Guest, etc) - .and(type -> !Reference.class.getPackage(type.getPackage()); // Exclude all Reference types - - mappingPdxSerializer.setTypeFilters(typeFilters); +Predicate typeFilters = customerTypes + .or(type -> User.class.isAssignble(type)) // Include User sub-types (e.g. Admin, Guest, etc) + .and(type -> !Reference.class.getPackage(type.getPackage()); // Exclude all Reference types +mappingPdxSerializer.setTypeFilters(typeFilters); ---- NOTE: In addition to setting your own type filtering `Predicates`, SDG's `MappingPdxSerializer` now automatically diff --git a/src/main/asciidoc/reference/region.adoc b/src/main/asciidoc/reference/region.adoc index 24d14fc4..1db9f06b 100644 --- a/src/main/asciidoc/reference/region.adoc +++ b/src/main/asciidoc/reference/region.adoc @@ -70,9 +70,9 @@ For instance, consider the following `cache.xml` file: ---- + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" + version="1.0"> @@ -264,6 +264,8 @@ The second is an anonymous inner bean definition. [source,xml] ---- + + @@ -271,8 +273,6 @@ The second is an anonymous inner bean definition. - - ---- @@ -525,9 +525,9 @@ Consider the following native {data-store-name} `cache.xml` configuration file: ---- + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" + version="1.0"> @@ -558,14 +558,15 @@ not uncommon for a developer to define beans for some or all of these Regions in meta-data as follows: [source,xml] +[subs="verbatim,attributes"] ---- diff --git a/src/main/asciidoc/reference/repositories.adoc b/src/main/asciidoc/reference/repositories.adoc index 41f5b2fe..0666f185 100644 --- a/src/main/asciidoc/reference/repositories.adoc +++ b/src/main/asciidoc/reference/repositories.adoc @@ -14,13 +14,15 @@ Data namespace, as the following example shows: .Bootstrap Spring Data for {data-store-name} Repositories in XML ==== [source,xml] +[subs="verbatim,attributes"] ---- @@ -311,6 +313,7 @@ public interface CustomerRepository extends GemfireRepository { @Import("org.example.app.domain.Customer") @Query(" SELECT DISTINCT * FROM /Customers c WHERE c.reputation > $1 ORDER BY c.reputation DESC LIMIT 5") List findDistinctCustomersByReputationGreaterThanOrderByReputationDesc(Integer reputation); + } ---- ====