public class GemfireTemplate extends GemfireAccessor implements GemfireOperations
GemFireCheckedException and
GemFireException into Spring DataAccessException, following the org.springframework.dao
exception hierarchy.
The central method is execute, supporting Pivotal GemFire access code implementing the GemfireCallback interface.
It provides dedicated handling such that neither the GemfireCallback implementation nor the calling code needs to
explicitly care about handling Region life-cycle exceptions.
Typically used to implement data access or business logic services that use Pivotal GemFire within their implementation but
are GemFire-agnostic in their interface. The latter or code calling the latter only have to deal with business
objects, query objects, and org.springframework.dao exceptions.Map,
GemfireAccessor,
GemfireOperations,
Region,
Query,
QueryService,
SelectResultslogger| Constructor and Description |
|---|
GemfireTemplate() |
GemfireTemplate(org.apache.geode.cache.Region<K,V> region) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
boolean |
containsKey(Object key) |
boolean |
containsKeyOnServer(Object key) |
boolean |
containsValue(Object value) |
boolean |
containsValueForKey(Object key) |
<K,V> void |
create(K key,
V value) |
protected <K,V> org.apache.geode.cache.Region<K,V> |
createRegionProxy(org.apache.geode.cache.Region<K,V> region)
Create a close-suppressing proxy for the given Pivotal GemFire Cache
Region. |
<T> T |
execute(GemfireCallback<T> action)
Execute the action specified by the given action object within a Region.
|
<T> T |
execute(GemfireCallback<T> action,
boolean exposeNativeRegion)
Execute the action specified by the given action object within a Region.
|
<E> org.apache.geode.cache.query.SelectResults<E> |
find(String queryString,
Object... params)
Executes a Pivotal GemFire query with the given (optional) parameters and returns the result.
|
<T> T |
findUnique(String queryString,
Object... params)
Executes a Pivotal GemFire query with the given (optional) parameters and returns the result.
|
<K,V> V |
get(K key) |
<K,V> Map<K,V> |
getAll(Collection<?> keys) |
boolean |
isExposeNativeRegion()
Returns whether to expose the native Pivotal GemFire Cache Region or a Region proxy to the GemfireCallback code.
|
<K,V> V |
put(K key,
V value) |
<K,V> void |
putAll(Map<? extends K,? extends V> map) |
<K,V> V |
putIfAbsent(K key,
V value) |
<E> org.apache.geode.cache.query.SelectResults<E> |
query(String query)
Shortcut for
Region.query(String) method. |
<K,V> V |
remove(K key) |
<K,V> V |
replace(K key,
V value) |
<K,V> boolean |
replace(K key,
V oldValue,
V newValue) |
protected org.apache.geode.cache.query.QueryService |
resolveQueryService(org.apache.geode.cache.Region<?,?> region)
Returns the
QueryService used by this template in its query/finder methods. |
void |
setExposeNativeRegion(boolean exposeNativeRegion)
Sets whether to expose the native Gemfire Region to GemfireCallback code.
|
convertGemFireAccessException, convertGemFireAccessException, convertGemFireQueryException, getRegion, setRegionpublic GemfireTemplate()
public GemfireTemplate(org.apache.geode.cache.Region<K,V> region)
public void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in class GemfireAccessorpublic void setExposeNativeRegion(boolean exposeNativeRegion)
close calls.
As there is often a need to cast to a interface, the exposed proxy implements all interfaces
implemented by the original Region. If this is not sufficient, turn this flag to "true".
exposeNativeRegion - a boolean value to indicate whether the native Pivotal GemFire Cache Region should be exposed
to the GemfireCallback.GemfireCallbackpublic boolean isExposeNativeRegion()
public boolean containsKey(Object key)
containsKey in interface GemfireOperationspublic boolean containsKeyOnServer(Object key)
containsKeyOnServer in interface GemfireOperationspublic boolean containsValue(Object value)
containsValue in interface GemfireOperationspublic boolean containsValueForKey(Object key)
containsValueForKey in interface GemfireOperationspublic <K,V> void create(K key,
V value)
create in interface GemfireOperationspublic <K,V> V get(K key)
get in interface GemfireOperationspublic <K,V> Map<K,V> getAll(Collection<?> keys)
getAll in interface GemfireOperationspublic <K,V> V put(K key,
V value)
put in interface GemfireOperationspublic <K,V> void putAll(Map<? extends K,? extends V> map)
putAll in interface GemfireOperationspublic <K,V> V putIfAbsent(K key,
V value)
putIfAbsent in interface GemfireOperationspublic <K,V> V remove(K key)
remove in interface GemfireOperationspublic <K,V> V replace(K key,
V value)
replace in interface GemfireOperationspublic <K,V> boolean replace(K key,
V oldValue,
V newValue)
replace in interface GemfireOperationspublic <E> org.apache.geode.cache.query.SelectResults<E> query(String query)
GemfireOperationsRegion.query(String) method. Filters the values of this region using the predicate given as a string with the syntax of the WHERE clause of the query language.
The predefined variable this may be used inside the predicate to denote the current element being filtered.
This method evaluates the passed in where clause and returns results. It is supported on servers as well as clients.
When executed on a client, this method always runs on the server and returns results.
When invoking this method from the client, applications can pass in a where clause or a complete query.query in interface GemfireOperationsE - type parameter specifying the type of the select results.query - an OQL Query language boolean query predicate.Region.query(String)public <E> org.apache.geode.cache.query.SelectResults<E> find(String queryString, Object... params) throws InvalidDataAccessApiUsageException
GemfireOperationsGemfireOperations.findUnique(String, Object...).
As oppose, to the GemfireOperations.query(String) method, this method allows for more generic queries (against multiple regions even) to be executed.
Note that the local query service is used if the region is configured as a client without any pool configuration or server connectivity - otherwise the query service on the default pool
is being used.find in interface GemfireOperationsE - type parameter specifying the type of the select results.queryString - the OQL query statement to execute.params - an array of Object values used as arguments to bind to the OQL query parameters (such as $1).SelectResults instance holding the objects matching the queryInvalidDataAccessApiUsageException - in case the query returns a single result (not a SelectResults).QueryService.newQuery(String),
Query.execute(Object[]),
SelectResultspublic <T> T findUnique(String queryString, Object... params) throws InvalidDataAccessApiUsageException
GemfireOperationsGemfireOperations.find(String, Object...).
As oppose, to the GemfireOperations.query(String) method, this method allows for more generic queries (against multiple regions even) to be executed.
Note that the local query service is used if the region is configured as a client without any pool configuration or server connectivity - otherwise the query service on the default pool
is being used.findUnique in interface GemfireOperationsT - type parameter specifying the returned result type.queryString - the OQL query statement to execute.params - an array of Object values used as arguments to bind to the OQL query parameters (such as $1).InvalidDataAccessApiUsageException - in case the query returns multiple objects (through SelectResults).QueryService.newQuery(String),
Query.execute(Object[])protected org.apache.geode.cache.query.QueryService resolveQueryService(org.apache.geode.cache.Region<?,?> region)
QueryService used by this template in its query/finder methods.region - Region used to acquire the QueryService.QueryService that will perform the query.Region,
Region.getRegionService(),
RegionService.getQueryService(),
ClientCache.getLocalQueryService()public <T> T execute(GemfireCallback<T> action) throws DataAccessException
GemfireOperationsexecute in interface GemfireOperationsT - type parameter specifying the returned result type.action - callback object that specifies the Gemfire action to execute.null.DataAccessException - in case of Pivotal GemFire errors.public <T> T execute(GemfireCallback<T> action, boolean exposeNativeRegion) throws DataAccessException
GemfireOperationsexecute in interface GemfireOperationsT - type parameter specifying the returned result type.action - callback object that specifies the Gemfire action to execute.exposeNativeRegion - whether to expose the native Pivotal GemFire region to callback code.null.DataAccessException - in case of Pivotal GemFire errors.protected <K,V> org.apache.geode.cache.Region<K,V> createRegionProxy(org.apache.geode.cache.Region<K,V> region)
Region.
Called by the execute method.K - the Region key class type.V - the Region value class type.region - the Pivotal GemFire Cache Region to create a proxy for.Region.close(),
execute(GemfireCallback, boolean)Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.