Class MongoDbMetadataStore
java.lang.Object
org.springframework.integration.mongodb.metadata.MongoDbMetadataStore
- All Implemented Interfaces:
ConcurrentMetadataStore
,MetadataStore
MongoDbMetadataStore implementation of
ConcurrentMetadataStore
.
Use this MetadataStore
to
achieve meta-data persistence shared across application instances and
restarts.- Since:
- 4.2
- Author:
- Senthil Arumugam, Samiraj Panneer Selvam, Artem Bilan, Gary Russell
-
Constructor Summary
ConstructorDescriptionMongoDbMetadataStore
(MongoTemplate template) Configure the MongoDbMetadataStore by providedMongoTemplate
and default collection name -DEFAULT_COLLECTION_NAME
.MongoDbMetadataStore
(MongoTemplate template, String collectionName) Configure the MongoDbMetadataStore by providedMongoTemplate
and collection name.MongoDbMetadataStore
(MongoDatabaseFactory factory) Configure the MongoDbMetadataStore by providedMongoDatabaseFactory
and default collection name -DEFAULT_COLLECTION_NAME
.MongoDbMetadataStore
(MongoDatabaseFactory factory, String collectionName) Configure the MongoDbMetadataStore by providedMongoDatabaseFactory
and collection name. -
Method Summary
Modifier and TypeMethodDescriptionGet thevalue
for the providedkey
performingfindOne
MongoDB operation.void
Store a metadatavalue
under providedkey
to the configuredcollectionName
.putIfAbsent
(String key, String value) If the specified key is not already associated with a value, associate it with the given value.Remove the metadata entry for the providedkey
and return itsvalue
, if any, usingfindAndRemove
MongoDB operation.boolean
Replace an existing metadata entryvalue
with a new one.
-
Constructor Details
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoDatabaseFactory
and default collection name -DEFAULT_COLLECTION_NAME
.- Parameters:
factory
- the mongodb factory
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoDatabaseFactory
and collection name.- Parameters:
factory
- the mongodb factorycollectionName
- the collection name where it persists the data
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoTemplate
and default collection name -DEFAULT_COLLECTION_NAME
.- Parameters:
template
- the mongodb template
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoTemplate
and collection name.- Parameters:
template
- the mongodb templatecollectionName
- the collection name where it persists the data
-
-
Method Details
-
put
Store a metadatavalue
under providedkey
to the configuredcollectionName
.If a document does not exist with the specified
key
, the method performs aninsert
. If a document exists with the specifiedkey
, the method performs anupdate
.- Specified by:
put
in interfaceMetadataStore
- Parameters:
key
- the metadata entry keyvalue
- the metadata entry value- See Also:
-
get
Get thevalue
for the providedkey
performingfindOne
MongoDB operation.- Specified by:
get
in interfaceMetadataStore
- Parameters:
key
- the metadata entry key- Returns:
- the metadata entry value or null if doesn't exist.
- See Also:
-
remove
Remove the metadata entry for the providedkey
and return itsvalue
, if any, usingfindAndRemove
MongoDB operation.- Specified by:
remove
in interfaceMetadataStore
- Parameters:
key
- the metadata entry key- Returns:
- the metadata entry value or null if doesn't exist.
- See Also:
-
putIfAbsent
If the specified key is not already associated with a value, associate it with the given value. This is equivalent toif (!map.containsKey(key)) return map.put(key, value); else return map.get(key);
- Specified by:
putIfAbsent
in interfaceConcurrentMetadataStore
- Parameters:
key
- the metadata entry keyvalue
- the metadata entry value to store- Returns:
- null if successful, the old value otherwise.
- See Also:
-
replace
Replace an existing metadata entryvalue
with a new one. Otherwise does nothing. PerformsupdateFirst
if a document for the providedkey
andoldValue
exists in thecollectionName
.- Specified by:
replace
in interfaceConcurrentMetadataStore
- Parameters:
key
- the metadata entry keyoldValue
- the metadata entry old value to replacenewValue
- the metadata entry new value to put- Returns:
true
if replace was successful,false
otherwise.- See Also:
-