Class PropertiesPersistingMetadataStore
java.lang.Object
org.springframework.integration.metadata.PropertiesPersistingMetadataStore
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,ConcurrentMetadataStore
,MetadataStore
public class PropertiesPersistingMetadataStore extends java.lang.Object implements ConcurrentMetadataStore, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, java.io.Closeable, java.io.Flushable
Properties file-based implementation of
MetadataStore
. To avoid conflicts
each instance should be constructed with the unique key from which unique file name
will be generated.
By default, the properties file will be
'java.io.tmpdir' + "/spring-integration/metadata-store.properties"
,
but the directory and filename are settable.- Since:
- 2.0
-
Constructor Summary
Constructors Constructor Description PropertiesPersistingMetadataStore()
-
Method Summary
Modifier and Type Method Description void
afterPropertiesSet()
void
close()
void
destroy()
void
flush()
java.lang.String
get(java.lang.String key)
Reads a value for the given key from this MetadataStore.void
put(java.lang.String key, java.lang.String value)
Writes a key value pair to this MetadataStore.java.lang.String
putIfAbsent(java.lang.String key, java.lang.String value)
Atomically insert the key into the store.java.lang.String
remove(java.lang.String key)
Remove a value for the given key from this MetadataStore.boolean
replace(java.lang.String key, java.lang.String oldValue, java.lang.String newValue)
Atomically replace the value for the key in the store if the old value matches the oldValue argument.void
setBaseDirectory(java.lang.String baseDirectory)
Set the location for the properties file.void
setFileName(java.lang.String fileName)
Set the name of the properties file insetBaseDirectory(String)
.
-
Constructor Details
-
PropertiesPersistingMetadataStore
public PropertiesPersistingMetadataStore()
-
-
Method Details
-
setBaseDirectory
public void setBaseDirectory(java.lang.String baseDirectory)Set the location for the properties file. Defaults to'java.io.tmpdir' + "/spring-integration/"
.- Parameters:
baseDirectory
- the directory.
-
setFileName
public void setFileName(java.lang.String fileName)Set the name of the properties file insetBaseDirectory(String)
. Defaults tometadata-store.properties
,- Parameters:
fileName
- the properties file name.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
put
public void put(java.lang.String key, java.lang.String value)Description copied from interface:MetadataStore
Writes a key value pair to this MetadataStore.- Specified by:
put
in interfaceMetadataStore
- Parameters:
key
- The key.value
- The value.
-
get
public java.lang.String get(java.lang.String key)Description copied from interface:MetadataStore
Reads a value for the given key from this MetadataStore.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- The key.- Returns:
- The value.
-
remove
public java.lang.String remove(java.lang.String key)Description copied from interface:MetadataStore
Remove a value for the given key from this MetadataStore.- Specified by:
remove
in interfaceMetadataStore
- Parameters:
key
- The key.- Returns:
- The previous value associated with key, or null if there was no mapping for key.
-
putIfAbsent
public java.lang.String putIfAbsent(java.lang.String key, java.lang.String value)Description copied from interface:ConcurrentMetadataStore
Atomically insert the key into the store.- Specified by:
putIfAbsent
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.value
- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
public boolean replace(java.lang.String key, java.lang.String oldValue, java.lang.String newValue)Description copied from interface:ConcurrentMetadataStore
Atomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replace
in interfaceConcurrentMetadataStore
- Parameters:
key
- The key.oldValue
- The old value.newValue
- The new value.- Returns:
- true if successful.
-
close
public void close()- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
flush
public void flush()- Specified by:
flush
in interfacejava.io.Flushable
-
destroy
public void destroy()- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-