public class MongoDbMetadataStore extends java.lang.Object implements ConcurrentMetadataStore
ConcurrentMetadataStore.
Use this MetadataStore to
achieve meta-data persistence shared across application instances and
restarts.| Constructor and Description |
|---|
MongoDbMetadataStore(org.springframework.data.mongodb.MongoDbFactory factory)
Configure the MongoDbMetadataStore by provided
MongoDbFactory and
default collection name - DEFAULT_COLLECTION_NAME. |
MongoDbMetadataStore(org.springframework.data.mongodb.MongoDbFactory factory,
java.lang.String collectionName)
Configure the MongoDbMetadataStore by provided
MongoDbFactory and
collection name |
MongoDbMetadataStore(org.springframework.data.mongodb.core.MongoTemplate template)
Configure the MongoDbMetadataStore by provided
MongoTemplate and
default collection name - DEFAULT_COLLECTION_NAME. |
MongoDbMetadataStore(org.springframework.data.mongodb.core.MongoTemplate template,
java.lang.String collectionName)
Configure the MongoDbMetadataStore by provided
MongoTemplate and collection name. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
get(java.lang.String key)
Get the
value for the provided key performing findOne MongoDB operation. |
void |
put(java.lang.String key,
java.lang.String value)
|
java.lang.String |
putIfAbsent(java.lang.String key,
java.lang.String value)
If the specified key is not already associated with a value, associate it with the given value.
|
java.lang.String |
remove(java.lang.String key)
Remove the metadata entry for the provided
key and return its value, if any,
using findAndRemove MongoDB operation. |
boolean |
replace(java.lang.String key,
java.lang.String oldValue,
java.lang.String newValue)
Replace an existing metadata entry
value with a new one. |
public MongoDbMetadataStore(org.springframework.data.mongodb.MongoDbFactory factory)
MongoDbFactory and
default collection name - DEFAULT_COLLECTION_NAME.factory - the mongodb factorypublic MongoDbMetadataStore(org.springframework.data.mongodb.MongoDbFactory factory,
java.lang.String collectionName)
MongoDbFactory and
collection namefactory - the mongodb factorycollectionName - the collection name where it persists the datapublic MongoDbMetadataStore(org.springframework.data.mongodb.core.MongoTemplate template)
MongoTemplate and
default collection name - DEFAULT_COLLECTION_NAME.template - the mongodb templatepublic MongoDbMetadataStore(org.springframework.data.mongodb.core.MongoTemplate template,
java.lang.String collectionName)
MongoTemplate and collection name.template - the mongodb templatecollectionName - the collection name where it persists the datapublic void put(java.lang.String key,
java.lang.String value)
value under provided key to the configured
collectionName.
If a document does not exist with the specified key, the method performs an insert.
If a document exists with the specified key, the method performs an update.
put in interface MetadataStorekey - the metadata entry keyvalue - the metadata entry valueMongoTemplate.execute(String, org.springframework.data.mongodb.core.CollectionCallback),
DBCollection.save(com.mongodb.DBObject)public java.lang.String get(java.lang.String key)
value for the provided key performing findOne MongoDB operation.get in interface MetadataStorekey - the metadata entry keyMongoTemplate.findOne(Query, Class, String)public java.lang.String remove(java.lang.String key)
key and return its value, if any,
using findAndRemove MongoDB operation.remove in interface MetadataStorekey - the metadata entry keyMongoTemplate.findAndRemove(Query, Class, String)public java.lang.String putIfAbsent(java.lang.String key,
java.lang.String value)
if (!map.containsKey(key))
return map.put(key, value);
else
return map.get(key);
except that the action is performed atomically.
putIfAbsent in interface ConcurrentMetadataStorekey - the metadata entry keyvalue - the metadata entry value to storeConcurrentMap.putIfAbsent(Object, Object)public boolean replace(java.lang.String key,
java.lang.String oldValue,
java.lang.String newValue)
value with a new one. Otherwise does nothing.
Performs updateFirst if a document for the provided key and oldValue
exists in the collectionName.replace in interface ConcurrentMetadataStorekey - the metadata entry keyoldValue - the metadata entry old value to replacenewValue - the metadata entry new value to puttrue if replace was successful, false otherwise.MongoTemplate.updateFirst(Query, Update, String)