public class CacheFactoryBean extends Object implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<com.gemstone.gemfire.cache.Cache>, InitializingBean, DisposableBean, PersistenceExceptionTranslator
This class implements the PersistenceExceptionTranslator
interface, as auto-detected by Spring's
PersistenceExceptionTranslationPostProcessor
, for AOP-based translation
of native Exceptions to Spring DataAccessExceptions. Hence, the presence of this class automatically enables
a PersistenceExceptionTranslationPostProcessor to translate GemFire Exceptions appropriately.
Modifier and Type | Class and Description |
---|---|
static class |
CacheFactoryBean.DynamicRegionSupport |
static class |
CacheFactoryBean.JndiDataSource |
Constructor and Description |
---|
CacheFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected <T extends com.gemstone.gemfire.cache.GemFireCache> |
createCache(Object factory)
Creates a new GemFire cache instance using the provided factory.
|
protected Object |
createFactory(Properties gemfireProperties)
Creates an instance of GemFire factory initialized with the given GemFire System Properties
to create an instance of a GemFire cache.
|
void |
destroy() |
protected <T extends com.gemstone.gemfire.cache.GemFireCache> |
fetchCache()
Fetches an existing GemFire Cache instance from the CacheFactory.
|
ClassLoader |
getBeanClassLoader() |
BeanFactory |
getBeanFactory() |
GemfireBeanFactoryLocator |
getBeanFactoryLocator() |
String |
getBeanName() |
Resource |
getCacheXml() |
Boolean |
getCopyOnRead() |
Float |
getCriticalHeapPercentage() |
CacheFactoryBean.DynamicRegionSupport |
getDynamicRegionSupport() |
Boolean |
getEnableAutoReconnect()
Gets the value for the auto-reconnect setting.
|
Float |
getEvictionHeapPercentage() |
Object |
getGatewayConflictResolver() |
List<CacheFactoryBean.JndiDataSource> |
getJndiDataSources() |
Integer |
getLockLease() |
Integer |
getLockTimeout() |
Integer |
getMessageSyncInterval() |
com.gemstone.gemfire.cache.Cache |
getObject() |
Class<? extends com.gemstone.gemfire.cache.GemFireCache> |
getObjectType() |
String |
getPdxDiskStoreName() |
Boolean |
getPdxIgnoreUnreadFields() |
Boolean |
getPdxPersistent() |
Boolean |
getPdxReadSerialized() |
Object |
getPdxSerializer() |
Properties |
getProperties() |
Integer |
getSearchTimeout() |
List<com.gemstone.gemfire.cache.TransactionListener> |
getTransactionListeners() |
com.gemstone.gemfire.cache.TransactionWriter |
getTransactionWriter() |
Boolean |
getUseClusterConfiguration()
Gets the value fo the use-shared-configuration GemFire setting.
|
boolean |
isLazyInitialize()
Determines whether this Cache instance will be lazily initialized.
|
protected boolean |
isPdxOptionsSpecified()
Determines whether the user specified PDX options.
|
boolean |
isSingleton() |
protected <T extends com.gemstone.gemfire.cache.GemFireCache> |
postProcess(T cache)
Post processes the GemFire Cache instance by loading any cache.xml, applying settings specified in SDG XML
configuration meta-data, and registering the appropriate Transaction Listeners, Writer and JNDI settings.
|
protected void |
postProcessPropertiesBeforeInitialization(Properties gemfireProperties) |
protected Object |
prepareFactory(Object factory)
Initializes the GemFire factory used to create the GemFire cache instance.
|
protected com.gemstone.gemfire.cache.Cache |
resolveCache()
Resolves the GemFire Cache by first attempting to lookup and find an existing Cache instance in the VM;
if an existing Cache could not be found, then this method proceeds in attempting to create a new Cache instance.
|
protected Properties |
resolveProperties()
Resolves the GemFire System properties used to configure the GemFire Cache instance.
|
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setBeanName(String name) |
void |
setCacheXml(Resource cacheXml)
Sets the Cache configuration.
|
void |
setClose(boolean close)
Set whether the Cache should be closed.
|
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(Object gatewayConflictResolver)
Requires GemFire 7.0 or higher
|
void |
setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources) |
void |
setLazyInitialize(boolean lazyInitialize) |
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(Object serializer)
Sets the
PdxSerializable for this cache. |
void |
setProperties(Properties properties)
Sets the cache properties.
|
void |
setSearchTimeout(Integer searchTimeout)
Set the number of seconds a netSearch operation can wait for data before timing out.
|
void |
setTransactionListeners(List<com.gemstone.gemfire.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(com.gemstone.gemfire.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 usage)
Indicates whether a bean factory locator is enabled (default) for this
cache definition or not.
|
void |
setUseClusterConfiguration(Boolean useSharedConfiguration)
Sets the state of the use-shared-configuration GemFire distribution config setting.
|
DataAccessException |
translateExceptionIfPossible(RuntimeException e) |
protected boolean close
protected boolean lazyInitialize
protected boolean useBeanFactoryLocator
protected final org.apache.commons.logging.Log log
protected BeanFactory beanFactory
protected Boolean copyOnRead
protected Boolean enableAutoReconnect
protected Boolean pdxIgnoreUnreadFields
protected Boolean pdxPersistent
protected Boolean pdxReadSerialized
protected Boolean useClusterConfiguration
protected com.gemstone.gemfire.cache.Cache cache
protected ClassLoader beanClassLoader
protected CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport
protected Float criticalHeapPercentage
protected Float evictionHeapPercentage
protected GemfireBeanFactoryLocator beanFactoryLocator
protected Integer lockLease
protected Integer lockTimeout
protected Integer messageSyncInterval
protected Integer searchTimeout
protected List<CacheFactoryBean.JndiDataSource> jndiDataSources
protected List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners
protected Object gatewayConflictResolver
protected Object pdxSerializer
protected Properties properties
protected Resource cacheXml
protected String beanName
protected String pdxDiskStoreName
protected com.gemstone.gemfire.cache.TransactionWriter transactionWriter
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties)
protected com.gemstone.gemfire.cache.Cache resolveCache()
Cache
,
fetchCache()
,
createFactory(java.util.Properties)
,
prepareFactory(Object)
,
createCache(Object)
protected <T extends com.gemstone.gemfire.cache.GemFireCache> T fetchCache()
T
- parameterized Class type extension of GemFireCache.com.gemstone.gemfire.cache.CacheClosedException
- if an existing GemFire Cache instance does not exist.GemFireCache
,
CacheFactory.getAnyInstance()
protected Properties resolveProperties()
getProperties()
protected Object createFactory(Properties gemfireProperties)
gemfireProperties
- a Properties object containing GemFire System properties.Properties
,
CacheFactory
protected Object prepareFactory(Object factory)
factory
- the GemFire factory used to create an instance of the GemFire cache.isPdxOptionsSpecified()
protected boolean isPdxOptionsSpecified()
protected <T extends com.gemstone.gemfire.cache.GemFireCache> T createCache(Object factory)
T
- parameterized Class type extension of GemFireCache.factory
- the appropriate GemFire factory used to create a cache instance.GemFireCache
,
CacheFactory.create()
protected <T extends com.gemstone.gemfire.cache.GemFireCache> T postProcess(T cache) throws IOException
cache
- the GemFire Cache instance to process.IOException
- if the cache.xml Resource could not be loaded and applied to the Cache instance.GemFireCache.loadCacheXml(java.io.InputStream)
,
getCacheXml()
,
setHeapPercentages(com.gemstone.gemfire.cache.GemFireCache)
,
registerTransactionListeners(com.gemstone.gemfire.cache.GemFireCache)
,
registerTransactionWriter(com.gemstone.gemfire.cache.GemFireCache)
,
registerJndiDataSources()
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
public DataAccessException translateExceptionIfPossible(RuntimeException e)
translateExceptionIfPossible
in interface PersistenceExceptionTranslator
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void setBeanName(String name)
setBeanName
in interface BeanNameAware
public void setCacheXml(Resource cacheXml)
cacheXml
- the cache.xml Resource used to initialize the GemFire Cache.Resource
public void setProperties(Properties properties)
properties
- the properties to setpublic void setLazyInitialize(boolean lazyInitialize)
lazyInitialize
- set to false to force cache initialization if no other bean references itpublic void setUseBeanFactoryLocator(boolean usage)
usage
- true if the bean factory locator is used underneath or notpublic void setClose(boolean close)
close
- set to false if destroy() should not close the cachepublic void setCopyOnRead(Boolean copyOnRead)
copyOnRead
- a boolean value indicating whether the object stored in the Cache is copied on gets.public void setCriticalHeapPercentage(Float criticalHeapPercentage)
criticalHeapPercentage
- floating point value indicating the critical heap percentage.public void setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
dynamicRegionSupport
- the DynamicRegionSupport class to setup Dynamic Regions in this Cache.public void setEnableAutoReconnect(Boolean enableAutoReconnect)
enableAutoReconnect
- a boolean value to enable/disable auto-reconnect functionality.public void setEvictionHeapPercentage(Float evictionHeapPercentage)
evictionHeapPercentage
- float-point value indicating the Cache's heap use percentage to trigger eviction.public void setGatewayConflictResolver(Object gatewayConflictResolver)
gatewayConflictResolver
- defined as Object in the signature for backward
compatibility with Gemfire 6 compatibility. This must be an instance of
GatewayConflictResolver
public void setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources)
jndiDataSources
- the list of configured JndiDataSources to use with this Cache.public void setLockLease(Integer lockLease)
lockLease
- an integer value indicating the object lock lease timeout.public void setLockTimeout(Integer lockTimeout)
lockTimeout
- an integer value specifying the object lock request timeout.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 void setPdxSerializer(Object 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 void setPdxReadSerialized(Boolean pdxReadSerialized)
pdxReadSerialized
- a boolean value indicating the PDX instance should be returned from Region.get(key)
when available.public void setPdxPersistent(Boolean pdxPersistent)
pdxPersistent
- a boolean value indicating that PDX type meta-data should be persisted to disk.public void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields)
pdxIgnoreUnreadFields
- the pdxIgnoreUnreadFields to setpublic void setPdxDiskStoreName(String pdxDiskStoreName)
pdxDiskStoreName
- the pdxDiskStoreName to setpublic void setSearchTimeout(Integer searchTimeout)
searchTimeout
- an integer value indicating the netSearch timeout value.public void setTransactionListeners(List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners)
transactionListeners
- the list of GemFire TransactionListeners listening for transaction events.TransactionListener
public void setTransactionWriter(com.gemstone.gemfire.cache.TransactionWriter transactionWriter)
transactionWriter
- the GemFire TransactionWriter callback receiving transaction events.TransactionWriter
public void setUseClusterConfiguration(Boolean useSharedConfiguration)
useSharedConfiguration
- a boolean value to set the use-shared-configuration GemFire distribution property.public ClassLoader getBeanClassLoader()
public BeanFactory getBeanFactory()
public GemfireBeanFactoryLocator getBeanFactoryLocator()
public String getBeanName()
public Resource getCacheXml()
public Properties getProperties()
public com.gemstone.gemfire.cache.Cache getObject() throws Exception
getObject
in interface FactoryBean<com.gemstone.gemfire.cache.Cache>
Exception
public Class<? extends com.gemstone.gemfire.cache.GemFireCache> getObjectType()
getObjectType
in interface FactoryBean<com.gemstone.gemfire.cache.Cache>
public boolean isSingleton()
isSingleton
in interface FactoryBean<com.gemstone.gemfire.cache.Cache>
public Boolean getCopyOnRead()
public Float getCriticalHeapPercentage()
public CacheFactoryBean.DynamicRegionSupport getDynamicRegionSupport()
public Boolean getEnableAutoReconnect()
public Float getEvictionHeapPercentage()
public Object getGatewayConflictResolver()
public List<CacheFactoryBean.JndiDataSource> getJndiDataSources()
public Object getPdxSerializer()
public Boolean getPdxReadSerialized()
public Boolean getPdxPersistent()
public Boolean getPdxIgnoreUnreadFields()
public String getPdxDiskStoreName()
public Integer getLockLease()
public Integer getLockTimeout()
public Integer getMessageSyncInterval()
public Integer getSearchTimeout()
public List<com.gemstone.gemfire.cache.TransactionListener> getTransactionListeners()
public com.gemstone.gemfire.cache.TransactionWriter getTransactionWriter()
public Boolean getUseClusterConfiguration()
public boolean isLazyInitialize()