public class CacheFactoryBean extends Object implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<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 void |
applyPdxOptions(Object factory)
Sets the PDX properties for the given object.
|
protected GemFireCache |
createCache(Object factory) |
protected Object |
createFactory(Properties gemfireProperties) |
void |
destroy() |
protected GemFireCache |
fetchCache() |
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() |
Cache |
getObject() |
Class<? extends Cache> |
getObjectType() |
String |
getPdxDiskStoreName() |
Boolean |
getPdxIgnoreUnreadFields() |
Boolean |
getPdxPersistent() |
Boolean |
getPdxReadSerialized() |
Object |
getPdxSerializer() |
Properties |
getProperties() |
Integer |
getSearchTimeout() |
List<TransactionListener> |
getTransactionListeners() |
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.
|
boolean |
isSingleton() |
protected void |
postProcessPropertiesBeforeInitialization(Properties gemfireProperties) |
protected void |
registerTransactionListeners()
Register all declared transaction listeners
|
protected void |
registerTransactionWriter()
Register a transaction writer if declared
|
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<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(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 static final List<String> VALID_JNDI_DATASOURCE_TYPE_NAMES
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 Cache cache
protected ClassLoader beanClassLoader
protected CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport
protected Float criticalHeapPercentage
protected Float evictionHeapPercentage
protected GemfireBeanFactoryLocator factoryLocator
protected Integer lockLease
protected Integer lockTimeout
protected Integer messageSyncInterval
protected Integer searchTimeout
protected List<CacheFactoryBean.JndiDataSource> jndiDataSources
protected List<TransactionListener> transactionListeners
protected Object gatewayConflictResolver
protected Object pdxSerializer
protected Properties properties
protected Resource cacheXml
protected String beanName
protected String pdxDiskStoreName
protected TransactionWriter transactionWriter
protected void applyPdxOptions(Object factory)
factory
- the GemFire CacheFactory used to apply the PDX configuration settings.protected void registerTransactionListeners()
protected void registerTransactionWriter()
protected GemFireCache createCache(Object factory)
protected Object createFactory(Properties gemfireProperties)
protected GemFireCache fetchCache()
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 cacheXml to setpublic 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 setEnableAutoReconnect(Boolean enableAutoReconnect)
enableAutoReconnect
- a boolean value to enable/disable auto-reconnect functionality.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 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 setEvictionHeapPercentage(Float evictionHeapPercentage)
evictionHeapPercentage
- float-point value indicating the Cache's heap use percentage to trigger eviction.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 setSearchTimeout(Integer searchTimeout)
searchTimeout
- an integer value indicating the netSearch timeout value.public void setTransactionListeners(List<TransactionListener> transactionListeners)
transactionListeners
- the list of GemFire TransactionListeners listening for transaction events.TransactionListener
public void setTransactionWriter(TransactionWriter transactionWriter)
transactionWriter
- the GemFire TransactionWriter callback receiving transaction events.TransactionWriter
public void setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
dynamicRegionSupport
- the DynamicRegionSupport class to setup Dynamic Regions in this Cache.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 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 Cache getObject() throws Exception
getObject
in interface FactoryBean<Cache>
Exception
public Class<? extends Cache> getObjectType()
getObjectType
in interface FactoryBean<Cache>
public boolean isSingleton()
isSingleton
in interface FactoryBean<Cache>
public Boolean getCopyOnRead()
public Float getCriticalHeapPercentage()
public Boolean getEnableAutoReconnect()
public Float getEvictionHeapPercentage()
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<TransactionListener> getTransactionListeners()
public TransactionWriter getTransactionWriter()
public CacheFactoryBean.DynamicRegionSupport getDynamicRegionSupport()
public Object getGatewayConflictResolver()
public List<CacheFactoryBean.JndiDataSource> getJndiDataSources()
public Boolean getUseClusterConfiguration()
public boolean isLazyInitialize()
protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception