public class CacheFactoryBean extends AbstractFactoryBeanSupport<org.apache.geode.cache.Cache> implements DisposableBean, InitializingBean, PersistenceExceptionTranslator, Phased
FactoryBean
used to construct, configure and initialize a Pivotal GemFire/Apache Geode
Cache peer cache).
Allows either retrieval of an existing, opened {@link Cache} or creation of a new {@link Cache}.
This class implements the {@link PersistenceExceptionTranslator} interface and is auto-detected by Spring's
{@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor} for AOP-based translation
of native persistent store exceptions to Spring's {@link DataAccessException} hierarchy. Therefore, the presence
of this class automatically enables a {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}
to translate Pivotal GemFire/Apache Geode exceptions appropriately.Properties
,
Cache
,
CacheFactory
,
GemFireCache
,
DynamicRegionFactory
,
RegionService
,
DistributedMember
,
DistributedSystem
,
org.apache.geode.cache.pdx.PdxSerializer
,
BeanFactory
,
DisposableBean
,
FactoryBean
,
InitializingBean
,
Phased
,
Resource
,
PersistenceExceptionTranslator
,
PeerCacheConfigurer
,
AbstractFactoryBeanSupport
,
GemfireBeanFactoryLocator
Modifier and Type | Class and Description |
---|---|
static class |
CacheFactoryBean.DynamicRegionSupport |
static class |
CacheFactoryBean.JndiDataSource |
Modifier and Type | Field and Description |
---|---|
protected GemfireBeanFactoryLocator |
beanFactoryLocator |
DEFAULT_SINGLETON
Constructor and Description |
---|
CacheFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Initializes this
CacheFactoryBean after properties have been set by the Spring container. |
protected void |
applyPeerCacheConfigurers(Iterable<PeerCacheConfigurer> peerCacheConfigurers)
|
protected void |
applyPeerCacheConfigurers(PeerCacheConfigurer... peerCacheConfigurers)
Null-safe operation to apply the given array of
PeerCacheConfigurers
to this CacheFactoryBean . |
protected void |
close(org.apache.geode.cache.GemFireCache cache)
Null-safe internal method used to close the
GemFireCache and calling RegionService.close()
iff the cache is not already closed . |
protected <T extends org.apache.geode.cache.GemFireCache> |
createCache(Object factory)
Creates a new
Cache instance using the provided factory. |
protected Object |
createFactory(Properties gemfireProperties)
Constructs a new instance of
CacheFactory initialized with the given Pivotal GemFire/Apache Geode
Properties used to create an instance of a Cache . |
void |
destroy()
Destroys the
Cache bean on Spring container shutdown. |
protected <T extends org.apache.geode.cache.GemFireCache> |
fetchCache()
Fetches an existing
Cache instance from the CacheFactory . |
GemfireBeanFactoryLocator |
getBeanFactoryLocator()
Returns a reference to the configured
GemfireBeanFactoryLocator used to resolve Spring bean references
in native Pivotal GemFire/Apache Geode native config (e.g. |
protected <T extends org.apache.geode.cache.GemFireCache> |
getCache()
Returns a direct reference to the constructed, configured an initialized
Cache
created by this CacheFactoryBean . |
Resource |
getCacheXml()
Returns a reference to the Pivotal GemFire/Apache Geode native cache.xml
as a Spring
Resource . |
PeerCacheConfigurer |
getCompositePeerCacheConfigurer()
Returns a reference to the Composite
PeerCacheConfigurer used to apply additional configuration
to this CacheFactoryBean on Spring container initialization. |
Boolean |
getCopyOnRead() |
Float |
getCriticalHeapPercentage() |
CacheFactoryBean.DynamicRegionSupport |
getDynamicRegionSupport() |
Boolean |
getEnableAutoReconnect()
Gets the value for the auto-reconnect setting.
|
Float |
getEvictionHeapPercentage() |
org.apache.geode.cache.util.GatewayConflictResolver |
getGatewayConflictResolver() |
List<CacheFactoryBean.JndiDataSource> |
getJndiDataSources() |
Integer |
getLockLease() |
Integer |
getLockTimeout() |
Integer |
getMessageSyncInterval() |
org.apache.geode.cache.Cache |
getObject()
Returns an object reference to the
Cache created by this CacheFactoryBean . |
Class<? extends org.apache.geode.cache.GemFireCache> |
getObjectType()
|
String |
getPdxDiskStoreName() |
Boolean |
getPdxIgnoreUnreadFields() |
Boolean |
getPdxPersistent() |
Boolean |
getPdxReadSerialized() |
org.apache.geode.pdx.PdxSerializer |
getPdxSerializer() |
int |
getPhase()
Returns the configured phase of the
Cache bean in the lifecycle managed by the Spring container. |
Properties |
getProperties()
Returns a reference to Pivotal GemFire/Apache Geode
Properties used to configure the cache. |
Integer |
getSearchTimeout() |
List<org.apache.geode.cache.TransactionListener> |
getTransactionListeners() |
org.apache.geode.cache.TransactionWriter |
getTransactionWriter() |
Boolean |
getUseClusterConfiguration()
Return the state of the use-shared-configuration Pivotal GemFire/Apache Geode
distribution configuration setting.
|
boolean |
isClose()
Returns a boolean value indicating whether the cache will be closed on shutdown of the Spring container.
|
boolean |
isUseBeanFactoryLocator()
Determines whether the
GemfireBeanFactoryLocator has been enabled. |
protected <T extends org.apache.geode.cache.GemFireCache> |
postProcess(T cache)
Post processes the
GemFireCache by loading any cache.xml, applying custom settings
specified in SDG XML configuration meta-data, and registering appropriate Transaction Listeners, Writer
and JNDI settings. |
protected void |
postProcessBeforeCacheInitialization(Properties gemfireProperties)
Post processes this
CacheFactoryBean before cache initialization. |
protected Object |
prepareFactory(Object factory)
Prepares and initializes the
CacheFactory used to create the Cache . |
protected org.apache.geode.cache.Cache |
resolveCache()
Resolves the
Cache by first attempting to lookup an existing Cache instance in the JVM. |
protected Properties |
resolveProperties()
Resolves the Pivotal GemFire/Apache Geode
Properties used to configure the Cache . |
protected Properties |
setAndGetProperties(Properties properties)
Sets and then returns a reference to Pivotal GemFire/Apache Geode
Properties used to configure the cache. |
protected void |
setCache(org.apache.geode.cache.Cache cache)
Sets a reference to the constructed, configured an initialized
Cache
created by this CacheFactoryBean . |
void |
setCacheXml(Resource cacheXml)
Sets a reference to the Pivotal GemFire/Apache Geode native cache.xml
Resource . |
void |
setClose(boolean close)
Sets a value to indicate whether the cache will be closed on shutdown of the Spring container.
|
void |
setCopyOnRead(Boolean copyOnRead)
Set the copyOnRead attribute of the Cache.
|
void |
setCriticalHeapPercentage(Float criticalHeapPercentage)
Set the Cache's critical heap percentage attribute.
|
void |
setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
Sets an instance of the DynamicRegionSupport to support Dynamic Regions in this GemFire Cache.
|
void |
setEnableAutoReconnect(Boolean enableAutoReconnect)
Controls whether auto-reconnect functionality introduced in GemFire 8 is enabled or not.
|
void |
setEvictionHeapPercentage(Float evictionHeapPercentage)
Set the Cache's eviction heap percentage attribute.
|
void |
setGatewayConflictResolver(org.apache.geode.cache.util.GatewayConflictResolver gatewayConflictResolver)
Requires GemFire 7.0 or higher
|
void |
setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources) |
void |
setLockLease(Integer lockLease)
Sets the number of seconds for implicit and explicit object lock leases to timeout.
|
void |
setLockTimeout(Integer lockTimeout)
Sets the number of seconds in which the implicit object lock request will timeout.
|
void |
setMessageSyncInterval(Integer messageSyncInterval)
Set for client subscription queue synchronization when this member acts as a server to clients
and server redundancy is used.
|
void |
setPdxDiskStoreName(String pdxDiskStoreName)
Set the disk store that is used for PDX meta data.
|
void |
setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields)
Controls whether pdx ignores fields that were unread during
deserialization.
|
void |
setPdxPersistent(Boolean pdxPersistent)
Controls whether type metadata for PDX objects is persisted to disk.
|
void |
setPdxReadSerialized(Boolean pdxReadSerialized)
Sets the object preference to PdxInstance.
|
void |
setPdxSerializer(org.apache.geode.pdx.PdxSerializer serializer)
Sets the
PdxSerializable for this cache. |
void |
setPeerCacheConfigurers(List<PeerCacheConfigurer> peerCacheConfigurers)
Null-safe operation to set an
Iterable of PeerCacheConfigurers to apply
additional configuration to this CacheFactoryBean when using Annotation-based configuration. |
void |
setPeerCacheConfigurers(PeerCacheConfigurer... peerCacheConfigurers)
Null-safe operation to set an array of
PeerCacheConfigurers used to apply
additional configuration to this CacheFactoryBean when using Annotation-based configuration. |
protected void |
setPhase(int phase)
Set the phase for the
Cache bean in the lifecycle managed by the Spring container. |
void |
setProperties(Properties properties)
Returns a reference to Pivotal GemFire/Apache Geode
Properties used to configure the cache. |
void |
setSearchTimeout(Integer searchTimeout)
Set the number of seconds a netSearch operation can wait for data before timing out.
|
void |
setTransactionListeners(List<org.apache.geode.cache.TransactionListener> transactionListeners)
Sets the list of TransactionListeners used to configure the Cache to receive transaction events after
the transaction is processed (committed, rolled back).
|
void |
setTransactionWriter(org.apache.geode.cache.TransactionWriter transactionWriter)
Sets the TransactionWriter used to configure the Cache for handling transaction events, such as to veto
the transaction or update an external DB before the commit.
|
void |
setUseBeanFactoryLocator(boolean use)
Sets whether to enable the
GemfireBeanFactoryLocator . |
void |
setUseClusterConfiguration(Boolean useSharedConfiguration)
Sets the state of the use-shared-configuration Pivotal GemFire/Apache Geode
distribution configuration setting.
|
DataAccessException |
translateExceptionIfPossible(RuntimeException exception)
Translates the given Pivotal GemFire/Apache Geode
RuntimeException thrown to a corresponding exception
from Spring's generic DataAccessException hierarchy, if possible. |
getBeanClassLoader, getBeanFactory, getBeanName, getLog, isSingleton, logDebug, logDebug, logInfo, logInfo, newLog, setBeanClassLoader, setBeanFactory, setBeanName
protected GemfireBeanFactoryLocator beanFactoryLocator
public void afterPropertiesSet() throws Exception
CacheFactoryBean
after properties have been set by the Spring container.afterPropertiesSet
in interface InitializingBean
Exception
- if initialization fails.InitializingBean.afterPropertiesSet()
,
initBeanFactoryLocator()
,
postProcessBeforeCacheInitialization(Properties)
protected void postProcessBeforeCacheInitialization(Properties gemfireProperties)
CacheFactoryBean
before cache initialization.
This is also the point at which any configured PeerCacheConfigurer
beans are called.gemfireProperties
- Properties
used to configure Pivotal GemFire/Apache Geode.PeerCacheConfigurer
,
Properties
protected void applyPeerCacheConfigurers(PeerCacheConfigurer... peerCacheConfigurers)
PeerCacheConfigurers
to this CacheFactoryBean
.peerCacheConfigurers
- array of PeerCacheConfigurers
applied to
this CacheFactoryBean
.PeerCacheConfigurer
,
applyPeerCacheConfigurers(Iterable)
protected void applyPeerCacheConfigurers(Iterable<PeerCacheConfigurer> peerCacheConfigurers)
peerCacheConfigurers
- Iterable
of PeerCacheConfigurers
applied to this CacheFactoryBean
.PeerCacheConfigurer
,
Iterable
protected org.apache.geode.cache.Cache resolveCache()
Cache
by first attempting to lookup an existing Cache
instance in the JVM.
If an existing Cache
could not be found, then this method proceeds in attempting to create
a new Cache
instance.Cache
instance.Cache
,
fetchCache()
,
resolveProperties()
,
createFactory(java.util.Properties)
,
prepareFactory(Object)
,
createCache(Object)
protected <T extends org.apache.geode.cache.GemFireCache> T fetchCache()
Cache
instance from the CacheFactory
.T
- parameterized Class
type extension of GemFireCache
.Cache
instance if available.org.apache.geode.cache.CacheClosedException
- if an existing Cache
instance does not exist.CacheFactory.getAnyInstance()
,
GemFireCache
,
getCache()
protected Properties resolveProperties()
Properties
used to configure the Cache
.Properties
used to configure the Cache
.setAndGetProperties(Properties)
,
getProperties()
protected Object createFactory(Properties gemfireProperties)
CacheFactory
initialized with the given Pivotal GemFire/Apache Geode
Properties
used to create an instance of a Cache
.gemfireProperties
- Properties
used by the CacheFactory
to configure the Cache
.CacheFactory
initialized with the given Pivotal GemFire/Apache Geode
Properties
.CacheFactory
,
Properties
protected Object prepareFactory(Object factory)
CacheFactory
used to create the Cache
.
Sets PDX options specified by the user.factory
- CacheFactory
used to create the Cache
.CacheFactory
.initializePdx(CacheFactory)
protected <T extends org.apache.geode.cache.GemFireCache> T createCache(Object factory)
Cache
instance using the provided factory.T
- parameterized Class
type extension of GemFireCache
.factory
- instance of CacheFactory
.Cache
created by the provided factory.CacheFactory.create()
,
GemFireCache
protected <T extends org.apache.geode.cache.GemFireCache> T postProcess(T cache)
GemFireCache
by loading any cache.xml, applying custom settings
specified in SDG XML configuration meta-data, and registering appropriate Transaction Listeners, Writer
and JNDI settings.T
- Parameterized Class
type extension of GemFireCache
.cache
- GemFireCache
instance to post process.GemFireCache
.GemFireCache.loadCacheXml(java.io.InputStream)
,
getCacheXml()
,
configureHeapPercentages(org.apache.geode.cache.GemFireCache)
,
registerJndiDataSources()
,
registerTransactionListeners(org.apache.geode.cache.GemFireCache)
,
registerTransactionWriter(org.apache.geode.cache.GemFireCache)
public void destroy() throws Exception
Cache
bean on Spring container shutdown.destroy
in interface DisposableBean
Exception
- if an error occurs while closing the cache.DisposableBean.destroy()
,
destroyBeanFactoryLocator()
,
close(GemFireCache)
,
isClose()
protected void close(org.apache.geode.cache.GemFireCache cache)
GemFireCache
and calling RegionService.close()
iff the cache is not already closed
.cache
- GemFireCache
to close.RegionService.isClosed()
,
RegionService.close()
public DataAccessException translateExceptionIfPossible(RuntimeException exception)
RuntimeException
thrown to a corresponding exception
from Spring's generic DataAccessException
hierarchy, if possible.translateExceptionIfPossible
in interface PersistenceExceptionTranslator
exception
- RuntimeException
to translate.DataAccessException
or null if the Pivotal GemFire/Apache Geode
RuntimeException
could not be converted.PersistenceExceptionTranslator.translateExceptionIfPossible(RuntimeException)
,
DataAccessException
public GemfireBeanFactoryLocator getBeanFactoryLocator()
GemfireBeanFactoryLocator
used to resolve Spring bean references
in native Pivotal GemFire/Apache Geode native config (e.g. cache.xml).GemfireBeanFactoryLocator
.GemfireBeanFactoryLocator
protected void setCache(org.apache.geode.cache.Cache cache)
Cache
created by this CacheFactoryBean
.cache
- Cache
created by this CacheFactoryBean
.Cache
protected <T extends org.apache.geode.cache.GemFireCache> T getCache()
Cache
created by this CacheFactoryBean
.Cache
created by this CacheFactoryBean
.Cache
public void setCacheXml(Resource cacheXml)
Resource
.public Resource getCacheXml()
Resource
.public org.apache.geode.cache.Cache getObject() throws Exception
Cache
created by this CacheFactoryBean
.getObject
in interface FactoryBean<org.apache.geode.cache.Cache>
Cache
created by this CacheFactoryBean
.Exception
FactoryBean.getObject()
,
Cache
,
getCache()
public Class<? extends org.apache.geode.cache.GemFireCache> getObjectType()
getObjectType
in interface FactoryBean<org.apache.geode.cache.Cache>
Class
type of the GemFireCache
produced by this CacheFactoryBean
.FactoryBean.getObjectType()
protected void setPhase(int phase)
Cache
bean in the lifecycle managed by the Spring container.phase
- int
value indicating the phase of this Cache
bean
in the lifecycle managed by the Spring container.Phased.getPhase()
public int getPhase()
Cache
bean in the lifecycle managed by the Spring container.getPhase
in interface Phased
int
value indicating the phase of this Cache
bean in the lifecycle
managed by the Spring container.Phased.getPhase()
protected Properties setAndGetProperties(Properties properties)
Properties
used to configure the cache.properties
- reference to Pivotal GemFire/Apache Geode Properties
used to configure the cache.Properties
used to configure the cache.Properties
,
setProperties(Properties)
,
getProperties()
public void setProperties(Properties properties)
Properties
used to configure the cache.properties
- reference to Pivotal GemFire/Apache Geode Properties
used to configure the cache.Properties
public Properties getProperties()
Properties
used to configure the cache.Properties
.Properties
public void setClose(boolean close)
close
- boolean value indicating whether the cache will be closed on shutdown of the Spring container.public boolean isClose()
public PeerCacheConfigurer getCompositePeerCacheConfigurer()
PeerCacheConfigurer
used to apply additional configuration
to this CacheFactoryBean
on Spring container initialization.PeerCacheConfigurer
.PeerCacheConfigurer
public void setCopyOnRead(Boolean copyOnRead)
copyOnRead
- a boolean value indicating whether the object stored in the Cache is copied on gets.public Boolean getCopyOnRead()
public void setCriticalHeapPercentage(Float criticalHeapPercentage)
criticalHeapPercentage
- floating point value indicating the critical heap percentage.public Float getCriticalHeapPercentage()
public void setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
dynamicRegionSupport
- the DynamicRegionSupport class to setup Dynamic Regions in this Cache.public CacheFactoryBean.DynamicRegionSupport getDynamicRegionSupport()
public void setEnableAutoReconnect(Boolean enableAutoReconnect)
enableAutoReconnect
- a boolean value to enable/disable auto-reconnect functionality.public Boolean getEnableAutoReconnect()
public void setEvictionHeapPercentage(Float evictionHeapPercentage)
evictionHeapPercentage
- float-point value indicating the Cache's heap use percentage to trigger eviction.public Float getEvictionHeapPercentage()
public void setGatewayConflictResolver(org.apache.geode.cache.util.GatewayConflictResolver gatewayConflictResolver)
gatewayConflictResolver
- defined as Object in the signature for backward
compatibility with Gemfire 6 compatibility. This must be an instance of
GatewayConflictResolver
public org.apache.geode.cache.util.GatewayConflictResolver getGatewayConflictResolver()
public void setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources)
jndiDataSources
- the list of configured JndiDataSources to use with this Cache.public List<CacheFactoryBean.JndiDataSource> getJndiDataSources()
public void setLockLease(Integer lockLease)
lockLease
- an integer value indicating the object lock lease timeout.public Integer getLockLease()
public void setLockTimeout(Integer lockTimeout)
lockTimeout
- an integer value specifying the object lock request timeout.public Integer getLockTimeout()
public void setMessageSyncInterval(Integer messageSyncInterval)
messageSyncInterval
- an integer value specifying the number of seconds in which the primary server
sends messages to secondary servers.public Integer getMessageSyncInterval()
public void setPdxDiskStoreName(String pdxDiskStoreName)
pdxDiskStoreName
- the pdxDiskStoreName to setpublic String getPdxDiskStoreName()
public void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields)
pdxIgnoreUnreadFields
- the pdxIgnoreUnreadFields to setpublic Boolean getPdxIgnoreUnreadFields()
public void setPdxPersistent(Boolean pdxPersistent)
pdxPersistent
- a boolean value indicating that PDX type meta-data should be persisted to disk.public Boolean getPdxPersistent()
public void setPdxReadSerialized(Boolean pdxReadSerialized)
pdxReadSerialized
- a boolean value indicating the PDX instance should be returned from Region.get(key)
when available.public Boolean getPdxReadSerialized()
public void setPdxSerializer(org.apache.geode.pdx.PdxSerializer serializer)
PdxSerializable
for this cache. Applicable on GemFire
6.6 or higher. The argument is of type object for compatibility with
GemFire 6.5.serializer
- pdx serializer configured for this cache.public org.apache.geode.pdx.PdxSerializer getPdxSerializer()
public void setPeerCacheConfigurers(PeerCacheConfigurer... peerCacheConfigurers)
PeerCacheConfigurers
used to apply
additional configuration to this CacheFactoryBean
when using Annotation-based configuration.peerCacheConfigurers
- array of PeerCacheConfigurers
used to apply
additional configuration to this CacheFactoryBean
.PeerCacheConfigurer
,
setPeerCacheConfigurers(List)
public void setPeerCacheConfigurers(List<PeerCacheConfigurer> peerCacheConfigurers)
Iterable
of PeerCacheConfigurers
to apply
additional configuration to this CacheFactoryBean
when using Annotation-based configuration.peerCacheConfigurers
- Iterable
of PeerCacheConfigurers
used to apply
additional configuration to this CacheFactoryBean
.PeerCacheConfigurer
public void setSearchTimeout(Integer searchTimeout)
searchTimeout
- an integer value indicating the netSearch timeout value.public Integer getSearchTimeout()
public void setTransactionListeners(List<org.apache.geode.cache.TransactionListener> transactionListeners)
transactionListeners
- the list of GemFire TransactionListeners listening for transaction events.TransactionListener
public List<org.apache.geode.cache.TransactionListener> getTransactionListeners()
public void setTransactionWriter(org.apache.geode.cache.TransactionWriter transactionWriter)
transactionWriter
- the GemFire TransactionWriter callback receiving transaction events.TransactionWriter
public org.apache.geode.cache.TransactionWriter getTransactionWriter()
public void setUseBeanFactoryLocator(boolean use)
GemfireBeanFactoryLocator
.use
- boolean value indicating whether to enable the GemfireBeanFactoryLocator
.GemfireBeanFactoryLocator
public boolean isUseBeanFactoryLocator()
GemfireBeanFactoryLocator
has been enabled.GemfireBeanFactoryLocator
has been enabled.GemfireBeanFactoryLocator
public void setUseClusterConfiguration(Boolean useSharedConfiguration)
useSharedConfiguration
- boolean value to set the use-shared-configuration
Pivotal GemFire/Apache Geode distribution configuration setting.public Boolean getUseClusterConfiguration()
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.