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
ConstructorsConstructorDescriptionMongoDbMetadataStore(MongoTemplate template) Configure the MongoDbMetadataStore by providedMongoTemplateand default collection name -DEFAULT_COLLECTION_NAME.MongoDbMetadataStore(MongoTemplate template, String collectionName) Configure the MongoDbMetadataStore by providedMongoTemplateand collection name.MongoDbMetadataStore(MongoDatabaseFactory factory) Configure the MongoDbMetadataStore by providedMongoDatabaseFactoryand default collection name -DEFAULT_COLLECTION_NAME.MongoDbMetadataStore(MongoDatabaseFactory factory, String collectionName) Configure the MongoDbMetadataStore by providedMongoDatabaseFactoryand collection name. -
Method Summary
Modifier and TypeMethodDescriptionGet thevaluefor the providedkeyperformingfindOneMongoDB operation.voidStore a metadatavalueunder providedkeyto 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 providedkeyand return itsvalue, if any, usingfindAndRemoveMongoDB operation.booleanReplace an existing metadata entryvaluewith a new one.
-
Constructor Details
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoDatabaseFactoryand default collection name -DEFAULT_COLLECTION_NAME.- Parameters:
factory- the mongodb factory
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoDatabaseFactoryand collection name.- Parameters:
factory- the mongodb factorycollectionName- the collection name where it persists the data
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoTemplateand default collection name -DEFAULT_COLLECTION_NAME.- Parameters:
template- the mongodb template
-
MongoDbMetadataStore
Configure the MongoDbMetadataStore by providedMongoTemplateand collection name.- Parameters:
template- the mongodb templatecollectionName- the collection name where it persists the data
-
-
Method Details
-
put
Store a metadatavalueunder providedkeyto 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:
putin interfaceMetadataStore- Parameters:
key- the metadata entry keyvalue- the metadata entry value- See Also:
-
get
Get thevaluefor the providedkeyperformingfindOneMongoDB operation.- Specified by:
getin 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 providedkeyand return itsvalue, if any, usingfindAndRemoveMongoDB operation.- Specified by:
removein 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 to
except that the action is performed atomically.if (!map.containsKey(key)) return map.put(key, value); else return map.get(key);- Specified by:
putIfAbsentin 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 entryvaluewith a new one. Otherwise does nothing. PerformsupdateFirstif a document for the providedkeyandoldValueexists in thecollectionName.- Specified by:
replacein interfaceConcurrentMetadataStore- Parameters:
key- the metadata entry keyoldValue- the metadata entry old value to replacenewValue- the metadata entry new value to put- Returns:
trueif replace was successful,falseotherwise.- See Also:
-