Class SimpleMetadataStore
java.lang.Object
org.springframework.integration.metadata.SimpleMetadataStore
- All Implemented Interfaces:
ConcurrentMetadataStore
,MetadataStore
public class SimpleMetadataStore extends Object implements ConcurrentMetadataStore
Simple implementation of
MetadataStore
that uses a ConcurrentMap
for the data store.
The metadata may not be persisted across application restarts, if the provided ConcurrentMap
is an in-memory instance.- Since:
- 2.0
- Author:
- Mark Fisher, Gary Russell, Artem Bilan
-
Constructor Summary
Constructors Constructor Description SimpleMetadataStore()
Instantiate aSimpleMetadataStore
using an in-memoryConcurrentHashMap
.SimpleMetadataStore(ConcurrentMap<String,String> metadata)
Instantiate aSimpleMetadataStore
using the providedConcurrentMap
. -
Method Summary
Modifier and Type Method Description String
get(String key)
Reads a value for the given key from this MetadataStore.void
put(String key, String value)
Writes a key value pair to this MetadataStore.String
putIfAbsent(String key, String value)
Atomically insert the key into the store.String
remove(String key)
Remove a value for the given key from this MetadataStore.boolean
replace(String key, String oldValue, String newValue)
Atomically replace the value for the key in the store if the old value matches the oldValue argument.
-
Constructor Details
-
SimpleMetadataStore
public SimpleMetadataStore()Instantiate aSimpleMetadataStore
using an in-memoryConcurrentHashMap
. -
SimpleMetadataStore
Instantiate aSimpleMetadataStore
using the providedConcurrentMap
. The implementation may be a distributed map provided by projects such as Redis and Hazelcast.- Parameters:
metadata
- theConcurrentMap
instance for metadata.- Since:
- 4.1.4
-
-
Method Details
-
put
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
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
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
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
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.
-