public class GemfireCacheManager extends AbstractCacheManager
CacheManager
implementation backed by a GemFire cache instance
(either a client or peer cache).
Automatically discovers available caches (or GemFire Regions
) when a cache for a given name
is missing and dynamic cache lookup/creation is enabled.Cache
,
CacheManager
,
AbstractCacheManager
,
GemFireCache
,
Region
Constructor and Description |
---|
GemfireCacheManager() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.geode.cache.GemFireCache |
getCache()
Returns the
GemFireCache instance backing this CacheManager . |
protected Cache |
getMissingCache(String name)
Returns a missing Spring
Cache for the given name . |
protected Set<org.apache.geode.cache.Region<?,?>> |
getRegions()
Returns the set of GemFire
Regions used explicitly as Spring Caches
in Spring's caching infrastructure. |
protected boolean |
isDynamic()
Determines whether this
CacheManager allows the dynamic creation of a Cache at runtime. |
protected Collection<Cache> |
loadCaches()
Loads all configured GemFire
Regions that will be used by this CacheManager . |
protected GemfireCache |
newGemfireCache(org.apache.geode.cache.Region<?,?> region)
Constructs a new instance of
GemfireCache initialized with the given GemFire Region . |
void |
setCache(org.apache.geode.cache.GemFireCache gemfireCache)
Sets the GemFire cache instance backing this
CacheManager . |
void |
setCacheNames(Set<String> cacheNames)
Sets the names of all Spring
Caches that will be used in the application. |
void |
setRegions(Set<org.apache.geode.cache.Region<?,?>> regions)
Explicitly sets the GemFire
Regions to be used as Spring Caches
in the application. |
addCache, afterPropertiesSet, decorateCache, getCache, getCacheNames, initializeCaches, lookupCache
protected Collection<Cache> loadCaches()
Regions
that will be used by this CacheManager
.
Any GemFire Regions
configured with the regions
property will take precedence over
any configured cacheNames
. If no GemFire Regions
were configured, then any
cacheNames
that were specified will be used to lookup existing GemFire Regions
to function as Spring Caches
in Spring's caching infrastructure.
However, if neither regions
nor cacheNames
were specified, then all defined GemFire
Regions
declared in the Spring application context, as determined by
RegionService.rootRegions()
, will be used as Spring Caches
, and this CacheManager
will allow any dynamically created GemFire Regions
at runtime to be found and used as a
Spring Cache
as well.loadCaches
in class AbstractCacheManager
Collection
of GemFire Regions
used by this CacheManager
to function as Caches
in Spring's caching infrastructure.IllegalStateException
- if a GemFire cache instance was not provided, the provided GemFire cache instance
has been closed, no GemFire Region
could be found for a given cache name, or the GemFire Region
for the given cache name has been destroyed.Cache
protected GemfireCache newGemfireCache(org.apache.geode.cache.Region<?,?> region)
GemfireCache
initialized with the given GemFire Region
.region
- GemFire Region
to wrap (adapt).GemfireCache
initialized with the given GemFire Region
.GemfireCache
,
Region
protected Cache getMissingCache(String name)
Cache
for the given name
.
To return a missing Spring Cache
for the given name
, dynamic cache lookup/creation must be
enabled, which means that either the cacheNames
or regions
properties must not be set.
If either property was specified then dynamic Spring Cache
lookup/creation will be disabled and this
overridden AbstractCacheManager.getMissingCache(String)
method will return null.getMissingCache
in class AbstractCacheManager
name
- name of the missing Spring Cache
to lookup (and potentially create).Cache
instance for the given name
or null if the Cache
cannot be found (or possibly created).AbstractCacheManager.getMissingCache(String)
,
Cache
protected boolean isDynamic()
CacheManager
allows the dynamic creation of a Cache
at runtime.Cache
creation is enabled.public void setCache(org.apache.geode.cache.GemFireCache gemfireCache)
CacheManager
.
When set, if neither Regions
nor cacheNames
were specified, then this CacheManager
is capable of creating Spring Caches
backed by existing GemFire Regions
used by
the application at runtime. However, in order to dynamically create Spring Caches
a reference to
an open GemFire cache instance must be set.gemfireCache
- the GemFire cache instance used by this CacheManager
to manage Spring Caches
.GemFireCache
protected org.apache.geode.cache.GemFireCache getCache()
GemFireCache
instance backing this CacheManager
.GemFireCache
instance backing this CacheManager
.GemFireCache
public void setCacheNames(Set<String> cacheNames)
Caches
that will be used in the application.
When set, this disables the dynamic capability of this CacheManager
to create Spring Caches
at runtime by dynamically looking up existing Regions
from the GemFire cache instance.public void setRegions(Set<org.apache.geode.cache.Region<?,?>> regions)
Regions
to be used as Spring Caches
in the application.
When set, this disables the dynamic capability of this CacheManager
to create Spring Caches
at runtime by dynamically looking up existing Regions
from the GemFire cache instance.regions
- Set
of GemFire Regions
used by this CacheManager
as Spring Caches
.Region
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.