Package org.springframework.data.gemfire
Class AbstractBasicCacheFactoryBean
java.lang.Object
org.springframework.data.gemfire.support.AbstractFactoryBeanSupport<org.apache.geode.cache.GemFireCache>
org.springframework.data.gemfire.AbstractBasicCacheFactoryBean
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.FactoryBean<org.apache.geode.cache.GemFireCache>
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.Phased
,org.springframework.dao.support.PersistenceExceptionTranslator
- Direct Known Subclasses:
AbstractConfigurableCacheFactoryBean
public abstract class AbstractBasicCacheFactoryBean
extends AbstractFactoryBeanSupport<org.apache.geode.cache.GemFireCache>
implements org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.dao.support.PersistenceExceptionTranslator, org.springframework.context.Phased
Abstract base class for
CacheFactoryBean
and ClientCacheFactoryBean
classes,
used to create Apache Geode peer Cache
and ClientCache
instances, respectively.
This class implements Spring's PersistenceExceptionTranslator
interface and is auto-detected by Spring's
PersistenceExceptionTranslationPostProcessor
to enable AOP-based translation of native Apache Geode
RuntimeExceptions
to Spring's DataAccessException
hierarchy. Therefore,
the presence of this class automatically enables Spring's PersistenceExceptionTranslationPostProcessor
to translate native Apache Geode thrown GemFireException
and GemFireCheckedException
types
as Spring DataAccessExceptions
.
In addition, this class also assumes the responsibility of positioning the creation of the cache in the appropriate
phase of the Spring container's lifecycle, providing default callbacks for both initialization and destruction.
More importantly, this abstract class encapsulates configuration applicable to tuning Apache Geode in order to
efficiently use JVM Heap memory. Since Apache Geode stores data in-memory, on the JVM Heap, it is important that
Apache Geode be tuned to monitor the JVM Heap and respond to memory pressure accordingly, by evicting data
and issuing warnings when the JVM Heap reaches critical mass.
This abstract class is also concerned with the configuration of PDX and transaction event handling along with
whether the contents (entries) of the cache should be made effectively immutable on reads (i.e. get(key)).
In summary, this abstract class primarily handles and encapsulates the configuration of the following concerns:
- copy-on-read semantics
- JVM Heap memory management
- PDX serialization
- Transaction event processing
ClientCache
and peer Cache
instances.- Since:
- 2.5.0
- See Also:
-
GemFireCheckedException
GemFireException
Cache
CacheFactory
DiskStore
GemFireCache
Region
TransactionListener
TransactionWriter
ClientCache
ClientCacheFactory
PdxSerializer
DisposableBean
FactoryBean
InitializingBean
Phased
DataAccessException
PersistenceExceptionTranslationPostProcessor
PersistenceExceptionTranslator
CacheFactoryBean
ClientCacheFactoryBean
ClientCacheConfigurer
PeerCacheConfigurer
AbstractFactoryBeanSupport
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Callback interface for initializing aCacheFactory
or aClientCacheFactory
instance, which is used to create an instance ofGemFireCache
.static interface
Callback interface to configure PDX. -
Field Summary
Fields inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
DEFAULT_SINGLETON
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Initializes this cacheFactoryBean
after all properties for this cache bean have been set by the Spring container.protected abstract void
Applies any user-defined cache configurers (e.g.protected void
close
(org.apache.geode.cache.GemFireCache cache) Null-safe method used to close theGemFireCache
by callingRegionService.close()
iff the cache is not already closed.protected org.apache.geode.cache.GemFireCache
configureHeapPercentages
(org.apache.geode.cache.GemFireCache cache) Configures theGemFireCache
critical and eviction heap thresholds as percentages.protected org.apache.geode.cache.GemFireCache
configureOffHeapPercentages
(org.apache.geode.cache.GemFireCache cache) Configures theGemFireCache
critical and eviction off-heap thresholds as percentages.protected <T> T
configurePdx
(AbstractBasicCacheFactoryBean.PdxConfigurer<T> pdxConfigurer) Configures the cache to use PDX serialization.void
destroy()
Destroys the cache bean on Spring container shutdown.protected abstract <T extends org.apache.geode.cache.GemFireCache>
Tprotected abstract org.apache.geode.cache.GemFireCache
protected Class<? extends org.apache.geode.cache.GemFireCache>
By default, returnsGemFireCache
Class
.protected <T extends org.apache.geode.cache.GemFireCache>
TFetches an existing cache instance from the Apache Geode cache factory.<T extends org.apache.geode.cache.GemFireCache>
TgetCache()
Returns a reference to the constructed, configured an initializedGemFireCache
instance created by this cacheFactoryBean
.Return theAbstractBasicCacheFactoryBean.CacheFactoryInitializer
called by thisFactoryBean
to initialize the Apache Geode cache factory used to create the cache constructed by thisFactoryBean
.Returns the configuration of theGemFireCache.getCopyOnRead()
property set on theGemFireCache
.Gets the configuration of theGemFireCache
critical heap percentage property.Gets the configuration of theGemFireCache
critical off-heap percentage property.Gets the configuration of theGemFireCache
eviction heap percentage property.Gets the configuration of theGemFireCache
eviction off-heap percentage property.org.apache.geode.cache.GemFireCache
Returns thecache object reference
created by this cacheFactoryBean
.Class<? extends org.apache.geode.cache.GemFireCache>
<T extends org.apache.geode.cache.GemFireCache>
Optional<T>Returns anOptional
reference to the constructed, configured and initializedGemFireCache
instance created by this cacheFactoryBean
.Gets thename
of the Apache GeodeDiskStore
used to store PDX metadata.Gets the configuration determining whether PDX will ignore unread fields when deserializing PDX bytes back to anObject
.org.apache.geode.pdx.PdxSerializer
Get a reference to the configuredPdxSerializer
used by this cache to de/serializeobjects
stored in the cache and distributed/transferred across the distributed system as PDX bytes.int
getPhase()
Returns the configured lifecycle phase for this cache bean in the Spring container.List<org.apache.geode.cache.TransactionListener>
Returns theList
of configured, application-definedTransactionListeners
registered with the cache (transaction manager) to enable applications to receive transaction events after a transaction is processed (i.e.org.apache.geode.cache.TransactionWriter
Return the configuredTransactionWriter
used to process and handle transaction events.protected Object
initializeFactory
(Object factory) Initializes the givenCacheFactory
orClientCacheFactory
with the configuredAbstractBasicCacheFactoryBean.CacheFactoryInitializer
.boolean
isClose()
Returns a boolean value used to determine whether the cache will be closed on shutdown of the Spring container.boolean
Determines whetherobjects
stored in theGemFireCache
are copied when read (i.e.protected boolean
isNotClosed
(org.apache.geode.cache.GemFireCache cache) Determines if theGemFireCache
has not been closed yet.protected org.apache.geode.cache.GemFireCache
registerTransactionListeners
(org.apache.geode.cache.GemFireCache cache) Registers configured, application-definedTransactionListeners
with the cache (transaction manager) to listen for and receive transaction events when a (cache) transaction is processed (e.g.protected org.apache.geode.cache.GemFireCache
registerTransactionWriter
(org.apache.geode.cache.GemFireCache cache) Registers the configured, application-definedTransactionWriter
with the cache (transaction manager) to receive transaction events with the intent to alter the transaction outcome (e.g.protected void
setCache
(org.apache.geode.cache.GemFireCache cache) Sets a reference to the constructed, configured an initializedGemFireCache
instance created by this cacheFactoryBean
.void
setCacheFactoryInitializer
(AbstractBasicCacheFactoryBean.CacheFactoryInitializer cacheFactoryInitializer) Set theAbstractBasicCacheFactoryBean.CacheFactoryInitializer
called by thisFactoryBean
to initialize the Apache Geode cache factory used to create the cache constructed by thisFactoryBean
.void
setClose
(boolean close) Sets a boolean value used to determine whether the cache should be closed on shutdown of the Spring container.void
setCopyOnRead
(Boolean copyOnRead) Sets theGemFireCache.getCopyOnRead()
property of theGemFireCache
.void
setCriticalHeapPercentage
(Float criticalHeapPercentage) Set theGemFireCache
critical heap percentage property.void
setCriticalOffHeapPercentage
(Float criticalOffHeapPercentage) Set theGemFireCache
critical off-heap percentage property.void
setEvictionHeapPercentage
(Float evictionHeapPercentage) Set theGemFireCache
eviction heap percentage property.void
setEvictionOffHeapPercentage
(Float evictionOffHeapPercentage) Set theGemFireCache
eviction off-heap percentage property.void
setPdxDiskStoreName
(String pdxDiskStoreName) Sets thename
of the Apache GeodeDiskStore
used to store PDX metadata.void
setPdxIgnoreUnreadFields
(Boolean pdxIgnoreUnreadFields) Configures whether PDX will ignore unread fields when deserializing PDX bytes back to anObject
.void
setPdxPersistent
(Boolean pdxPersistent) void
setPdxReadSerialized
(Boolean pdxReadSerialized) void
setPdxSerializer
(org.apache.geode.pdx.PdxSerializer serializer) Configures a reference toPdxSerializer
used by this cache to de/serializeobjects
stored in the cache and distributed/transferred across the distributed system as PDX bytes.protected void
setPhase
(int phase) Set the lifecycle phase for this cache bean in the Spring container.void
setTransactionListeners
(List<org.apache.geode.cache.TransactionListener> transactionListeners) Configures the cache (transaction manager) with aList
ofTransactionListeners
implemented by applications to listen for and receive transaction events after a transaction is processed (i.e.void
setTransactionWriter
(org.apache.geode.cache.TransactionWriter transactionWriter) Configures aTransactionWriter
implemented by the application to receive transaction events and perform a action, like a veto.org.springframework.dao.DataAccessException
translateExceptionIfPossible
(RuntimeException exception) Translates the thrown Apache GeodeRuntimeException
into a correspondingException
from Spring's genericDataAccessException
hierarchy if possible.Methods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLogger, getOptionalLogger, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isSingleton, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLogger, setBeanClassLoader, setBeanFactory, setBeanName
-
Constructor Details
-
AbstractBasicCacheFactoryBean
public AbstractBasicCacheFactoryBean()
-
-
Method Details
-
setCache
protected void setCache(@Nullable org.apache.geode.cache.GemFireCache cache) Sets a reference to the constructed, configured an initializedGemFireCache
instance created by this cacheFactoryBean
.- Parameters:
cache
-GemFireCache
created by this cacheFactoryBean
.- See Also:
-
GemFireCache
-
getCache
@Nullable public <T extends org.apache.geode.cache.GemFireCache> T getCache()Returns a reference to the constructed, configured an initializedGemFireCache
instance created by this cacheFactoryBean
.- Type Parameters:
T
- parameterizedClass
type extendingGemFireCache
.- Returns:
- a reference to the
GemFireCache
created by this cacheFactoryBean
. - See Also:
-
GemFireCache
-
getOptionalCache
Returns anOptional
reference to the constructed, configured and initializedGemFireCache
instance created by this cacheFactoryBean
.- Type Parameters:
T
- parameterizedClass
type extendingGemFireCache
.- Returns:
- an
Optional
reference to theGemFireCache
created by this {cache @link FactoryBean}. - See Also:
-
GemFireCache
Optional
getCache()
-
setCacheFactoryInitializer
public void setCacheFactoryInitializer(@Nullable AbstractBasicCacheFactoryBean.CacheFactoryInitializer cacheFactoryInitializer) Set theAbstractBasicCacheFactoryBean.CacheFactoryInitializer
called by thisFactoryBean
to initialize the Apache Geode cache factory used to create the cache constructed by thisFactoryBean
.- Parameters:
cacheFactoryInitializer
-AbstractBasicCacheFactoryBean.CacheFactoryInitializer
called to initialize the cache factory.- See Also:
-
getCacheFactoryInitializer
Return theAbstractBasicCacheFactoryBean.CacheFactoryInitializer
called by thisFactoryBean
to initialize the Apache Geode cache factory used to create the cache constructed by thisFactoryBean
.- Returns:
- the
AbstractBasicCacheFactoryBean.CacheFactoryInitializer
called to initialize the cache factory. - See Also:
-
setClose
public void setClose(boolean close) Sets a boolean value used to determine whether the cache should be closed on shutdown of the Spring container.- Parameters:
close
- boolean value used to determine whether the cache will be closed on shutdown of the Spring container.
-
isClose
public boolean isClose()Returns a boolean value used to determine whether the cache will be closed on shutdown of the Spring container. Defaults to true.- Returns:
- a boolean value used to determine whether the cache will be closed on shutdown of the Spring container.
-
setCopyOnRead
Sets theGemFireCache.getCopyOnRead()
property of theGemFireCache
. -
getCopyOnRead
Returns the configuration of theGemFireCache.getCopyOnRead()
property set on theGemFireCache
. -
isCopyOnRead
public boolean isCopyOnRead()Determines whetherobjects
stored in theGemFireCache
are copied when read (i.e.Region.get(Object)
. Defaults to false.- Returns:
- a boolean value indicating whether
objects
stored in theGemFireCache
are copied when read (i.e.Region.get(Object)
. - See Also:
-
setCriticalHeapPercentage
Set theGemFireCache
critical heap percentage property.- Parameters:
criticalHeapPercentage
-Float
value specifying the configuration for theGemFireCache
critical heap percentage.
-
getCriticalHeapPercentage
Gets the configuration of theGemFireCache
critical heap percentage property.- Returns:
- a
Float
value specifying the configuration for theGemFireCache
critical heap percentage.
-
setCriticalOffHeapPercentage
Set theGemFireCache
critical off-heap percentage property.- Parameters:
criticalOffHeapPercentage
-Float
value specifying the configuration for theGemFireCache
critical off-heap percentage.
-
getCriticalOffHeapPercentage
Gets the configuration of theGemFireCache
critical off-heap percentage property.- Returns:
- a
Float
value specifying the configuration for theGemFireCache
critical off-heap percentage.
-
setEvictionHeapPercentage
Set theGemFireCache
eviction heap percentage property.- Parameters:
evictionHeapPercentage
-Float
value specifying the configuration for theGemFireCache
eviction heap percentage.
-
getEvictionHeapPercentage
Gets the configuration of theGemFireCache
eviction heap percentage property.- Returns:
- a
Float
value specifying the configuration for theGemFireCache
eviction heap percentage.
-
setEvictionOffHeapPercentage
Set theGemFireCache
eviction off-heap percentage property.- Parameters:
evictionOffHeapPercentage
-Float
value specifying the configuration for theGemFireCache
eviction off-heap percentage.
-
getEvictionOffHeapPercentage
Gets the configuration of theGemFireCache
eviction off-heap percentage property.- Returns:
- a
Float
value specifying the configuration for theGemFireCache
eviction off-heap percentage.
-
getObject
Returns thecache object reference
created by this cacheFactoryBean
.- Specified by:
getObject
in interfaceorg.springframework.beans.factory.FactoryBean<org.apache.geode.cache.GemFireCache>
- Returns:
- the
cache object reference
created by this cacheFactoryBean
. - Throws:
Exception
- See Also:
-
FactoryBean.getObject()
GemFireCache
doGetObject()
getCache()
-
doGetObject
protected abstract org.apache.geode.cache.GemFireCache doGetObject()- Returns:
- a new constructed, configured and initialized
GemFireCache
instance. - See Also:
-
GemFireCache
getObject()
-
getObjectType
- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<org.apache.geode.cache.GemFireCache>
- Returns:
- the
type
ofGemFireCache
created by this cacheFactoryBean
. - See Also:
-
FactoryBean.getObjectType()
doGetObjectType()
-
doGetObjectType
By default, returnsGemFireCache
Class
.- Returns:
GemFireCache
Class
by default.- See Also:
-
GemFireCache
getObjectType()
Class
-
setPdxDiskStoreName
Sets thename
of the Apache GeodeDiskStore
used to store PDX metadata.- Parameters:
pdxDiskStoreName
-name
for the PDXDiskStore
.- See Also:
-
CacheFactory.setPdxDiskStore(String)
DiskStore.getName()
-
getPdxDiskStoreName
Gets thename
of the Apache GeodeDiskStore
used to store PDX metadata.- Returns:
- the
name
of the PDXDiskStore
. - See Also:
-
GemFireCache.getPdxDiskStore()
DiskStore.getName()
-
setPdxIgnoreUnreadFields
Configures whether PDX will ignore unread fields when deserializing PDX bytes back to anObject
. Defaults to false.- Parameters:
pdxIgnoreUnreadFields
-Boolean
value controlling ignoring unread fields.- See Also:
-
CacheFactory.setPdxIgnoreUnreadFields(boolean)
-
getPdxIgnoreUnreadFields
Gets the configuration determining whether PDX will ignore unread fields when deserializing PDX bytes back to anObject
. Defaults to false.- Returns:
- a
Boolean
value controlling ignoring unread fields. - See Also:
-
GemFireCache.getPdxIgnoreUnreadFields()
-
setPdxPersistent
-
getPdxPersistent
-
setPdxReadSerialized
Configures whetherobjects
stored in the Apache Geodecache
as PDX will be read back as PDX bytes or (deserialized) as anObject
whenRegion.get(Object)
is called.- Parameters:
pdxReadSerialized
-Boolean
value controlling the PDX read serialized function.- See Also:
-
CacheFactory.setPdxReadSerialized(boolean)
-
getPdxReadSerialized
Gets the configuration determining whetherobjects
stored in the Apache Geodecache
as PDX will be read back as PDX bytes or (deserialized) as anObject
whenRegion.get(Object)
is called.- Returns:
- a
Boolean
value controlling the PDX read serialized function. - See Also:
-
GemFireCache.getPdxReadSerialized()
-
setPdxSerializer
public void setPdxSerializer(@Nullable org.apache.geode.pdx.PdxSerializer serializer) Configures a reference toPdxSerializer
used by this cache to de/serializeobjects
stored in the cache and distributed/transferred across the distributed system as PDX bytes.- Parameters:
serializer
-PdxSerializer
used by this cache to de/serializeobjects
as PDX.- See Also:
-
CacheFactory.setPdxSerializer(PdxSerializer)
PdxSerializer
-
getPdxSerializer
@Nullable public org.apache.geode.pdx.PdxSerializer getPdxSerializer()Get a reference to the configuredPdxSerializer
used by this cache to de/serializeobjects
stored in the cache and distributed/transferred across the distributed system as PDX bytes.- Returns:
- a reference to the configured
PdxSerializer
. - See Also:
-
GemFireCache.getPdxSerializer()
PdxSerializer
-
setPhase
protected void setPhase(int phase) Set the lifecycle phase for this cache bean in the Spring container.- Parameters:
phase
-Integer.TYPE
value specifying the lifecycle phase for this cache bean in the Spring container.- See Also:
-
Phased.getPhase()
-
getPhase
public int getPhase()Returns the configured lifecycle phase for this cache bean in the Spring container.- Specified by:
getPhase
in interfaceorg.springframework.context.Phased
- Returns:
- an
Integer.TYPE
used specifying the lifecycle phase for this cache bean in the Spring container. - See Also:
-
Phased.getPhase()
-
setTransactionListeners
public void setTransactionListeners(List<org.apache.geode.cache.TransactionListener> transactionListeners) Configures the cache (transaction manager) with aList
ofTransactionListeners
implemented by applications to listen for and receive transaction events after a transaction is processed (i.e. committed or rolled back).- Parameters:
transactionListeners
-List
of application-definedTransactionListeners
registered with the cache to listen for and receive transaction events.- See Also:
-
TransactionListener
-
getTransactionListeners
Returns theList
of configured, application-definedTransactionListeners
registered with the cache (transaction manager) to enable applications to receive transaction events after a transaction is processed (i.e. committed or rolled back).- Returns:
- a
List
of application-definedTransactionListeners
registered with the cache (transaction manager) to listen for and receive transaction events. - See Also:
-
TransactionListener
-
setTransactionWriter
public void setTransactionWriter(@Nullable org.apache.geode.cache.TransactionWriter transactionWriter) Configures aTransactionWriter
implemented by the application to receive transaction events and perform a action, like a veto.- Parameters:
transactionWriter
-TransactionWriter
receiving transaction events.- See Also:
-
TransactionWriter
-
getTransactionWriter
@Nullable public org.apache.geode.cache.TransactionWriter getTransactionWriter()Return the configuredTransactionWriter
used to process and handle transaction events.- Returns:
- the configured
TransactionWriter
. - See Also:
-
TransactionWriter
-
afterPropertiesSet
Initializes this cacheFactoryBean
after all properties for this cache bean have been set by the Spring container.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
- if initialization fails.- See Also:
-
InitializingBean.afterPropertiesSet()
applyCacheConfigurers()
-
applyCacheConfigurers
protected abstract void applyCacheConfigurers()Applies any user-defined cache configurers (e.g.ClientCacheConfigurer
orPeerCacheConfigurer
) to this cacheFactoryBean
before cache construction, configuration and initialization. -
close
protected void close(@Nullable org.apache.geode.cache.GemFireCache cache) Null-safe method used to close theGemFireCache
by callingRegionService.close()
iff the cache is not already closed.- Parameters:
cache
-GemFireCache
to close.- See Also:
-
RegionService.isClosed()
RegionService.close()
isNotClosed(GemFireCache)
-
isNotClosed
protected boolean isNotClosed(@Nullable org.apache.geode.cache.GemFireCache cache) Determines if theGemFireCache
has not been closed yet.- Parameters:
cache
-GemFireCache
to evaluate.- Returns:
- a boolean value indicating if the
GemFireCache
is not yet closed. - See Also:
-
GemFireCache
-
destroy
public void destroy()Destroys the cache bean on Spring container shutdown.- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- See Also:
-
DisposableBean.destroy()
close(GemFireCache)
fetchCache()
isClose()
-
configureHeapPercentages
@NonNull protected org.apache.geode.cache.GemFireCache configureHeapPercentages(@NonNull org.apache.geode.cache.GemFireCache cache) Configures theGemFireCache
critical and eviction heap thresholds as percentages.- Parameters:
cache
-GemFireCache
to configure the critical and eviction heap thresholds; must not be null.- Returns:
- the given
GemFireCache
. - Throws:
IllegalArgumentException
- if the critical or eviction heap thresholds are not valid percentages.- See Also:
-
ResourceManager.setCriticalHeapPercentage(float)
ResourceManager.setEvictionHeapPercentage(float)
ResourceManager
GemFireCache.getResourceManager()
GemFireCache
-
configureOffHeapPercentages
@NonNull protected org.apache.geode.cache.GemFireCache configureOffHeapPercentages(@NonNull org.apache.geode.cache.GemFireCache cache) Configures theGemFireCache
critical and eviction off-heap thresholds as percentages.- Parameters:
cache
-GemFireCache
to configure the critical and eviction off-heap thresholds; must not be null.- Returns:
- the given
GemFireCache
. - Throws:
IllegalArgumentException
- if the critical or eviction off-heap thresholds are not valid percentages.- See Also:
-
ResourceManager.setCriticalOffHeapPercentage(float)
ResourceManager.setEvictionOffHeapPercentage(float)
ResourceManager
GemFireCache.getResourceManager()
GemFireCache
-
configurePdx
Configures the cache to use PDX serialization.- Parameters:
pdxConfigurer
-AbstractBasicCacheFactoryBean.PdxConfigurer
used to configure the cache with PDX serialization.- Returns:
- the
AbstractBasicCacheFactoryBean.PdxConfigurer.getTarget()
.
-
fetchCache
protected <T extends org.apache.geode.cache.GemFireCache> T fetchCache()Fetches an existing cache instance from the Apache Geode cache factory.- Type Parameters:
T
- parameterizedClass
type extendingGemFireCache
.- Returns:
- an existing cache instance if available.
- Throws:
org.apache.geode.cache.CacheClosedException
- if an existing cache instance does not exist.- See Also:
-
ClientCacheFactory.getAnyInstance()
CacheFactory.getAnyInstance()
GemFireCache
doFetchCache()
getCache()
-
doFetchCache
protected abstract <T extends org.apache.geode.cache.GemFireCache> T doFetchCache()Called byfetchCache()
if theGemFireCache
reference returned bygetCache()
is null. This method is typically implemented by callingCacheFactory.getAnyInstance()
orClientCacheFactory.getAnyInstance()
depending on theGemFireCache
type declared and used in the Spring application.- Type Parameters:
T
- parameterizedClass
type extendingGemFireCache
.- Returns:
- a (existing) reference to a
GemFireCache
instance. - Throws:
org.apache.geode.cache.CacheClosedException
- if aGemFireCache
reference does not exist.- See Also:
-
initializeFactory
Initializes the givenCacheFactory
orClientCacheFactory
with the configuredAbstractBasicCacheFactoryBean.CacheFactoryInitializer
.- Parameters:
factory
-CacheFactory
orClientCacheFactory
to initialize.- Returns:
- the initialized
CacheFactory
orClientCacheFactory
. - See Also:
-
AbstractBasicCacheFactoryBean.CacheFactoryInitializer.initialize(Object)
ClientCacheFactory
CacheFactory
getCacheFactoryInitializer()
-
registerTransactionListeners
@NonNull protected org.apache.geode.cache.GemFireCache registerTransactionListeners(@NonNull org.apache.geode.cache.GemFireCache cache) Registers configured, application-definedTransactionListeners
with the cache (transaction manager) to listen for and receive transaction events when a (cache) transaction is processed (e.g. committed or rolled back).- Parameters:
cache
-GemFireCache
used to register the configured, application-definedTransactionListeners
; must not be null.- Returns:
- the given
GemFireCache
. - See Also:
-
GemFireCache.getCacheTransactionManager()
CacheTransactionManager.addListener(TransactionListener)
CacheTransactionManager
TransactionListener
GemFireCache
-
registerTransactionWriter
@NonNull protected org.apache.geode.cache.GemFireCache registerTransactionWriter(@NonNull org.apache.geode.cache.GemFireCache cache) Registers the configured, application-definedTransactionWriter
with the cache (transaction manager) to receive transaction events with the intent to alter the transaction outcome (e.g. veto).- Parameters:
cache
-GemFireCache
used to register the configured, application-definedTransactionWriter
, must not be null.- Returns:
- the given
GemFireCache
. - See Also:
-
GemFireCache.getCacheTransactionManager()
CacheTransactionManager.setWriter(TransactionWriter)
CacheTransactionManager
TransactionWriter
GemFireCache
-
translateExceptionIfPossible
@Nullable public org.springframework.dao.DataAccessException translateExceptionIfPossible(@Nullable RuntimeException exception) Translates the thrown Apache GeodeRuntimeException
into a correspondingException
from Spring's genericDataAccessException
hierarchy if possible.- Specified by:
translateExceptionIfPossible
in interfaceorg.springframework.dao.support.PersistenceExceptionTranslator
- Parameters:
exception
- the Apache GeodeRuntimeException
to translate.- Returns:
- the translated Spring
DataAccessException
or null if the Apache GeodeRuntimeException
could not be translated. - See Also:
-
PersistenceExceptionTranslator.translateExceptionIfPossible(RuntimeException)
DataAccessException
-