org.springframework.data.gemfire
Class CacheFactoryBean

java.lang.Object
  extended by org.springframework.data.gemfire.CacheFactoryBean
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, DisposableBean, FactoryBean<com.gemstone.gemfire.cache.GemFireCache>, InitializingBean, PersistenceExceptionTranslator
Direct Known Subclasses:
ClientCacheFactoryBean

public class CacheFactoryBean
extends Object
implements BeanNameAware, BeanFactoryAware, BeanClassLoaderAware, DisposableBean, InitializingBean, FactoryBean<com.gemstone.gemfire.cache.GemFireCache>, PersistenceExceptionTranslator

Factory used for configuring a Gemfire Cache manager. Allows either retrieval of an existing, opened cache or the creation of a new one.

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.


Nested Class Summary
static class CacheFactoryBean.DynamicRegionSupport
           
static class CacheFactoryBean.JndiDataSource
           
 
Field Summary
protected  ClassLoader beanClassLoader
           
protected  BeanFactory beanFactory
           
protected  String beanName
           
protected  com.gemstone.gemfire.cache.GemFireCache cache
           
protected  Resource cacheXml
           
protected  Boolean copyOnRead
           
protected  Float criticalHeapPercentage
           
protected  CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport
           
protected  Float evictionHeapPercentage
           
protected  GemfireBeanFactoryLocator factoryLocator
           
protected  List<CacheFactoryBean.JndiDataSource> jndiDataSources
           
protected  Integer lockLease
           
protected  Integer lockTimeout
           
protected  org.apache.commons.logging.Log log
           
protected  Integer messageSyncInterval
           
protected  String pdxDiskStoreName
           
protected  Boolean pdxIgnoreUnreadFields
           
protected  Boolean pdxPersistent
           
protected  Boolean pdxReadSerialized
           
protected  Object pdxSerializer
           
protected  Properties properties
           
protected  Integer searchTimeout
           
protected  List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners
           
protected  com.gemstone.gemfire.cache.TransactionWriter transactionWriter
           
protected  boolean useBeanFactoryLocator
           
 
Constructor Summary
CacheFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void applyInternalCacheOptions()
           
protected  void applyPdxOptions(Object factory)
          Sets the PDX properties for the given object.
protected  com.gemstone.gemfire.cache.GemFireCache createCache(Object factory)
           
protected  Object createFactory(Properties props)
           
 void destroy()
           
protected  com.gemstone.gemfire.cache.GemFireCache fetchCache()
           
protected  BeanFactory getBeanFactory()
           
 com.gemstone.gemfire.cache.GemFireCache getObject()
           
 Class<? extends com.gemstone.gemfire.cache.GemFireCache> getObjectType()
           
 boolean isSingleton()
           
protected  Properties mergeProperties()
           
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 setCopyOnRead(boolean copyOnRead)
           
 void setCriticalHeapPercentage(Float criticalHeapPercentage)
           
 void setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
           
 void setEvictionHeapPercentage(Float evictionHeapPercentage)
           
 void setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources)
           
 void setLockLease(int lockLease)
           
 void setLockTimeout(int lockTimeout)
           
 void setMessageSyncInterval(int messageSyncInterval)
           
 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)
          Sets the object preference to PdxInstance type.
 void setPdxReadSerialized(Boolean pdxReadSerialized)
          Controls whether the type metadata for PDX objects is persisted to disk.
 void setPdxSerializer(Object serializer)
          Sets the PdxSerializable for this cache.
 void setProperties(Properties properties)
          Sets the cache properties.
 void setSearchTimeout(int searchTimeout)
           
 void setTransactionListeners(List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners)
           
 void setTransactionWriter(com.gemstone.gemfire.cache.TransactionWriter transactionWriter)
           
 void setUseBeanFactoryLocator(boolean usage)
          Indicates whether a bean factory locator is enabled (default) for this cache definition or not.
 DataAccessException translateExceptionIfPossible(RuntimeException ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

cache

protected com.gemstone.gemfire.cache.GemFireCache cache

cacheXml

protected Resource cacheXml

properties

protected Properties properties

beanClassLoader

protected ClassLoader beanClassLoader

factoryLocator

protected GemfireBeanFactoryLocator factoryLocator

beanFactory

protected BeanFactory beanFactory

beanName

protected String beanName

useBeanFactoryLocator

protected boolean useBeanFactoryLocator

pdxSerializer

protected Object pdxSerializer

pdxPersistent

protected Boolean pdxPersistent

pdxReadSerialized

protected Boolean pdxReadSerialized

pdxIgnoreUnreadFields

protected Boolean pdxIgnoreUnreadFields

pdxDiskStoreName

protected String pdxDiskStoreName

copyOnRead

protected Boolean copyOnRead

lockTimeout

protected Integer lockTimeout

lockLease

protected Integer lockLease

messageSyncInterval

protected Integer messageSyncInterval

searchTimeout

protected Integer searchTimeout

transactionListeners

protected List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners

transactionWriter

protected com.gemstone.gemfire.cache.TransactionWriter transactionWriter

evictionHeapPercentage

protected Float evictionHeapPercentage

criticalHeapPercentage

protected Float criticalHeapPercentage

dynamicRegionSupport

protected CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport

jndiDataSources

protected List<CacheFactoryBean.JndiDataSource> jndiDataSources
Constructor Detail

CacheFactoryBean

public CacheFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

registerTransactionWriter

protected void registerTransactionWriter()
Register a transaction writer if declared


registerTransactionListeners

protected void registerTransactionListeners()
Register all declared transaction listeners


applyPdxOptions

protected void applyPdxOptions(Object factory)
Sets the PDX properties for the given object. Note this is implementation specific as it depends on the type of the factory passed in.

Parameters:
factory -

applyInternalCacheOptions

protected void applyInternalCacheOptions()

createFactory

protected Object createFactory(Properties props)

fetchCache

protected com.gemstone.gemfire.cache.GemFireCache fetchCache()

createCache

protected com.gemstone.gemfire.cache.GemFireCache createCache(Object factory)

mergeProperties

protected Properties mergeProperties()

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

translateExceptionIfPossible

public DataAccessException translateExceptionIfPossible(RuntimeException ex)
Specified by:
translateExceptionIfPossible in interface PersistenceExceptionTranslator

getObject

public com.gemstone.gemfire.cache.GemFireCache getObject()
                                                  throws Exception
Specified by:
getObject in interface FactoryBean<com.gemstone.gemfire.cache.GemFireCache>
Throws:
Exception

getObjectType

public Class<? extends com.gemstone.gemfire.cache.GemFireCache> getObjectType()
Specified by:
getObjectType in interface FactoryBean<com.gemstone.gemfire.cache.GemFireCache>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean<com.gemstone.gemfire.cache.GemFireCache>

setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface BeanClassLoaderAware

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

setBeanName

public void setBeanName(String name)
Specified by:
setBeanName in interface BeanNameAware

setProperties

public void setProperties(Properties properties)
Sets the cache properties.

Parameters:
properties - the properties to set

setCacheXml

public void setCacheXml(Resource cacheXml)
Sets the cache configuration.

Parameters:
cacheXml - the cacheXml to set

setUseBeanFactoryLocator

public void setUseBeanFactoryLocator(boolean usage)
Indicates whether a bean factory locator is enabled (default) for this cache definition or not. The locator stores the enclosing bean factory reference to allow auto-wiring of Spring beans into GemFire managed classes. Usually disabled when the same cache is used in multiple application context/bean factories inside the same VM.

Parameters:
usage - true if the bean factory locator is used underneath or not

setPdxSerializer

public void setPdxSerializer(Object serializer)
Sets the PdxSerializable for this cache. Applicable on GemFire 6.6 or higher. The argument is of type object for compatibility with GemFire 6.5.

Parameters:
serializer - pdx serializer configured for this cache.

setPdxPersistent

public void setPdxPersistent(Boolean pdxPersistent)
Sets the object preference to PdxInstance type. Applicable on GemFire 6.6 or higher.

Parameters:
pdxPersistent - the pdxPersistent to set

setPdxReadSerialized

public void setPdxReadSerialized(Boolean pdxReadSerialized)
Controls whether the type metadata for PDX objects is persisted to disk. Applicable on GemFire 6.6 or higher.

Parameters:
pdxReadSerialized - the pdxReadSerialized to set

setPdxIgnoreUnreadFields

public void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields)
Controls whether pdx ignores fields that were unread during deserialization. Applicable on GemFire 6.6 or higher.

Parameters:
pdxIgnoreUnreadFields - the pdxIgnoreUnreadFields to set

setPdxDiskStoreName

public void setPdxDiskStoreName(String pdxDiskStoreName)
Set the disk store that is used for PDX meta data. Applicable on GemFire 6.6 or higher.

Parameters:
pdxDiskStoreName - the pdxDiskStoreName to set

getBeanFactory

protected BeanFactory getBeanFactory()
Returns:
the beanFactory

setCopyOnRead

public void setCopyOnRead(boolean copyOnRead)
Parameters:
copyOnRead -

setLockTimeout

public void setLockTimeout(int lockTimeout)
Parameters:
lockTimeout -

setLockLease

public void setLockLease(int lockLease)
Parameters:
lockLease -

setMessageSyncInterval

public void setMessageSyncInterval(int messageSyncInterval)
Parameters:
messageSyncInterval -

setSearchTimeout

public void setSearchTimeout(int searchTimeout)
Parameters:
searchTimeout -

setEvictionHeapPercentage

public void setEvictionHeapPercentage(Float evictionHeapPercentage)
Parameters:
evictionHeapPercentage -

setCriticalHeapPercentage

public void setCriticalHeapPercentage(Float criticalHeapPercentage)
Parameters:
criticalHeapPercentage -

setTransactionListeners

public void setTransactionListeners(List<com.gemstone.gemfire.cache.TransactionListener> transactionListeners)
Parameters:
transactionListeners -

setTransactionWriter

public void setTransactionWriter(com.gemstone.gemfire.cache.TransactionWriter transactionWriter)
Parameters:
transactionWriter -

setDynamicRegionSupport

public void setDynamicRegionSupport(CacheFactoryBean.DynamicRegionSupport dynamicRegionSupport)
Parameters:
dynamicRegionSupport -

setJndiDataSources

public void setJndiDataSources(List<CacheFactoryBean.JndiDataSource> jndiDataSources)
Parameters:
jndiDataSources -