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.


Field Summary
protected  org.apache.commons.logging.Log log
           
protected  String pdxDiskStoreName
           
protected  Boolean pdxIgnoreUnreadFields
           
protected  Boolean pdxPersistent
           
protected  Boolean pdxReadSerialized
           
protected  Object pdxSerializer
           
 
Constructor Summary
CacheFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
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()
           
 void setBeanClassLoader(ClassLoader classLoader)
           
 void setBeanFactory(BeanFactory beanFactory)
           
 void setBeanName(String name)
           
 void setCacheXml(Resource cacheXml)
          Sets the cache configuration.
 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 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

pdxSerializer

protected Object pdxSerializer

pdxPersistent

protected Boolean pdxPersistent

pdxReadSerialized

protected Boolean pdxReadSerialized

pdxIgnoreUnreadFields

protected Boolean pdxIgnoreUnreadFields

pdxDiskStoreName

protected String pdxDiskStoreName
Constructor Detail

CacheFactoryBean

public CacheFactoryBean()
Method Detail

afterPropertiesSet

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

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 -

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