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
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,FactoryBean<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,
,V>> InitializingBean
,ApplicationListener<SnapshotApplicationEvent<K,
V>>
public class SnapshotServiceFactoryBean<K,V>
extends AbstractFactoryBeanSupport<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,V>>
implements InitializingBean, DisposableBean, 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
- Author:
- John Blum
- See Also:
-
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 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
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
(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> wrap
(RegionSnapshotService<K, V> regionSnapshotService) 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 interfaceInitializingBean
- 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(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(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
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:
-
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:
-
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:
-
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:
-
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.- Specified by:
getObject
in interfaceFactoryBean<K>
- Returns:
- the GemFire Snapshot Service created by this FactoryBean.
- Throws:
Exception
- if the GemFire Snapshot Service failed to be created.- See Also:
-
getObjectType
Gets the type of Snapshot Service created by this FactoryBean.- Specified by:
getObjectType
in interfaceFactoryBean<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 interfaceFactoryBean<K>
- Overrides:
isSingleton
in classAbstractFactoryBeanSupport<SnapshotServiceFactoryBean.SnapshotServiceAdapter<K,
V>> - Returns:
- true.
- See Also:
-
destroy
Performs an export of the GemFire Cache or Region if configured.- Specified by:
destroy
in interfaceDisposableBean
- 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 interfaceApplicationListener<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:
-