org.springframework.data.gemfire
Class RegionFactoryBean<K,V>

java.lang.Object
  extended by org.springframework.data.gemfire.RegionLookupFactoryBean<K,V>
      extended by org.springframework.data.gemfire.RegionFactoryBean<K,V>
All Implemented Interfaces:
Aware, BeanNameAware, DisposableBean, FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>, InitializingBean, Lifecycle, Phased, SmartLifecycle
Direct Known Subclasses:
LocalRegionFactoryBean, PartitionedRegionFactoryBean, ReplicatedRegionFactoryBean

public class RegionFactoryBean<K,V>
extends RegionLookupFactoryBean<K,V>
implements DisposableBean, SmartLifecycle

Base class for FactoryBeans used to create GemFire Regions. Will try to first locate the region (by name) and, in case none if found, proceed to creating one using the given settings. Note that this factory bean allows for very flexible creation of GemFire Region. For "client" regions however, see ClientRegionFactoryBean which offers easier configuration and defaults.


Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
RegionFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 int getPhase()
           
 boolean isAutoStartup()
           
protected  boolean isNotPersistent()
           
protected  boolean isPersistent()
           
 boolean isRunning()
           
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.AttributesFactory<K,V> attrFactory)
          Deprecated. as of GemFire 6.5, the use of AttributesFactory has been deprecated
protected  void postProcess(com.gemstone.gemfire.cache.Region<K,V> region)
          Post-process the region object for this factory bean during the initialization process.
protected  void resolveDataPolicy(com.gemstone.gemfire.cache.RegionFactory<K,V> regionFactory, Boolean persistent, String dataPolicy)
          This validates the configured data policy and may override it, taking into account the persistent attribute and constraints for the region type
 void setAsyncEventQueues(Object[] asyncEventQueues)
           
 void setAttributes(com.gemstone.gemfire.cache.RegionAttributes<K,V> attributes)
          Sets the region attributes used for the region used by this factory.
 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 cache loader used for the region used by this factory.
 void setCacheWriter(com.gemstone.gemfire.cache.CacheWriter<K,V> cacheWriter)
          Sets the cache writer used for the region used by this factory.
 void setClose(boolean close)
          Indicates whether the region referred by this factory bean, will be closed on shutdown (default true).
 void setDataPolicy(String dataPolicyName)
          Sets the dataPolicy as a String.
 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 setEnableGateway(boolean enableGateway)
           
 void setGatewaySenders(Object[] gatewaySenders)
           
 void setHubId(String hubId)
           
 void setPersistent(boolean persistent)
           
 void setScope(com.gemstone.gemfire.cache.Scope scope)
          Sets the region scope.
 void setSnapshot(Resource snapshot)
          Sets the snapshots used for loading a newly created region.
 void start()
           
 void stop()
           
 void stop(Runnable callback)
           
 
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
 

Field Detail

log

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

RegionFactoryBean

public RegionFactoryBean()
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

resolveDataPolicy

protected void resolveDataPolicy(com.gemstone.gemfire.cache.RegionFactory<K,V> regionFactory,
                                 Boolean persistent,
                                 String dataPolicy)
This validates the configured data policy and may override it, taking into account the persistent attribute and constraints for the region type

Parameters:
regionFactory -
persistent -
dataPolicy - requested data policy

postProcess

@Deprecated
protected void postProcess(com.gemstone.gemfire.cache.AttributesFactory<K,V> attrFactory)
Deprecated. as of GemFire 6.5, the use of AttributesFactory has been deprecated

Post-process the attribute factory object used for configuring the region of this factory bean during the initialization process. The object is already initialized and configured by the factory bean before this method is invoked.

Parameters:
attrFactory - attribute factory

postProcess

protected void postProcess(com.gemstone.gemfire.cache.Region<K,V> region)
Post-process the region object for this factory bean during the initialization process. The object is already initialized and configured by the factory bean before this method is invoked.

Parameters:
region -

destroy

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

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)

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)

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)

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 cache loader used for the region used by this factory. Used only when a new region is created.Overrides the settings specified through setAttributes(RegionAttributes).

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

setCacheWriter

public void setCacheWriter(com.gemstone.gemfire.cache.CacheWriter<K,V> cacheWriter)
Sets the cache writer used for the region used by this factory. Used only when a new region is created. Overrides the settings specified through setAttributes(RegionAttributes).

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

setScope

public void setScope(com.gemstone.gemfire.cache.Scope scope)
Sets the region scope. Used only when a new region is created. Overrides the settings specified through setAttributes(RegionAttributes).

Parameters:
scope - the region scope
See Also:
Scope

setPersistent

public void setPersistent(boolean persistent)

setDataPolicy

public void setDataPolicy(String dataPolicyName)
Sets the dataPolicy as a String. Required to support property placeholders

Parameters:
dataPolicy - the dataPolicy name (NORMAL, PRELOADED, etc)

setDiskStoreName

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

Parameters:
diskStoreName -

setGatewaySenders

public void setGatewaySenders(Object[] gatewaySenders)
Parameters:
gatewaySenders - defined as Object for backward compatibility with Gemfire 6

setAsyncEventQueues

public void setAsyncEventQueues(Object[] asyncEventQueues)
Parameters:
asyncEventQueues - defined as Object for backward compatibility with Gemfire 6

setEnableGateway

public void setEnableGateway(boolean enableGateway)

setHubId

public void setHubId(String hubId)

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.

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

isPersistent

protected boolean isPersistent()

isNotPersistent

protected boolean isNotPersistent()

start

public void start()
Specified by:
start in interface Lifecycle

stop

public void stop()
Specified by:
stop in interface Lifecycle

isRunning

public boolean isRunning()
Specified by:
isRunning in interface Lifecycle

getPhase

public int getPhase()
Specified by:
getPhase in interface Phased

isAutoStartup

public boolean isAutoStartup()
Specified by:
isAutoStartup in interface SmartLifecycle

stop

public void stop(Runnable callback)
Specified by:
stop in interface SmartLifecycle