Class SimpleMetadataStore
java.lang.Object
org.springframework.integration.metadata.SimpleMetadataStore
- All Implemented Interfaces:
ConcurrentMetadataStore,MetadataStore
public class SimpleMetadataStore extends java.lang.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
-
Constructor Summary
Constructors Constructor Description SimpleMetadataStore()Instantiate aSimpleMetadataStoreusing an in-memoryConcurrentHashMap.SimpleMetadataStore(java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String> metadata)Instantiate aSimpleMetadataStoreusing the providedConcurrentMap. -
Method Summary
Modifier and Type Method Description java.lang.Stringget(java.lang.String key)Reads a value for the given key from this MetadataStore.voidput(java.lang.String key, java.lang.String value)Writes a key value pair to this MetadataStore.java.lang.StringputIfAbsent(java.lang.String key, java.lang.String value)Atomically insert the key into the store.java.lang.Stringremove(java.lang.String key)Remove a value for the given key from this MetadataStore.booleanreplace(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.
-
Constructor Details
-
SimpleMetadataStore
public SimpleMetadataStore()Instantiate aSimpleMetadataStoreusing an in-memoryConcurrentHashMap. -
SimpleMetadataStore
public SimpleMetadataStore(java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String> metadata)Instantiate aSimpleMetadataStoreusing the providedConcurrentMap. The implementation may be a distributed map provided by projects such as Redis and Hazelcast.- Parameters:
metadata- theConcurrentMapinstance for metadata.- Since:
- 4.1.4
-
-
Method Details
-
put
public void put(java.lang.String key, java.lang.String value)Description copied from interface:MetadataStoreWrites a key value pair to this MetadataStore.- Specified by:
putin interfaceMetadataStore- Parameters:
key- The key.value- The value.
-
get
public java.lang.String get(java.lang.String key)Description copied from interface:MetadataStoreReads a value for the given key from this MetadataStore.- Specified by:
getin interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The value.
-
remove
public java.lang.String remove(java.lang.String key)Description copied from interface:MetadataStoreRemove a value for the given key from this MetadataStore.- Specified by:
removein 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:ConcurrentMetadataStoreAtomically insert the key into the store.- Specified by:
putIfAbsentin 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:ConcurrentMetadataStoreAtomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replacein interfaceConcurrentMetadataStore- Parameters:
key- The key.oldValue- The old value.newValue- The new value.- Returns:
- true if successful.
-