SGF-402 - Document Lucene integration support.
(cherry picked from commit 556afed8772ad37a99e4a3b9f6d3783ee3e9a872) Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
@@ -7,7 +7,7 @@ Costin Leau , David Turanski , John Blum , Oliver Gierke
|
||||
:toc-placement!:
|
||||
:spring-data-commons-docs: {basedocdir}/../../../../spring-data-commons/src/main/asciidoc
|
||||
|
||||
(C) 2011-2015 The original authors.
|
||||
(C) 2010-2017 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
|
||||
@@ -20,18 +20,15 @@ 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[]
|
||||
@@ -39,20 +36,19 @@ include::{baseDir}/reference/serialization.adoc[]
|
||||
include::{baseDir}/reference/mapping.adoc[]
|
||||
include::{baseDir}/reference/repositories.adoc[]
|
||||
include::{baseDir}/reference/function-annotations.adoc[]
|
||||
include::{basedocdir}/reference/lucene.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.
|
||||
In addition to this reference documentation, there are a number of other resources that may help you learn
|
||||
how to use GemFire with the Spring Framework. These additional, third-party resources are enumerated in this section.
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
include::{baseDir}/links.adoc[]
|
||||
|
||||
:leveloffset: -1
|
||||
|
||||
[[appendices]]
|
||||
@@ -65,5 +61,4 @@ include::{spring-data-commons-docs}/repository-populator-namespace-reference.ado
|
||||
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
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
[[bootstrap]]
|
||||
= Bootstrapping GemFire through the Spring Container
|
||||
= Bootstrapping GemFire with 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.
|
||||
Spring Data GemFire provides full configuration and initialization of the Pivotal GemFire In-Memory Data Grid
|
||||
using the Spring IoC container. The framework includes several classes to help simplify the configuration of
|
||||
Pivotal GemFire components including: Caches, Regions, Indexes, DiskStores, Functions, WAN Gateways, persistence backup
|
||||
along with several other Distributed System components in order to support a variety of use cases 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].
|
||||
NOTE: This section assumes basic familiarity with Pivotal 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.
|
||||
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
|
||||
@@ -93,31 +97,7 @@ prefix declaration above:
|
||||
include::{basedocdir}/reference/cache.adoc[]
|
||||
include::{basedocdir}/reference/data-access.adoc[]
|
||||
include::{basedocdir}/reference/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::{basedocdir}/reference/indexing.adoc[]
|
||||
include::{basedocdir}/reference/diskstore.adoc[]
|
||||
include::{basedocdir}/reference/snapshot.adoc[]
|
||||
include::{basedocdir}/reference/function.adoc[]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[[apis]]
|
||||
= Working with the GemFire APIs
|
||||
= Working with 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.
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
[[bootstrap-diskstore]]
|
||||
= Configuring a Disk Store
|
||||
[[bootstrap:diskstore]]
|
||||
= Configuring a DiskStore
|
||||
|
||||
As of Release 1.2.0, Spring Data GemFire supports disk store configuration via a top level `disk-store` element.
|
||||
As of Release 1.2.0, _Spring Data GemFire_ supports `DiskStore` configuration via the `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.
|
||||
NOTE: Prior to Release 1.2.0, `disk-store` was a child element of the `\*-region` elements.
|
||||
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 all `disk-store` element(s) to the top-level,
|
||||
assign an `id` and use the `*-region` element's `disk-store-ref` attribute.
|
||||
|
||||
Also, `disk-synchronous` is now a `*-region` attribute.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
@@ -14,5 +19,8 @@ NOTE: Prior to Release 1.2.0, `disk-store` was a child element of `*-region`. If
|
||||
</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.
|
||||
`DiskStores` are used by Regions for file system persistent backup or overflow storage of evicted entries,
|
||||
and persistent backup of WAN Gateways. Multiple components may share the same `DiskStore`.
|
||||
Additionally, multiple directories may be defined for a single `DiskStore`.
|
||||
|
||||
Please refer to Pivotal GemFire's documentation for an explanation of the configuration options.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[[bootstrap:function]]
|
||||
= Configuring GemFire's Function Service
|
||||
= Configuring the 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://data-docs-samples.cfapps.io/docs-gemfire/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 `org.apache.geode.cache.execute.Function` interface or extend `org.apache.geode.cache.execute.FunctionAdapter`. The namespace uses a familiar pattern to declare functions:
|
||||
|
||||
|
||||
25
src/main/asciidoc/reference/indexing.adoc
Normal file
25
src/main/asciidoc/reference/indexing.adoc
Normal file
@@ -0,0 +1,25 @@
|
||||
[[bootstrap:indexing]]
|
||||
= Creating an Index
|
||||
|
||||
Pivotal GemFire allows Indexes (or Indices) to be created to improve the performance of OQL queries.
|
||||
|
||||
In _Spring Data GemFire_, Indices can be declared with 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 using the new bean definition,
|
||||
regardless if the old `Index` definition was the same or not.
|
||||
|
||||
To prevent the named `Index` definition change, especially when the old and new `Index` definitions differ
|
||||
in a significant way, then set the `override` attribute to `false`, which effectively returns the existing
|
||||
`Index` definition given the same name.
|
||||
|
||||
`Index` declarations are not bound to a Region but rather are top-level elements (just like `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 XML schema for a full set of options.
|
||||
@@ -1,21 +1,26 @@
|
||||
[[ref-introduction]]
|
||||
= Document Structure
|
||||
|
||||
The following chapters explain the core functionality offered by Spring Data GemFire.
|
||||
The following chapters explain the core functionality offered by Spring Data GemFire for Pivotal GemFire.
|
||||
|
||||
<<bootstrap>> describes the configuration support provided for bootstrapping, configuring, initializing and accessing GemFire Caches, Cache Servers, Regions, and related Distributed System components.
|
||||
This reference guide is equally applicable to Spring Data Geode for Apache Geode.
|
||||
|
||||
<<apis>> explains the integration between the GemFire APIs and the various data access features available in Spring, such as transaction management and exception translation.
|
||||
<<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.
|
||||
<<mapping>> describes persistence mapping for POJOs stored in GemFire or Geode 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.
|
||||
<<gemfire-bootstrap>> describes how to bootstrap a Spring ApplicationContext running in a GemFire or Geode Server
|
||||
using Gfsh.
|
||||
|
||||
<<samples>> describes the samples provided with the distribution to illustrate the various features
|
||||
available in Spring Data GemFire and/or Spring Data Geode.
|
||||
|
||||
282
src/main/asciidoc/reference/lucene.adoc
Normal file
282
src/main/asciidoc/reference/lucene.adoc
Normal file
@@ -0,0 +1,282 @@
|
||||
[[bootstrap:lucene]]
|
||||
= Apache Lucene Integration
|
||||
|
||||
http://geode.apache.org/[Apache Geode] integrates with http://lucene.apache.org/[Apache Lucene] to allow developers
|
||||
to index and search on data stored in Apache Geode using Lucene queries. Search-based queries also includes
|
||||
the capability to page through query results.
|
||||
|
||||
Additionally, _Spring Data Geode_ adds support for query projections based on _Spring Data Commons_
|
||||
Projection infrastructure. This feature enables the query results to be projected into first-class,
|
||||
application domain types as needed or required by the application use case.
|
||||
|
||||
However, a Lucene `Index` must be created first before any Lucene search-based query can be ran. A `LuceneIndex`
|
||||
can be created in _Spring (Data GemFire)_ XML config like so...
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<gfe:lucene-index id="IndexOne" fields="fieldOne, fieldTwo" region-path="/Example"/>
|
||||
----
|
||||
|
||||
Additionally, Apache Lucene allows the specification of
|
||||
http://lucene.apache.org/core/6_5_0/core/org/apache/lucene/analysis/Analyzer.html[Analyzers] per field
|
||||
and can be configured like so...
|
||||
|
||||
[source.xml]
|
||||
----
|
||||
<gfe:lucene-index id="IndexTwo" lucene-service-ref="luceneService" region-path="/AnotherExample">
|
||||
<gfe:field-analyzers>
|
||||
<map>
|
||||
<entry key="fieldOne">
|
||||
<bean class="example.AnalyzerOne"/>
|
||||
</entry>
|
||||
<entry key="fieldTwo">
|
||||
<bean class="example.AnalyzerTwo"/>
|
||||
</entry>
|
||||
</map>
|
||||
</gfe:field-analyzers>
|
||||
</gfe:lucene-index>
|
||||
----
|
||||
|
||||
Of course, the `Map` can be specified at top-level bean definitions and referenced using the `ref` attribute
|
||||
on the `<gfe:field-analyzers>` element like this, `<gfe-field-analyzers ref="refToTopLevelMapBeanDefinition"/>`.
|
||||
|
||||
Alternatively, a `LuceneIndex` can be declared in _Spring_ Java config, inside a `@Configuration` class like so...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Bean(name = "People")
|
||||
@DependsOn("personTitleIndex")
|
||||
PartitionedRegionFactoryBean<Long, Person> peopleRegion(GemFireCache gemfireCache) {
|
||||
PartitionedRegionFactoryBean<Long, Person> peopleRegion = new PartitionedRegionFactoryBean<>();
|
||||
|
||||
peopleRegion.setCache(gemfireCache);
|
||||
peopleRegion.setClose(false);
|
||||
peopleRegion.setPersistent(false);
|
||||
|
||||
return peopleRegion;
|
||||
}
|
||||
|
||||
@Bean
|
||||
LuceneIndexFactoryBean personTitleIndex(GemFireCache gemFireCache) {
|
||||
LuceneIndexFactoryBean luceneIndex = new LuceneIndexFactoryBean();
|
||||
|
||||
luceneIndex.setCache(gemFireCache);
|
||||
luceneIndex.setFields("title");
|
||||
luceneIndex.setRegionPath("/People");
|
||||
|
||||
return luceneIndex;
|
||||
}
|
||||
----
|
||||
|
||||
There are a few limitations of Apache Geode's, Apache Lucene integration support. First, a `LuceneIndex` can only
|
||||
be created on a Geode `PARTITION` Region. Second, all `LuceneIndexes` must be created before the the Region on which
|
||||
the `LuceneIndex` is applied.
|
||||
|
||||
It is possible that these Apache Geode restrictions will not apply in a future release which is why
|
||||
the SDG `LuceneIndexFactoryBean` can take a reference to the Region directly rather than just the Region path,
|
||||
which is more ideal. For instance, it is reasonable to assume that some users may want to define a `LuceneIndex`
|
||||
on an already existing Region with data at a later point in the application lifecycle and as requirements demand.
|
||||
Where possible, SDG strives to stick to strongly-typed objects and classes.
|
||||
|
||||
Now that we have a `LuceneIndex` we can perform Lucene based data access operations, such as queries and so on.
|
||||
|
||||
#### Lucene Template Data Accessors
|
||||
|
||||
_Spring Data Geode_ provides 2 primary templates for Lucene data access operations, depending on how low a level
|
||||
your application is prepared to deal with.
|
||||
|
||||
The `LuceneOperations` interface defines query operations using Apache Geode
|
||||
http://geode.apache.org/releases/latest/javadoc/org/apache/geode/cache/lucene/package-frame.html[Lucene types].
|
||||
|
||||
[source,java]
|
||||
----
|
||||
public interface LuceneOperations {
|
||||
|
||||
<K, V> List<LuceneResultStruct<K, V>> query(String query, String defaultField [, int resultLimit]
|
||||
, String... projectionFields);
|
||||
|
||||
<K, V> PageableLuceneQueryResults<K, V> query(String query, String defaultField,
|
||||
int resultLimit, int pageSize, String... projectionFields);
|
||||
|
||||
<K, V> List<LuceneResultStruct<K, V>> query(LuceneQueryProvider queryProvider [, int resultLimit]
|
||||
, String... projectionFields);
|
||||
|
||||
<K, V> PageableLuceneQueryResults<K, V> query(LuceneQueryProvider queryProvider,
|
||||
int resultLimit, int pageSize, String... projectionFields);
|
||||
|
||||
<K> Collection<K> queryForKeys(String query, String defaultField [, int resultLimit]);
|
||||
|
||||
<K> Collection<K> queryForKeys(LuceneQueryProvider queryProvider [, int resultLimit]);
|
||||
|
||||
<V> Collection<V> queryForValues(String query, String defaultField [, int resultLimit]);
|
||||
|
||||
<V> Collection<V> queryForValues(LuceneQueryProvider queryProvider [, int resultLimit]);
|
||||
}
|
||||
----
|
||||
|
||||
The operations in the `LuceneOperations` interface match the operations provided by the Apache Geode
|
||||
http://geode.apache.org/releases/latest/javadoc/org/apache/geode/cache/lucene/LuceneQuery.html[LuceneQuery] interface,
|
||||
however SDG has the added value of translating proprietary Geode or Lucene `Exceptions` into _Spring's_ highly
|
||||
consistent and expressive DAO
|
||||
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#dao-exceptions[Exception Hierarchy],
|
||||
particularly as many modern data access operations involve more than one store or repository.
|
||||
|
||||
Additionally, SDG's `LuceneOperations` interface can shield your application from interface breaking changes
|
||||
introduced by the underlying Apache Geode or Apache Lucene APIs when they do and will change.
|
||||
|
||||
However, it would be remorse to only offer a Lucene Data Access Object that only uses Apache Geode and Apache Lucene
|
||||
data types (e.g. Geode's `LuceneResultStruct`), therefore SDG gives you the `ProjectingLuceneOperations` interface
|
||||
to remedy these important application concerns.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
public interface ProjectingLuceneOperations {
|
||||
|
||||
<T> List<T> query(String query, String defaultField [, int resultLimit], Class<T> projectionType);
|
||||
|
||||
<T> Page<T> query(String query, String defaultField, int resultLimit, int pageSize, Class<T> projectionType);
|
||||
|
||||
<T> List<T> query(LuceneQueryProvider queryProvider [, int resultLimit], Class<T> projectionType);
|
||||
|
||||
<T> Page<T> query(LuceneQueryProvider queryProvider, int resultLimit, int pageSize, Class<T> projectionType);
|
||||
}
|
||||
----
|
||||
|
||||
The `ProjectingLuceneOperations` interface primarily uses application domain object types to work with
|
||||
your application data. The `query` method variants accept a "projection type" and the template applies
|
||||
the query results to instances of the given projection type using the _Spring Data Commons_
|
||||
Projection infrastructure.
|
||||
|
||||
Additionally, the template wraps the paged Lucene query results in an instance of the _Spring Data Commons_
|
||||
abstraction representing a `Page`. The same projection logic can still be applied to the results in the page
|
||||
and are lazily projected as each page in the collection is accessed.
|
||||
|
||||
By way of example, suppose I have a class representing a `Person` like so...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
class Person {
|
||||
|
||||
Gender gender;
|
||||
|
||||
LocalDate birthDate;
|
||||
|
||||
String firstName;
|
||||
String lastName;
|
||||
|
||||
...
|
||||
|
||||
String getName() {
|
||||
return String.format("%1$s %2$s", getFirstName(), getLastName());
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Additionally, I might have a single interface to represent people as Customers depending on my application view...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
interface Customer {
|
||||
|
||||
String getName()
|
||||
}
|
||||
----
|
||||
|
||||
If I define the following `LuceneIndex`...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
LuceneIndexFactoryBean personLastNameIndex(GemFireCache gemfireCache) {
|
||||
LuceneIndexFactoryBean personLastNameIndex = new LuceneIndexFactoryBean();
|
||||
|
||||
personLastNameIndex.setCache(gemfireCache);
|
||||
personLastNameIndex.setFields("lastName");
|
||||
personLastNameIndex.setRegionPath("/People");
|
||||
|
||||
return personLastNameIndex;
|
||||
}
|
||||
----
|
||||
|
||||
Then it is a simple matter to query for people as either `Person` objects...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
List<Person> people = luceneTemplate.query("lastName: D*", "lastName", Person.class);
|
||||
----
|
||||
|
||||
Or as a page of type `Customer`...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
Page<Customer> customers = luceneTemplate.query("lastName: D*", "lastName", 100, 20, Customer.class);
|
||||
----
|
||||
|
||||
The `Page` can then be used to fetch individual pages of results...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
List<Customer> firstPage = customers.getContent();
|
||||
----
|
||||
|
||||
Conveniently, the _Spring Data Commons_ `Page` interface implements `java.lang.Iterable<T>` too making it very easy
|
||||
to iterate over the content as well.
|
||||
|
||||
The only restriction to the _Spring Data Commons_ Projection infrastructure is that the "projection type"
|
||||
must be an interface. However, it is possible to extend the provided, out-of-the-box (OOTB)
|
||||
SDC Projection infrastructure and provide a "custom"
|
||||
http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/projection/ProjectionFactory.html[ProjectionFactory]
|
||||
that uses https://github.com/cglib/cglib[CGLIB] to generate proxy classes as the projected entity.
|
||||
|
||||
The "custom" `ProjectionFactory` can then be set on the template using `setProjectionFactory(:ProjectionFactory)`.
|
||||
|
||||
#### Annotation configuration support
|
||||
|
||||
Finally, _Spring Data Geode_ provides Annotation configuration support for `LuceneIndexes`. Eventually, the SDG Lucene
|
||||
support will find its way into the Repository infrastructure extension for Apache Geode so that Lucene queries
|
||||
can be expressed as methods on an application Repository interface, much like the
|
||||
http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#gemfire-repositories.executing-queries[OQL support]
|
||||
today.
|
||||
|
||||
However, in the meantime, if you want to conveniently express `LuceneIndexes`, you can do so directly on
|
||||
your application domain objects like so...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@PartitionRegion("People")
|
||||
class Person {
|
||||
|
||||
Gender gender;
|
||||
|
||||
@Index
|
||||
LocalDate birthDate;
|
||||
|
||||
String firstName;
|
||||
|
||||
@LuceneIndex;
|
||||
String lastName;
|
||||
|
||||
...
|
||||
}
|
||||
----
|
||||
|
||||
You must be using the SDG Annotation configuration support along with the `@EnableEntityDefineRegions`
|
||||
and `@EnableIndexing` Annotations to enable this feature...
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@PeerCacheApplication
|
||||
@EnableEntityDefinedRegions
|
||||
@EnableIndexing
|
||||
class ApplicationConfiguration {
|
||||
|
||||
...
|
||||
}
|
||||
----
|
||||
|
||||
Given our definition of the `Person` class above, the SDG Annotation configuration support
|
||||
will find the `Person` entity class definition, determine that people will be stored in
|
||||
a `PARTITION` Region called "People" and that the Person will have an OQL `Index` on `birthDate`
|
||||
along with a `LuceneIndex` on `lastName`.
|
||||
|
||||
More will be described with this feature in subsequent releases.
|
||||
@@ -35,15 +35,10 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link IllegalArgumentException} with the given {@link String message}
|
||||
* and {@link Object[] arguments} used to format the message.
|
||||
* and {@link Object arguments} used to format the message.
|
||||
*
|
||||
<<<<<<< HEAD
|
||||
* @param message {@link String} describing the exception.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
=======
|
||||
* @param message {@link String} describing the {@link IllegalArgumentException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
|
||||
>>>>>>> f104d57... SGF-402 - Add Lucene Integration support.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link IllegalArgumentException} with the given {@link String message}.
|
||||
* @see #newIllegalArgumentException(Throwable, String, Object...)
|
||||
* @see java.lang.IllegalArgumentException
|
||||
@@ -54,12 +49,12 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link IllegalArgumentException} with the given {@link Throwable cause},
|
||||
* {@link String message} and {@link Object[] arguments} used to format the message.
|
||||
* {@link String message} and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param cause {@link Throwable} identifying the reason the {@link IllegalArgumentException} was thrown.
|
||||
* @param message {@link String} describing the exception.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
* @return a new {@link IllegalArgumentException} with the given {@link String message}.
|
||||
* @param message {@link String} describing the {@link IllegalArgumentException exception}.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link IllegalArgumentException} with the given {@link Throwable cause} and {@link String message}.
|
||||
* @see java.lang.IllegalArgumentException
|
||||
*/
|
||||
public static IllegalArgumentException newIllegalArgumentException(Throwable cause,
|
||||
@@ -70,10 +65,10 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link IllegalStateException} with the given {@link String message}
|
||||
* and {@link Object[] arguments} used to format the message.
|
||||
* and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param message {@link String} describing the {@link IllegalStateException exception}.
|
||||
* @param args {@link Object} array of arguments used to replace format placeholders in the {@link String message}.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link IllegalStateException} with the given {@link String message}.
|
||||
* @see #newIllegalStateException(Throwable, String, Object...)
|
||||
* @see java.lang.IllegalStateException
|
||||
@@ -84,18 +79,12 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link IllegalStateException} with the given {@link Throwable cause},
|
||||
* {@link String message} and {@link Object[] arguments} used to format the message.
|
||||
* {@link String message} and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param cause {@link Throwable} identifying the reason the {@link IllegalStateException} was thrown.
|
||||
<<<<<<< HEAD
|
||||
* @param message {@link String} describing the exception.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
* @return a new {@link IllegalStateException} with the given {@link String message}.
|
||||
=======
|
||||
* @param message {@link String} describing the {@link IllegalStateException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link IllegalStateException} with the given {@link Throwable cause} and {@link String message}.
|
||||
>>>>>>> f104d57... SGF-402 - Add Lucene Integration support.
|
||||
* @see java.lang.IllegalStateException
|
||||
*/
|
||||
public static IllegalStateException newIllegalStateException(Throwable cause, String message, Object... args) {
|
||||
@@ -104,15 +93,10 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link RuntimeException} with the given {@link String message}
|
||||
* and {@link Object[] arguments} used to format the message.
|
||||
* and {@link Object arguments} used to format the message.
|
||||
*
|
||||
<<<<<<< HEAD
|
||||
* @param message {@link String} describing the exception.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
=======
|
||||
* @param message {@link String} describing the {@link RuntimeException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
|
||||
>>>>>>> f104d57... SGF-402 - Add Lucene Integration support.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link RuntimeException} with the given {@link String message}.
|
||||
* @see #newRuntimeException(Throwable, String, Object...)
|
||||
* @see java.lang.RuntimeException
|
||||
@@ -123,18 +107,12 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link RuntimeException} with the given {@link Throwable cause},
|
||||
* {@link String message} and {@link Object[] arguments} used to format the message.
|
||||
* {@link String message} and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param cause {@link Throwable} identifying the reason the {@link RuntimeException} was thrown.
|
||||
<<<<<<< HEAD
|
||||
* @param message {@link String} describing the exception.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
* @return a new {@link RuntimeException} with the given {@link String message}.
|
||||
=======
|
||||
* @param message {@link String} describing the {@link RuntimeException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link RuntimeException} with the given {@link Throwable cause} and {@link String message}.
|
||||
>>>>>>> f104d57... SGF-402 - Add Lucene Integration support.
|
||||
* @see java.lang.RuntimeException
|
||||
*/
|
||||
public static RuntimeException newRuntimeException(Throwable cause, String message, Object... args) {
|
||||
@@ -142,13 +120,11 @@ public abstract class RuntimeExceptionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* Constructs and initializes an {@link UnsupportedOperationException} with the given {@link String message}
|
||||
* and {@link Object[] arguments} used to format the message.
|
||||
* and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param message {@link String} describing the {@link UnsupportedOperationException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link UnsupportedOperationException} with the given {@link String message}.
|
||||
* @see #newUnsupportedOperationException(Throwable, String, Object...)
|
||||
* @see java.lang.UnsupportedOperationException
|
||||
@@ -159,11 +135,11 @@ public abstract class RuntimeExceptionFactory {
|
||||
|
||||
/**
|
||||
* Constructs and initializes an {@link UnsupportedOperationException} with the given {@link Throwable cause},
|
||||
* {@link String message} and {@link Object[] arguments} used to format the message.
|
||||
* {@link String message} and {@link Object arguments} used to format the message.
|
||||
*
|
||||
* @param cause {@link Throwable} identifying the reason the {@link UnsupportedOperationException} was thrown.
|
||||
* @param message {@link String} describing the {@link UnsupportedOperationException exception}.
|
||||
* @param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return a new {@link UnsupportedOperationException} with the given {@link Throwable cause}
|
||||
* and {@link String message}.
|
||||
* @see java.lang.UnsupportedOperationException
|
||||
@@ -175,11 +151,10 @@ public abstract class RuntimeExceptionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> f104d57... SGF-402 - Add Lucene Integration support.
|
||||
* Formats the given {@link String message} using the given {@link Object[] arguments}.
|
||||
* Formats the given {@link String message} using the given {@link Object arguments}.
|
||||
*
|
||||
* @param message {@link String} containing the message pattern to format.
|
||||
* @param args {@link Object[] arguments} used in the message to replace format placeholders.
|
||||
* @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}.
|
||||
* @return the formatted {@link String message}.
|
||||
* @see java.lang.String#format(String, Object...)
|
||||
* @see java.text.MessageFormat#format(String, Object...)
|
||||
|
||||
Reference in New Issue
Block a user