org.springframework.data.gemfire.client
Class ClientRegionFactoryBean<K,V>

java.lang.Object
  extended by org.springframework.data.gemfire.RegionLookupFactoryBean<K,V>
      extended by org.springframework.data.gemfire.client.ClientRegionFactoryBean<K,V>
All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, DisposableBean, FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>, InitializingBean

public class ClientRegionFactoryBean<K,V>
extends RegionLookupFactoryBean<K,V>
implements BeanFactoryAware, DisposableBean

Client extension for GemFire Regions.


Constructor Summary
ClientRegionFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void assertClientRegionShortcutAndPersistentAttributeAreCompatible(com.gemstone.gemfire.cache.client.ClientRegionShortcut resolvedShortcut)
          Validates that the settings for ClientRegionShortcut and the 'persistent' attribute in elements are compatible.
protected  void assertDataPolicyAndPersistentAttributeAreCompatible(com.gemstone.gemfire.cache.DataPolicy resolvedDataPolicy)
          Validates that the settings for Data Policy and the 'persistent' attribute in elements are compatible.
 void destroy()
           
protected  boolean isNotPersistent()
           
protected  boolean isPersistent()
           
protected  com.gemstone.gemfire.cache.Region<K,V> lookupFallback(com.gemstone.gemfire.cache.GemFireCache cache, String regionName)
          Fall back method in case the named region does not exist.
protected  void postProcess(com.gemstone.gemfire.cache.Region<K,V> region)
           
protected  com.gemstone.gemfire.cache.client.ClientRegionShortcut resolveClientRegionShortcut()
           
 void setAttributes(com.gemstone.gemfire.cache.RegionAttributes<K,V> attributes)
          Sets the region attributes used for the region used by this factory.
 void setBeanFactory(BeanFactory beanFactory)
           
 void setCacheListeners(com.gemstone.gemfire.cache.CacheListener<K,V>[] cacheListeners)
          Sets the cache listeners used for the region used by this factory.
 void setCacheLoader(com.gemstone.gemfire.cache.CacheLoader<K,V> cacheLoader)
          Sets the CacheLoader used to load data local to the client's Region on cache misses.
 void setCacheWriter(com.gemstone.gemfire.cache.CacheWriter<K,V> cacheWriter)
          Sets the CacheWriter used to perform a synchronous write-behind when data is put into the client's Region.
 void setClose(boolean close)
          Indicates whether the region referred by this factory bean, will be closed on shutdown (default true).
 void setDataPolicy(com.gemstone.gemfire.cache.DataPolicy dataPolicy)
          Sets the Data Policy.
 void setDataPolicyName(String dataPolicyName)
          Deprecated. use setDataPolicy(:DataPolicy) instead.
 void setDestroy(boolean destroy)
          Indicates whether the region referred by this factory bean will be destroyed on shutdown (default false).
 void setDiskStoreName(String diskStoreName)
          Sets the name of disk store to use for overflow and persistence
 void setInterests(Interest<K>[] interests)
          Set the interests for this client region.
 void setPersistent(boolean persistent)
           
 void setPool(com.gemstone.gemfire.cache.client.Pool pool)
          Sets the pool used by this client.
 void setPoolName(String poolName)
          Sets the pool name used by this client.
 void setShortcut(com.gemstone.gemfire.cache.client.ClientRegionShortcut shortcut)
          Initializes the client using a GemFire ClientRegionShortcut.
 void setSnapshot(Resource snapshot)
          Sets the snapshots used for loading a newly created region.
 
Methods inherited from class org.springframework.data.gemfire.RegionLookupFactoryBean
getObject, getObjectType, getRegion, isSingleton, setBeanName, setCache, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientRegionFactoryBean

public ClientRegionFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class RegionLookupFactoryBean<K,V>
Throws:
Exception

lookupFallback

protected com.gemstone.gemfire.cache.Region<K,V> lookupFallback(com.gemstone.gemfire.cache.GemFireCache cache,
                                                                String regionName)
                                                         throws Exception
Description copied from class: RegionLookupFactoryBean
Fall back method in case the named region does not exist. By default, this implementation throws an exception.

Overrides:
lookupFallback in class RegionLookupFactoryBean<K,V>
Parameters:
cache - GemFire cache
regionName - region name
Throws:
Exception

resolveClientRegionShortcut

protected com.gemstone.gemfire.cache.client.ClientRegionShortcut resolveClientRegionShortcut()

assertClientRegionShortcutAndPersistentAttributeAreCompatible

protected void assertClientRegionShortcutAndPersistentAttributeAreCompatible(com.gemstone.gemfire.cache.client.ClientRegionShortcut resolvedShortcut)
Validates that the settings for ClientRegionShortcut and the 'persistent' attribute in elements are compatible.

Parameters:
resolvedShortcut - the GemFire ClientRegionShortcut resolved form the Spring GemFire XML namespace configuration meta-data.
See Also:
isPersistent(), isNotPersistent(), ClientRegionShortcut

assertDataPolicyAndPersistentAttributeAreCompatible

protected void assertDataPolicyAndPersistentAttributeAreCompatible(com.gemstone.gemfire.cache.DataPolicy resolvedDataPolicy)
Validates that the settings for Data Policy and the 'persistent' attribute in elements are compatible.

Parameters:
resolvedDataPolicy - the GemFire Data Policy resolved form the Spring GemFire XML namespace configuration meta-data.
See Also:
isPersistent(), isNotPersistent(), DataPolicy

postProcess

protected void postProcess(com.gemstone.gemfire.cache.Region<K,V> region)

destroy

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

setAttributes

public void setAttributes(com.gemstone.gemfire.cache.RegionAttributes<K,V> attributes)
Sets the region attributes used for the region used by this factory. Allows maximum control in specifying the region settings. Used only when a new region is created. Note that using this method allows for advanced customization of the region - while it provides a lot of flexibility, note that it's quite easy to create misconfigured regions (especially in a client/server scenario).

Parameters:
attributes - the attributes to set on a newly created region

setBeanFactory

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

setInterests

public void setInterests(Interest<K>[] interests)
Set the interests for this client region. Both key and regex interest are supported.

Parameters:
interests - the interests to set

setPool

public void setPool(com.gemstone.gemfire.cache.client.Pool pool)
Sets the pool used by this client.

Parameters:
pool -

setPoolName

public void setPoolName(String poolName)
Sets the pool name used by this client.

Parameters:
poolName -

setClose

public void setClose(boolean close)
Indicates whether the region referred by this factory bean, will be closed on shutdown (default true). Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.

Parameters:
close - whether to close or not the region
See Also:
setDestroy(boolean)

setDestroy

public void setDestroy(boolean destroy)
Indicates whether the region referred by this factory bean will be destroyed on shutdown (default false). Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.

Parameters:
destroy - whether or not to destroy the region
See Also:
setClose(boolean)

setCacheListeners

public void setCacheListeners(com.gemstone.gemfire.cache.CacheListener<K,V>[] cacheListeners)
Sets the cache listeners used for the region used by this factory. Used only when a new region is created.Overrides the settings specified through setAttributes(RegionAttributes).

Parameters:
cacheListeners - the cacheListeners to set on a newly created region

setCacheLoader

public void setCacheLoader(com.gemstone.gemfire.cache.CacheLoader<K,V> cacheLoader)
Sets the CacheLoader used to load data local to the client's Region on cache misses.

Parameters:
cacheLoader - a GemFire CacheLoader used to load data into the client Region.
See Also:
CacheLoader

setCacheWriter

public void setCacheWriter(com.gemstone.gemfire.cache.CacheWriter<K,V> cacheWriter)
Sets the CacheWriter used to perform a synchronous write-behind when data is put into the client's Region.

Parameters:
cacheWriter - the GemFire CacheWriter used to perform synchronous write-behinds on put ops.
See Also:
CacheWriter

setDataPolicy

public void setDataPolicy(com.gemstone.gemfire.cache.DataPolicy dataPolicy)
Sets the Data Policy. Used only when a new Region is created.

Parameters:
dataPolicy - the client Region's Data Policy.
See Also:
DataPolicy

setDiskStoreName

public void setDiskStoreName(String diskStoreName)
Sets the name of disk store to use for overflow and persistence

Parameters:
diskStoreName -

setDataPolicyName

public void setDataPolicyName(String dataPolicyName)
Deprecated. use setDataPolicy(:DataPolicy) instead.

An alternate way to set the Data Policy, using the String name of the enumerated value.

Parameters:
dataPolicyName - the enumerated value String name of the Data Policy.
See Also:
DataPolicy, setDataPolicy(com.gemstone.gemfire.cache.DataPolicy)

isPersistent

protected boolean isPersistent()

isNotPersistent

protected boolean isNotPersistent()

setPersistent

public void setPersistent(boolean persistent)

setShortcut

public void setShortcut(com.gemstone.gemfire.cache.client.ClientRegionShortcut shortcut)
Initializes the client using a GemFire ClientRegionShortcut. The recommended way for creating clients since it covers all the major scenarios with minimal configuration.

Parameters:
shortcut - the ClientRegionShortcut to use.

setSnapshot

public void setSnapshot(Resource snapshot)
Sets the snapshots used for loading a newly created region. That is, the snapshot will be used only when a new region is created - if the region already exists, no loading will be performed.

Parameters:
snapshot - the snapshot to set
See Also:
RegionLookupFactoryBean.setName(String)