Package org.springframework.data.gemfire
Class PeerRegionFactoryBean<K,V>
java.lang.Object
org.springframework.data.gemfire.support.AbstractFactoryBeanSupport<Region<K,V>>
org.springframework.data.gemfire.ResolvableRegionFactoryBean<K,V>
org.springframework.data.gemfire.ConfigurableRegionFactoryBean<K,V>
org.springframework.data.gemfire.PeerRegionFactoryBean<K,V>
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,FactoryBean<Region<K,
,V>> InitializingBean
,Lifecycle
,Phased
,SmartLifecycle
,EvictingRegionFactoryBean
,ExpiringRegionFactoryBean<K,
V>
- Direct Known Subclasses:
GenericRegionFactoryBean
,LocalRegionFactoryBean
,PartitionedRegionFactoryBean
,ReplicatedRegionFactoryBean
public abstract class PeerRegionFactoryBean<K,V>
extends ConfigurableRegionFactoryBean<K,V>
implements DisposableBean, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K,V>, SmartLifecycle
Spring
FactoryBean
and abstract base class extended by other SDG FactoryBeans
used to construct, configure and initialize peer Regions
.
This FactoryBean
allows for very easy and flexible creation of peer Regions
.
For client Regions
, see the ClientRegionFactoryBean
.- Author:
- Costin Leau, David Turanski, John Blum
- See Also:
-
Cache
CacheListener
CacheLoader
CacheWriter
CustomExpiry
DataPolicy
DiskStore
EvictionAttributes
ExpirationAttributes
GemFireCache
PartitionAttributes
Region
RegionAttributes
RegionFactory
RegionShortcut
Scope
AsyncEventQueue
GatewaySender
Compressor
DisposableBean
SmartLifecycle
ConfigurableRegionFactoryBean
ResolvableRegionFactoryBean
ClientRegionFactoryBean
EvictingRegionFactoryBean
ExpiringRegionFactoryBean
RegionConfigurer
-
Field Summary
Fields inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
DEFAULT_SINGLETON
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAsyncEventQueueIds
(String[] asyncEventQueueIds) Registers the array ofAsyncEventQueues
(AEQ) with thisRegion
byID
by appending to the already existing, registered AEQs for thisRegion
.void
addAsyncEventQueues
(AsyncEventQueue[] asyncEventQueues) Registers the array ofAsyncEventQueues
(AEQ) with thisRegion
by appending to the already existing, registered AEQs for thisRegion
.void
addGatewaySenders
(GatewaySender[] gatewaySenders) Registers the array ofGatewaySenders
with thisRegion
by appending to the already existing, registeredGatewaySenders
for thisRegion
.void
addGatewaySendersIds
(String[] gatewaySenderIds) Registers the array ofGatewaySender
IDs
with thisRegion
by appending to the already existing, registeredGatewaySenders
for thisRegion
.protected RegionFactory<K,
V> configure
(RegionFactory<K, V> regionFactory) Configures theRegionFactory
based on the configuration settings of thisPeerRegionFactoryBean
.createRegion
(GemFireCache gemfireCache, String regionName) protected RegionFactory<K,
V> createRegionFactory
(Cache cache) Create a new instance ofRegionFactory
initialized with the givenCache
that is then used to construct, configure and initialize theRegion
specified by thisPeerRegionFactoryBean
.void
destroy()
Closes and destroys thisRegion
.Returns theRegionAttributes
used to configure thisRegion
.int
getPhase()
getScope()
Returns the configuredRegionShortcut
.boolean
protected boolean
Returns true when the user explicitly specified a value for the persistent attribute and it is false.boolean
Returns a boolean value indicating whether off-heap memory use was enabled for thisRegion
.protected boolean
Returns true when the user explicitly specified a value for the persistent attribute and it is true.boolean
boolean
protected <K,
V> void mergePartitionAttributes
(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Merges theRegionAttributes
into theRegionFactory
.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 RegionFactory<K,
V> postProcess
(RegionFactory<K, V> regionFactory) Post-process theRegionFactory
used to create theRegion
specified by thisPeerRegionFactoryBean
during initialization.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.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 boolean
void
setAsyncEventQueueIds
(String[] asyncEventQueueIds) void
setAsyncEventQueues
(AsyncEventQueue[] asyncEventQueues) Configures an array ofAsyncEventQueues
for thisRegion
, which are used to perform asynchronous data access operations, e.g.void
setAttributes
(RegionAttributes<K, V> attributes) Sets theRegionAttributes
used to configure thisRegion
.void
setCacheListeners
(CacheListener<K, V>[] cacheListeners) ConfiguresCacheListeners
used to listen for entry events on thisRegion
.void
setCacheLoader
(CacheLoader<K, V> cacheLoader) Configures theCacheLoader
used by thisRegion
to perform synchronous read-through data access operations to an underlying, external data source.void
setCacheWriter
(CacheWriter<K, V> cacheWriter) Configures theCacheWriter
used by thisRegion
to perform synchronous write-through data access operations to an underlying, external data source.void
setClose
(boolean close) Configure whether to close this Region during shutdown.void
setCompressor
(Compressor compressor) Configures theCompressor
used to compress thisRegion's
data.void
setCustomEntryIdleTimeout
(CustomExpiry<K, V> customEntryIdleTimeout) void
setCustomEntryTimeToLive
(CustomExpiry<K, V> customEntryTimeToLive) void
setDataPolicy
(DataPolicy dataPolicy) Configure theDataPolicy
for thisRegion
.void
setDestroy
(boolean destroy) Configure whether to destroy thisRegion
during shutdown.void
setDiskStoreName
(String diskStoreName) void
setEntryIdleTimeout
(ExpirationAttributes entryIdleTimeout) void
setEntryTimeToLive
(ExpirationAttributes entryTimeToLive) void
setEvictionAttributes
(EvictionAttributes evictionAttributes) void
setGatewaySenderIds
(String[] gatewaySenderIds) Configures theGatewaySenders
byID
used to send data and events from thisRegion
to a matchingRegion
in a remote cluster.void
setGatewaySenders
(GatewaySender[] gatewaySenders) Configures theGatewaySenders
used to send data and events from thisRegion
to a matchingRegion
in a remote cluster.void
setKeyConstraint
(Class<K> keyConstraint) void
setOffHeap
(Boolean offHeap) Configures thisRegion
with the capability to store data in off-heap memory.void
setPersistent
(Boolean persistent) Configures whether to enable persistence for thisRegion
.void
setRegionIdleTimeout
(ExpirationAttributes regionIdleTimeout) void
setRegionTimeToLive
(ExpirationAttributes regionTimeToLive) void
void
setShortcut
(RegionShortcut shortcut) Configures theRegion
with the givenRegionShortcut
.void
setStatisticsEnabled
(Boolean statisticsEnabled) void
setValueConstraint
(Class<V> valueConstraint) void
start()
void
stop()
void
Methods inherited from class org.springframework.data.gemfire.ConfigurableRegionFactoryBean
applyRegionConfigurers, applyRegionConfigurers, applyRegionConfigurers, getCompositeRegionConfigurer, setRegionConfigurers, setRegionConfigurers
Methods inherited from class org.springframework.data.gemfire.ResolvableRegionFactoryBean
afterPropertiesSet, getCache, getLookupEnabled, getObject, getObjectType, getParent, getRegion, isLookupEnabled, loadSnapshot, postProcess, resolveRegionName, setCache, setLookupEnabled, setName, setParent, setRegion, setRegionName, setSnapshot
Methods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLog, getOptionalLog, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isSingleton, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLog, setBeanClassLoader, setBeanFactory, setBeanName
-
Constructor Details
-
PeerRegionFactoryBean
public PeerRegionFactoryBean()
-
-
Method Details
-
createRegion
- Overrides:
createRegion
in classResolvableRegionFactoryBean<K,
V> - Parameters:
gemfireCache
- reference to theGemFireCache
.regionName
-name
of the newRegion
.- Returns:
- a new
Region
with the givenname
. - See Also:
-
createRegionFactory
Create a new instance ofRegionFactory
initialized with the givenCache
that is then used to construct, configure and initialize theRegion
specified by thisPeerRegionFactoryBean
.- Parameters:
cache
- reference to theCache
.- Returns:
- a
RegionFactory
used to construct, configure and initialize theRegion
specified by thisPeerRegionFactoryBean
. - See Also:
-
configure
Configures theRegionFactory
based on the configuration settings of thisPeerRegionFactoryBean
.- Parameters:
regionFactory
-RegionFactory
to configure- Returns:
- the given
RegionFactory
. - See Also:
-
postProcess
Post-process theRegionFactory
used to create theRegion
specified by thisPeerRegionFactoryBean
during initialization. TheRegionFactory
has been already constructed, configured and initialized by thisPeerRegionFactoryBean
before this method gets invoked.- Parameters:
regionFactory
-RegionFactory
used to create theRegion
.- Returns:
- the given
RegionFactory
. - See Also:
-
mergeRegionAttributes
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. This method is used to merge the RegionAttributes and PartitionAttributes with the RegionFactory that is created when the user specified a RegionShortcut. This method gets called by the createRegionFactory method depending upon the value passed to the Cache.createRegionFactory() method (i.e. whether there was a RegionShortcut specified or not).- Type Parameters:
K
- the Class type fo the Region key.V
- the Class type of the Region value.- Parameters:
regionFactory
- the GemFire RegionFactory used to configure and create the Region that is the product of this PeerRegionFactoryBean.regionAttributes
- the RegionAttributes containing the Region configuration settings to merge to the RegionFactory.- Returns:
- the RegionFactory with the configuration settings of the RegionAttributes merged.
- See Also:
-
isUserSpecifiedEvictionAttributes(org.apache.geode.cache.RegionAttributes)
validateRegionAttributes(org.apache.geode.cache.RegionAttributes)
RegionAttributes
RegionFactory
-
mergePartitionAttributes
protected <K,V> void mergePartitionAttributes(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Merges theRegionAttributes
into theRegionFactory
.- Parameters:
regionFactory
-RegionFactory
to configure.regionAttributes
-RegionAttributes
used to configure theRegionFactory
if not null.- See Also:
-
isNotPersistent
protected boolean isNotPersistent()Returns true when the user explicitly specified a value for the persistent attribute and it is false. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.- Returns:
- true when the user specified an explicit value for the persistent attribute and it is false; false otherwise.
- See Also:
-
isPersistent
protected boolean isPersistent()Returns true when the user explicitly specified a value for the persistent attribute and it is true. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.- Returns:
- true when the user specified an explicit value for the persistent attribute and it is true; false otherwise.
- See Also:
-
resolveDataPolicy
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.- Parameters:
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.- See Also:
-
resolveDataPolicy
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.- Parameters:
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.- See Also:
-
destroy
Closes and destroys thisRegion
.- Specified by:
destroy
in interfaceDisposableBean
- Throws:
Exception
- ifdestroy()
fails.- See Also:
-
setAsyncEventQueues
Configures an array ofAsyncEventQueues
for thisRegion
, which are used to perform asynchronous data access operations, e.g. asynchronous, write-behind operations. This method clears any existing, registeredAsyncEventQueues
(AEQ) already associated with thisRegion
. UseaddAsyncEventQueues(AsyncEventQueue[])
oraddAsyncEventQueueIds(String[])
to append to the existing AEQs already registered instead.- Parameters:
asyncEventQueues
- array ofAsyncEventQueues
registered with and used by thisRegion
to perform asynchronous data access operations.- See Also:
-
setAsyncEventQueueIds
Configures an array ofAsyncEventQueues
(AEQ) for thisRegion
byAEQ ID
. This method clears any existing, registeredAsyncEventQueues
(AEQ) already associated with thisRegion
by AEQ ID. UseaddAsyncEventQueues(AsyncEventQueue[])
oraddAsyncEventQueueIds(String[])
to append to the existing AEQs already registered instead. oraddAsyncEventQueueIds(String[])
to append to the existing AEQs already registered instead. -
addAsyncEventQueues
Registers the array ofAsyncEventQueues
(AEQ) with thisRegion
by appending to the already existing, registered AEQs for thisRegion
.- Parameters:
asyncEventQueues
- array ofAsyncEventQueues
to register with thisRegion
.- See Also:
-
addAsyncEventQueueIds
Registers the array ofAsyncEventQueues
(AEQ) with thisRegion
byID
by appending to the already existing, registered AEQs for thisRegion
.- Parameters:
asyncEventQueueIds
- array ofAsyncEventQueue
IDs
to register with thisRegion
.- See Also:
-
setAttributes
Sets theRegionAttributes
used to configure thisRegion
. SpecifyingRegionAttributes
allows full control in configuring variousRegion
settings. Used only when theRegion
is created and not when theRegion
is looked up.- Parameters:
attributes
-RegionAttributes
used to configure thisRegion
.- See Also:
-
getAttributes
Returns theRegionAttributes
used to configure thisRegion
.- Returns:
- the
RegionAttributes
used to configure thisRegion
. - See Also:
-
setCacheListeners
ConfiguresCacheListeners
used to listen for entry events on thisRegion
. Used only when a newRegion
is created and notlooked up
. Overrides theRegion
settings specified inRegionAttributes
set withsetAttributes(RegionAttributes)
.- Parameters:
cacheListeners
- arrayCacheListeners
to register with thisRegion
.- See Also:
-
setCacheLoader
Configures theCacheLoader
used by thisRegion
to perform synchronous read-through data access operations to an underlying, external data source. Used only when a newRegion
is created and notlooked up
. Overrides theRegion
settings specified inRegionAttributes
set withsetAttributes(RegionAttributes)
.- Parameters:
cacheLoader
-CacheLoader
to register for thisRegion
.- See Also:
-
setCacheWriter
Configures theCacheWriter
used by thisRegion
to perform synchronous write-through data access operations to an underlying, external data source. Used only when a newRegion
is created and notlooked up
. Overrides theRegion
settings specified inRegionAttributes
set withsetAttributes(RegionAttributes)
.- Parameters:
cacheWriter
-CacheWriter
to register for thisRegion
.- See Also:
-
setClose
public void setClose(boolean close) Configure whether to close this Region during shutdown. Defaults to true.- Parameters:
close
- boolean value indicating whether thisRegion
should be closed during shutdown.- See Also:
-
setCompressor
Configures theCompressor
used to compress thisRegion's
data.- Parameters:
compressor
-Compressor
used to compress thisRegion's
data.- See Also:
-
setCustomEntryIdleTimeout
- Specified by:
setCustomEntryIdleTimeout
in interfaceExpiringRegionFactoryBean<K,
V>
-
setCustomEntryTimeToLive
- Specified by:
setCustomEntryTimeToLive
in interfaceExpiringRegionFactoryBean<K,
V>
-
setDestroy
public void setDestroy(boolean destroy) Configure whether to destroy thisRegion
during shutdown. Defaults to false.- Parameters:
destroy
- value indicating whether thisRegion
should be destroyed during shutdown.- See Also:
-
setDataPolicy
Configure theDataPolicy
for thisRegion
.- Parameters:
dataPolicy
-DataPolicy
used when configuring thisRegion
.- Since:
- 1.4.0
- See Also:
-
getDataPolicy
- Returns:
- the configured, resolved
DataPolicy
used by thisRegion
. - Throws:
IllegalStateException
- if theDataPolicy
has not been configured or is not resolvable.- See Also:
-
setDiskStoreName
-
setEntryIdleTimeout
- Specified by:
setEntryIdleTimeout
in interfaceExpiringRegionFactoryBean<K,
V>
-
setEntryTimeToLive
- Specified by:
setEntryTimeToLive
in interfaceExpiringRegionFactoryBean<K,
V>
-
setEvictionAttributes
- Specified by:
setEvictionAttributes
in interfaceEvictingRegionFactoryBean
-
setGatewaySenders
Configures theGatewaySenders
used to send data and events from thisRegion
to a matchingRegion
in a remote cluster. This method clears all existing, registeredGatewaySenders
already associated with thisRegion
. UseaddGatewaySenders(GatewaySender[])
oraddGatewaySendersIds(String[])
to append to the existing, registeredGatewaySenders
for thisRegion
.- Parameters:
gatewaySenders
-GatewaySenders
used to send data and events from thisRegion
to a matchingRegion
in a remote cluster.- See Also:
-
setGatewaySenderIds
Configures theGatewaySenders
byID
used to send data and events from thisRegion
to a matchingRegion
in a remote cluster. This method clears all existing, registeredGatewaySenders
already associated with thisRegion
. UseaddGatewaySenders(GatewaySender[])
oraddGatewaySendersIds(String[])
to append to the existing, registeredGatewaySenders
for thisRegion
.- Parameters:
gatewaySenderIds
-String
array containingGatewaySender
IDs
to register with thisRegion
.- See Also:
-
addGatewaySenders
Registers the array ofGatewaySenders
with thisRegion
by appending to the already existing, registeredGatewaySenders
for thisRegion
.- Parameters:
gatewaySenders
- array ofGatewaySenders
to register with thisRegion
.- See Also:
-
addGatewaySendersIds
Registers the array ofGatewaySender
IDs
with thisRegion
by appending to the already existing, registeredGatewaySenders
for thisRegion
.- Parameters:
gatewaySenderIds
- array ofGatewaySender
IDs
to register with thisRegion
.- See Also:
-
setOffHeap
Configures thisRegion
with the capability to store data in off-heap memory. -
getOffHeap
-
isOffHeap
public boolean isOffHeap()Returns a boolean value indicating whether off-heap memory use was enabled for thisRegion
.- Returns:
- a boolean value indicating whether off-heap memory use was enabled for
this
Region
. - See Also:
-
setKeyConstraint
-
setPersistent
-
setRegionIdleTimeout
- Specified by:
setRegionIdleTimeout
in interfaceExpiringRegionFactoryBean<K,
V>
-
setRegionTimeToLive
- Specified by:
setRegionTimeToLive
in interfaceExpiringRegionFactoryBean<K,
V>
-
setScope
-
getScope
-
setShortcut
Configures theRegion
with the givenRegionShortcut
.- Parameters:
shortcut
-RegionShortcut
used to configure pre-defined defaults for theRegion
.- See Also:
-
getShortcut
Returns the configuredRegionShortcut
.- Returns:
- the configured
RegionShortcut
. - See Also:
-
setStatisticsEnabled
-
getStatisticsEnabled
-
isStatisticsEnabled
public boolean isStatisticsEnabled() -
resolveStatisticsEnabled
protected boolean resolveStatisticsEnabled() -
setValueConstraint
-
start
public void start() -
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
stop
public void stop() -
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-