|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.gemfire.GemfireAccessor org.springframework.data.gemfire.GemfireTemplate
public class GemfireTemplate
Helper class that simplifies GemFire data access code and converts GemFireCheckedException
and
GemFireException
into Spring DataAccessException
, following the org.springframework.dao
exception hierarchy.
Region
life-cycle exceptions.
Typically used to implement data access or business logic services that use 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.
Field Summary |
---|
Fields inherited from class org.springframework.data.gemfire.GemfireAccessor |
---|
log |
Constructor Summary | |
---|---|
GemfireTemplate()
|
|
GemfireTemplate(com.gemstone.gemfire.cache.Region<K,V> region)
|
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
boolean |
containsKey(Object key)
|
|
boolean |
containsKeyOnServer(Object key)
|
|
boolean |
containsValue(Object value)
|
|
boolean |
containsValueForKey(Object key)
|
|
|
create(K key,
V value)
|
|
protected
|
createRegionProxy(com.gemstone.gemfire.cache.Region<K,V> region)
Create a close-suppressing proxy for the given GemFire Region . |
|
|
execute(GemfireCallback<T> action)
|
|
|
execute(GemfireCallback<T> action,
boolean exposeNativeRegion)
Execute the action specified by the given action object within a Region. |
|
|
find(String query,
Object... params)
Executes a GemFire query with the given (optional) parameters and returns the result. |
|
|
findUnique(String query,
Object... params)
Executes a GemFire query with the given (optional) parameters and returns the result. |
|
|
get(K key)
|
|
|
getAll(Collection<?> keys)
|
|
boolean |
isExposeNativeRegion()
Returns whether to expose the native GemFire Region to GemfireCallback code, or rather a Region proxy. |
|
protected com.gemstone.gemfire.cache.query.QueryService |
lookupQueryService(com.gemstone.gemfire.cache.Region<?,?> region)
Returns the query service used by the template in its find methods. |
|
|
put(K key,
V value)
|
|
|
putAll(Map<? extends K,? extends V> map)
|
|
|
putIfAbsent(K key,
V value)
|
|
|
query(String query)
Shortcut for Region.query(String) method. |
|
|
remove(K key)
|
|
|
replace(K key,
V value)
|
|
|
replace(K key,
V oldValue,
V newValue)
|
|
void |
setExposeNativeRegion(boolean exposeNativeRegion)
Sets whether to expose the native Gemfire Region to GemfireCallback code. |
Methods inherited from class org.springframework.data.gemfire.GemfireAccessor |
---|
convertGemFireAccessException, convertGemFireAccessException, convertGemFireQueryException, getRegion, setRegion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GemfireTemplate()
public GemfireTemplate(com.gemstone.gemfire.cache.Region<K,V> region)
Method Detail |
---|
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class GemfireAccessor
public 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".
GemfireCallback
public boolean isExposeNativeRegion()
public boolean containsKey(Object key)
public boolean containsKeyOnServer(Object key)
public boolean containsValue(Object value)
public boolean containsValueForKey(Object key)
public <K,V> void create(K key, V value)
public <K,V> V get(K key)
public <K,V> V put(K key, V value)
public <K,V> V putIfAbsent(K key, V value)
public <K,V> V remove(K key)
public <K,V> V replace(K key, V value)
public <K,V> boolean replace(K key, V oldValue, V newValue)
public <K,V> Map<K,V> getAll(Collection<?> keys)
public <K,V> void putAll(Map<? extends K,? extends V> map)
public <E> com.gemstone.gemfire.cache.query.SelectResults<E> query(String query)
Region.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
- A query language boolean query predicate.
Region.query(String)
public <E> com.gemstone.gemfire.cache.query.SelectResults<E> find(String query, Object... params) throws InvalidDataAccessApiUsageException
findUnique(String, Object...)
.
As oppose, to the 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.
query
- GemFire queryparams
- Values that are bound to parameters (such as $1) in this query.
SelectResults
instance holding the objects matching the query
InvalidDataAccessApiUsageException
- in case the query returns a single result (not a SelectResults
).QueryService.newQuery(String)
,
Query.execute(Object[])
,
SelectResults
public <T> T findUnique(String query, Object... params) throws InvalidDataAccessApiUsageException
find(String, Object...)
.
As oppose, to the 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.
query
- GemFire queryparams
- Values that are bound to parameters (such as $1) in this query.
InvalidDataAccessApiUsageException
- in case the query returns multiple objects (through SelectResults
).QueryService.newQuery(String)
,
Query.execute(Object[])
protected com.gemstone.gemfire.cache.query.QueryService lookupQueryService(com.gemstone.gemfire.cache.Region<?,?> region)
region
- region to find the local query service from
public <T> T execute(GemfireCallback<T> action) throws DataAccessException
DataAccessException
public <T> T execute(GemfireCallback<T> action, boolean exposeNativeRegion) throws DataAccessException
action
- callback object that specifies the Gemfire actionexposeNativeRegion
- whether to expose the native
GemFire region to callback code
null
DataAccessException
- in case of GemFire errorsprotected <K,V> com.gemstone.gemfire.cache.Region<K,V> createRegionProxy(com.gemstone.gemfire.cache.Region<K,V> region)
Region
.
Called by the execute
method.
region
- the GemFire Region to create a proxy for
Region.close()
,
execute(GemfireCallback, boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |