Class SnapshotServiceFactoryBean<K,V>
java.lang.Object
org.springframework.data.gemfire.support.AbstractFactoryBeanSupport<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,V>>
org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBean<K,V>
- All Implemented Interfaces:
EventListener
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.FactoryBean<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,
,V>> org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationListener<SnapshotApplicationEvent<K,
V>>
public class SnapshotServiceFactoryBean<K,V>
extends AbstractFactoryBeanSupport<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,V>>
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationListener<SnapshotApplicationEvent<K,V>>
The SnapshotServiceFactoryBean class is a Spring FactoryBean used to configure and create an instance
of an appropriate GemFire Snapshot Service to perform data import and exports. A CacheSnapshotService is created
if the Region is not specified, otherwise a RegionSnapshotService is used based on the configured Region.
- Since:
- 1.7.0
- See Also:
-
DisposableBean
FactoryBean
InitializingBean
ApplicationListener
SnapshotServiceFactoryBean.SnapshotServiceAdapter
CacheSnapshotService
RegionSnapshotService
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
The ArchiveFileFilter class is a Java FileFilter implementation accepting any File that is either a JAR file or ZIP file.protected static class
The CacheSnapshotServiceAdapter is a SnapshotServiceAdapter adapting GemFire's CacheSnapshotService.protected static class
The RegionSnapshotServiceAdapter is a SnapshotServiceAdapter adapting GemFire's RegionSnapshotService.static class
The SnapshotMetadata class encapsulates details of the GemFire Cache or Region data snapshot on either import or export.static interface
The SnapshotServiceAdapter interface is an Adapter adapting both GemFire CacheSnapshotService and RegionSnapshotService to treat them uniformly.protected static class
SnapshotServiceAdapterSupport is an abstract base class for all SnapshotServiceAdapter implementations encapsulating common reusable functionality. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final SnapshotServiceFactoryBean.SnapshotMetadata[]
Fields inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
DEFAULT_SINGLETON
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Constructs and initializes the GemFire Snapshot Service used to take a snapshot of the configured Cache or Region if initialized.create()
Constructs an appropriate instance of the SnapshotServiceAdapter based on the FactoryBean configuration.void
destroy()
Performs an export of the GemFire Cache or Region if configured.protected org.apache.geode.cache.Cache
getCache()
Gets a reference to the GemFire Cache for which the snapshot will be taken.protected SnapshotServiceFactoryBean.SnapshotMetadata<K,
V>[] Sets the meta-data (location, filter and format) used to create a snapshot from the Cache or Region data.protected SnapshotServiceFactoryBean.SnapshotMetadata<K,
V>[] Gets the meta-data (location, filter and format) used to read a data snapshot into an entire Cache or individual Region.Gets the reference to the GemFire Snapshot Service created by this FactoryBean.Class<?>
Gets the type of Snapshot Service created by this FactoryBean.Gets a reference to the GemFire Region for which the snapshot will be taken.protected boolean
Determines whether importing on initialization should be suppressed.protected boolean
isMatch
(SnapshotApplicationEvent event) Determines whether the details of the given SnapshotApplicationEvent match the criteria of this factory to trigger a GemFire Cache or Region data export.boolean
Determines this this FactoryBean creates single GemFire Snapshot Service instances.void
onApplicationEvent
(SnapshotApplicationEvent<K, V> event) Listens for SnapshotApplicationEvents triggering a GemFire Cache-wide or Region data snapshot import/export when details of the event match the criteria of this factory's constructed GemFire SnapshotService.protected SnapshotServiceFactoryBean.SnapshotMetadata<K,
V>[] Resolves the SnapshotMetadata used to perform the GemFire Cache or Region data snapshot import/export.void
setCache
(org.apache.geode.cache.Cache cache) Sets a reference to the GemFire Cache for which the snapshot will be taken.void
setExports
(SnapshotServiceFactoryBean.SnapshotMetadata<K, V>[] exports) Sets the meta-data (location, filter and format) used to create a snapshot from the Cache or Region data.void
setImports
(SnapshotServiceFactoryBean.SnapshotMetadata<K, V>[] imports) Sets the meta-data (location, filter and format) used to read a data snapshot into an entire Cache or individual Region.void
Sets a reference to the GemFire Region for which the snapshot will be taken.void
setSuppressImportOnInit
(Boolean suppressImportOnInit) Sets a boolean condition to indicate whether importing on initialization should be suppressed.wrap
(org.apache.geode.cache.snapshot.CacheSnapshotService cacheSnapshotService) Wraps the GemFire CacheSnapshotService into an appropriate Adapter to uniformly access snapshot operations on the Cache and Regions alike.protected SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,
V> Wraps GemFire's RegionSnapshotService into an appropriate Adapter to uniformly access snapshot operations on the Cache and Regions alike.Methods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLogger, getOptionalLogger, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLogger, setBeanClassLoader, setBeanFactory, setBeanName
-
Field Details
-
EMPTY_ARRAY
-
-
Constructor Details
-
SnapshotServiceFactoryBean
public SnapshotServiceFactoryBean()
-
-
Method Details
-
afterPropertiesSet
Constructs and initializes the GemFire Snapshot Service used to take a snapshot of the configured Cache or Region if initialized. In addition, this initialization method will perform the actual import.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
- if the construction and initialization of the GemFire Snapshot Service fails.- See Also:
-
create
Constructs an appropriate instance of the SnapshotServiceAdapter based on the FactoryBean configuration. If a Region has not been specified, then a GemFire Snapshot Service for the Cache is constructed, otherwise the GemFire Snapshot Service for the configured Region is used.- Returns:
- a SnapshotServiceAdapter wrapping the appropriate GemFire Snapshot Service (either Cache or Region) depending on the FactoryBean configuration.
- See Also:
-
wrap
protected SnapshotServiceFactoryBean.SnapshotServiceAdapter<Object,Object> wrap(org.apache.geode.cache.snapshot.CacheSnapshotService cacheSnapshotService) Wraps the GemFire CacheSnapshotService into an appropriate Adapter to uniformly access snapshot operations on the Cache and Regions alike.- Parameters:
cacheSnapshotService
- the GemFire CacheSnapshotService to wrap.- Returns:
- a SnapshotServiceAdapter wrapping the GemFire CacheSnapshotService.
- See Also:
-
wrap
protected SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,V> wrap(org.apache.geode.cache.snapshot.RegionSnapshotService<K, V> regionSnapshotService) Wraps GemFire's RegionSnapshotService into an appropriate Adapter to uniformly access snapshot operations on the Cache and Regions alike.- Parameters:
regionSnapshotService
- the GemFire RegionSnapshotService to wrap.- Returns:
- a SnapshotServiceAdapter wrapping the GemFire RegionSnapshotService.
- See Also:
-
setCache
public void setCache(org.apache.geode.cache.Cache cache) Sets a reference to the GemFire Cache for which the snapshot will be taken.- Parameters:
cache
- the GemFire Cache used to create an instance of CacheSnapshotService.- Throws:
IllegalArgumentException
- if the Cache reference is null.- See Also:
-
Cache
getCache()
-
getCache
protected org.apache.geode.cache.Cache getCache()Gets a reference to the GemFire Cache for which the snapshot will be taken.- Returns:
- the GemFire Cache used to create an instance of CacheSnapshotService.
- Throws:
IllegalStateException
- if the Cache argument is null.- See Also:
-
Cache
setCache(Cache)
-
setExports
Sets the meta-data (location, filter and format) used to create a snapshot from the Cache or Region data.- Parameters:
exports
- an array of snapshot meta-data used for each export.- See Also:
-
getExports
Sets the meta-data (location, filter and format) used to create a snapshot from the Cache or Region data.- Returns:
- an array of snapshot meta-data used for each export.
- See Also:
-
setImports
Sets the meta-data (location, filter and format) used to read a data snapshot into an entire Cache or individual Region.- Parameters:
imports
- an array of snapshot meta-data used for each import.- See Also:
-
getImports
Gets the meta-data (location, filter and format) used to read a data snapshot into an entire Cache or individual Region.- Returns:
- an array of snapshot meta-data used for each import.
- See Also:
-
setRegion
Sets a reference to the GemFire Region for which the snapshot will be taken.- Parameters:
region
- the GemFire Region used to create an instance of the RegionSnapshotService.- See Also:
-
Region
getRegion()
-
getRegion
Gets a reference to the GemFire Region for which the snapshot will be taken.- Returns:
- the GemFire Region used to create an instance of the RegionSnapshotService.
- See Also:
-
Region
getRegion()
-
setSuppressImportOnInit
Sets a boolean condition to indicate whether importing on initialization should be suppressed.- Parameters:
suppressImportOnInit
- a Boolean value to indicate whether importing on initialization should be suppressed.- See Also:
-
getSuppressImportOnInit
protected boolean getSuppressImportOnInit()Determines whether importing on initialization should be suppressed.- Returns:
- a boolean value indicating whether import on initialization should be suppressed.
- See Also:
-
getObject
Gets the reference to the GemFire Snapshot Service created by this FactoryBean. -
getObjectType
Gets the type of Snapshot Service created by this FactoryBean.- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<K>
- Returns:
- a Class object representing the type of Snapshot Service created by this FactoryBean.
- See Also:
-
isSingleton
public boolean isSingleton()Determines this this FactoryBean creates single GemFire Snapshot Service instances.- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<K>
- Overrides:
isSingleton
in classAbstractFactoryBeanSupport<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,
V>> - Returns:
- true.
- See Also:
-
FactoryBean.isSingleton()
-
destroy
Performs an export of the GemFire Cache or Region if configured.- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
- if the Cache/Region data export operation fails.- See Also:
-
onApplicationEvent
Listens for SnapshotApplicationEvents triggering a GemFire Cache-wide or Region data snapshot import/export when details of the event match the criteria of this factory's constructed GemFire SnapshotService.- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<K>
- Parameters:
event
- the SnapshotApplicationEvent triggering a GemFire Cache or Region data import/export.- See Also:
-
isMatch
Determines whether the details of the given SnapshotApplicationEvent match the criteria of this factory to trigger a GemFire Cache or Region data export.- Parameters:
event
- the SnapshotApplicationEvent containing details of the application requested data export.- Returns:
- a boolean value indicating whether the application requested snapshot event details match the criteria required by this factory to trigger a GemFire Cache or Region data export.
- See Also:
-
resolveSnapshotMetadata
protected SnapshotServiceFactoryBean.SnapshotMetadata<K,V>[] resolveSnapshotMetadata(SnapshotApplicationEvent<K, V> event) Resolves the SnapshotMetadata used to perform the GemFire Cache or Region data snapshot import/export. If the event contains specific SnapshotMetadata, then this is preferred over the factory's own "import" or "export" SnapshotMetadata.- Parameters:
event
- the SnapshotApplicationEvent from which to resolve the SnapshotMetadata.- Returns:
- the resolved SnapshotMetadata, either from the event or this factory's configured imports/exports.
- See Also:
-