public class RegionFactoryBean<K,V> extends RegionLookupFactoryBean<K,V> implements DisposableBean, SmartLifecycle
Region
s. 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.Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
log |
Constructor and Description |
---|
RegionFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
assertDataPolicyAndPersistentAttributesAreCompatible(DataPolicy resolvedDataPolicy)
Validates that the settings for Data Policy and the 'persistent' attribute in <gfe:*-region> elements
are compatible.
|
protected RegionFactory<K,V> |
createRegionFactory(Cache cache)
Creates an instance of RegionFactory using the given Cache instance used to configure and construct the Region
created by this FactoryBean.
|
void |
destroy() |
RegionAttributes |
getAttributes()
Returns the attributes used to configure the Region created by this factory as set in the SDG XML namespace
configuration meta-data, or as set with the setAttributes(:Attributes) method.
|
DataPolicy |
getDataPolicy()
Gets the "resolved" Data Policy as determined by this RegionFactory when configuring the attributes
of the Region to be created.
|
int |
getPhase() |
protected RegionShortcut |
getShortcut() |
boolean |
isAutoStartup() |
protected boolean |
isNotPersistent()
Returns true when the user explicitly specified a value for the persistent attribute and it is false.
|
protected boolean |
isPersistent()
Returns true when the user explicitly specified a value for the persistent attribute and it is true.
|
protected boolean |
isPersistentUnspecified()
Determines whether the user explicitly set the 'persistent' attribute or not.
|
boolean |
isRunning() |
protected Region<K,V> |
lookupFallback(GemFireCache gemfireCache,
String regionName)
Fallback method in case the named Region does not exist.
|
protected <K,V> void |
mergePartitionAttributes(RegionFactory<K,V> regionFactory,
RegionAttributes<K,V> regionAttributes) |
protected <K,V> RegionFactory<K,V> |
mergeRegionAttributes(RegionFactory<K,V> regionFactory,
RegionAttributes<K,V> regionAttributes)
Intelligently merges the given RegionAttributes with the configuration setting of the RegionFactory.
|
protected void |
postProcess(Region<K,V> region)
Post-process the Region for this factory bean during the initialization process.
|
protected void |
postProcess(RegionFactory<K,V> regionFactory)
Post-process the RegionFactory used to create the GemFire Region for this factory bean during the initialization
process.
|
protected void |
resolveDataPolicy(RegionFactory<K,V> regionFactory,
Boolean persistent,
DataPolicy dataPolicy)
Validates and sets the Data Policy on the RegionFactory used to create and configure the Region from this
FactoryBean.
|
protected void |
resolveDataPolicy(RegionFactory<K,V> regionFactory,
Boolean persistent,
String dataPolicy)
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)
The list of AsyncEventQueues to use with this Region.
|
void |
setAttributes(RegionAttributes<K,V> attributes)
Sets the region attributes used for the region used by this factory.
|
void |
setCacheListeners(CacheListener<K,V>[] cacheListeners)
Sets the cache listeners used for the region used by this factory.
|
void |
setCacheLoader(CacheLoader<K,V> cacheLoader)
Sets the cache loader used for the region used by this factory.
|
void |
setCacheWriter(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 to by this factory bean will be closed on shutdown (default true).
|
void |
setDataPolicy(DataPolicy dataPolicy)
Sets the DataPolicy of the Region.
|
void |
setDataPolicy(String dataPolicyName)
Deprecated.
as of 1.4.0, use setDataPolicy(:DataPolicy) instead.
|
void |
setDestroy(boolean destroy)
Indicates whether the Region referred to by this factory bean will be destroyed on shutdown (default false).
|
void |
setDiskStoreName(String diskStoreName)
Sets the name of Disk Store used for either overflow or persistence, or both.
|
void |
setEnableGateway(boolean enableGateway) |
void |
setGatewaySenders(Object[] gatewaySenders) |
void |
setHubId(String hubId) |
void |
setPersistent(Boolean persistent) |
void |
setScope(Scope scope)
Sets the region scope.
|
void |
setShortcut(RegionShortcut shortcut)
Configures the Region with a RegionShortcut.
|
void |
setSnapshot(Resource snapshot)
Sets the snapshots used for loading a newly created region.
|
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
getLookupEnabled, getObject, getObjectType, getParent, getRegion, isSingleton, setBeanName, setCache, setLookupEnabled, setName, setParent, setRegionName
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class RegionLookupFactoryBean<K,V>
Exception
protected Region<K,V> lookupFallback(GemFireCache gemfireCache, String regionName) throws Exception
RegionLookupFactoryBean
lookupFallback
in class RegionLookupFactoryBean<K,V>
gemfireCache
- a reference to the GemFire Cache.regionName
- the name of the GemFire Cache Region.Exception
- if the lookup operation fails.protected void assertDataPolicyAndPersistentAttributesAreCompatible(DataPolicy resolvedDataPolicy)
resolvedDataPolicy
- the GemFire Data Policy resolved form the Spring GemFire XML namespace configuration
meta-data.isPersistent()
,
isNotPersistent()
,
DataPolicy
protected boolean isPersistentUnspecified()
isPersistent()
,
isNotPersistent()
protected boolean isPersistent()
isNotPersistent()
,
isPersistentUnspecified()
protected boolean isNotPersistent()
isPersistent()
,
isPersistentUnspecified()
protected RegionFactory<K,V> createRegionFactory(Cache cache)
cache
- the GemFire Cache instance.Cache.createRegionFactory()
,
Cache.createRegionFactory(com.gemstone.gemfire.cache.RegionAttributes)
,
Cache.createRegionFactory(com.gemstone.gemfire.cache.RegionShortcut)
,
RegionFactory
protected <K,V> RegionFactory<K,V> mergeRegionAttributes(RegionFactory<K,V> regionFactory, RegionAttributes<K,V> regionAttributes)
K
- the Class type fo the Region key.V
- the Class type of the Region value.regionFactory
- the GemFire RegionFactory used to configure and create the Region that is the product
of this RegionFactoryBean.regionAttributes
- the RegionAttributes containing the Region configuration settings to merge to the
RegionFactory.hasUserSpecifiedEvictionAttributes(com.gemstone.gemfire.cache.RegionAttributes)
,
validateRegionAttributes(com.gemstone.gemfire.cache.RegionAttributes)
,
RegionAttributes
,
RegionFactory
protected <K,V> void mergePartitionAttributes(RegionFactory<K,V> regionFactory, RegionAttributes<K,V> regionAttributes)
protected void postProcess(RegionFactory<K,V> regionFactory)
regionFactory
- the GemFire RegionFactory used to create the Region for post-processing.RegionFactory
protected void postProcess(Region<K,V> region)
region
- the GemFire Region to post-process.Region
protected void resolveDataPolicy(RegionFactory<K,V> regionFactory, Boolean persistent, DataPolicy dataPolicy)
regionFactory
- the RegionFactory used by this FactoryBean to create and configure the Region.persistent
- a boolean value indicating whether the Region should be persistent and persist it's
data to disk.dataPolicy
- the configured Data Policy for the Region.resolveDataPolicy(com.gemstone.gemfire.cache.RegionFactory, Boolean, String)
,
DataPolicy
,
RegionFactory
protected void resolveDataPolicy(RegionFactory<K,V> regionFactory, Boolean persistent, String dataPolicy)
regionFactory
- the GemFire RegionFactory used to create the desired Region.persistent
- a boolean value indicating whether the Region should persist it's data to disk.dataPolicy
- requested Data Policy as set by the user in the Spring GemFire configuration meta-data.DataPolicy
,
RegionFactory
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
public void setAsyncEventQueues(Object[] asyncEventQueues)
asyncEventQueues
- defined as Object for backwards compatibility with Gemfire 6.public void setAttributes(RegionAttributes<K,V> attributes)
attributes
- the attributes to set on a newly created regionpublic RegionAttributes getAttributes()
RegionAttributes
public void setCacheListeners(CacheListener<K,V>[] cacheListeners)
setAttributes(RegionAttributes)
.cacheListeners
- the cacheListeners to set on a newly created regionpublic void setCacheLoader(CacheLoader<K,V> cacheLoader)
setAttributes(RegionAttributes)
.cacheLoader
- the cacheLoader to set on a newly created regionpublic void setCacheWriter(CacheWriter<K,V> cacheWriter)
setAttributes(RegionAttributes)
.cacheWriter
- the cacheWriter to set on a newly created regionpublic void setClose(boolean close)
close
- a boolean value indicating whether this Region should be closed on member shutdown.setDestroy(boolean)
public void setDestroy(boolean destroy)
destroy
- a boolean value indicating whether the Region is to be destroy on member shutdown.setDestroy(boolean)
public void setDataPolicy(DataPolicy dataPolicy)
dataPolicy
- the GemFire DataPolicy to use when configuring the Region.public void setDataPolicy(String dataPolicyName)
dataPolicyName
- the name of the DataPolicy (e.g. REPLICATE, PARTITION)setDataPolicy(com.gemstone.gemfire.cache.DataPolicy)
public DataPolicy getDataPolicy()
DataPolicy
public void setDiskStoreName(String diskStoreName)
diskStoreName
- the name of the Disk Store bean in context used for overflow/persistence.public void setEnableGateway(boolean enableGateway)
public void setGatewaySenders(Object[] gatewaySenders)
gatewaySenders
- defined as Object for backward compatibility with
Gemfire 6public void setHubId(String hubId)
public void setPersistent(Boolean persistent)
public void setScope(Scope scope)
setAttributes(RegionAttributes)
.scope
- the region scopeScope
protected final RegionShortcut getShortcut()
public void setShortcut(RegionShortcut shortcut)
shortcut
- the RegionShortcut used to configure pre-defined default for the Region created
by this FactoryBean.RegionShortcut
public void setSnapshot(Resource snapshot)
snapshot
- the snapshot to setRegionLookupFactoryBean.setName(String)
public boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public void stop(Runnable callback)
stop
in interface SmartLifecycle