Module org.mule.sdk.api
Package org.mule.sdk.api.store
Interface ObjectStore<T extends Serializable>
- Type Parameters:
T- the generic type of the objects to be stored
A generic object key value store
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionallKeys()voidclear()Removes all items of this store without disposing it, meaning that after performing a clear(), you should still be able perform other operations.voidclose()Close the underlying store.booleanCheck whether this store already contains a value for the givenkeybooleanvoidopen()Open the underlying store.Remove the object with the givenkey* Retrieve the object stored under the givenkeyvoidStore the given Object.
-
Method Details
-
contains
Check whether this store already contains a value for the givenkey- Parameters:
key- the identifier of the object to check- Returns:
trueif the key is stored orfalseno value was stored for the key.- Throws:
org.mule.runtime.api.store.ObjectStoreException- if the given key isnull.org.mule.runtime.api.store.ObjectStoreNotAvailableException- if any implementation-specific error occured, e.g. when the store is not available
-
store
Store the given Object.- Parameters:
key- the identifier forvaluevalue- the Object to store withkey- Throws:
org.mule.runtime.api.store.ObjectStoreException- if the given key cannot be stored or isnull.org.mule.runtime.api.store.ObjectStoreNotAvailableException- if the store is not available or any other implementation-specific error occured.org.mule.runtime.api.store.ObjectAlreadyExistsException- if an attempt is made to store an object for a key that already has an object associated.
-
retrieve
* Retrieve the object stored under the givenkey- Parameters:
key- the identifier of the object to retrieve.- Returns:
- the object associated with the given key. If no object for the given key was found this method throws an
ObjectDoesNotExistException. - Throws:
org.mule.runtime.api.store.ObjectStoreException- if the given key isnull.org.mule.runtime.api.store.ObjectStoreNotAvailableException- if the store is not available or any other implementation-specific error occured.org.mule.runtime.api.store.ObjectDoesNotExistException- if no value for the given key was previously stored.
-
remove
Remove the object with the givenkey- Parameters:
key- the identifier of the object to remove.- Returns:
- the object that was previously stored for the given key
- Throws:
org.mule.runtime.api.store.ObjectStoreException- if the given key isnullor if the store is not available or any other implementation-specific error occuredorg.mule.runtime.api.store.ObjectDoesNotExistException- if no value for the given key was previously stored.
-
isPersistent
boolean isPersistent()- Returns:
- Whether
thisstore is persistent or not
-
clear
void clear() throws org.mule.runtime.api.store.ObjectStoreExceptionRemoves all items of this store without disposing it, meaning that after performing a clear(), you should still be able perform other operations. Implementations of this method have to remove all items in the fastest way possible. No assumptions should be made regarding thread safeness. If the store implementation is thread-safe, then this method should also be. If the implementation does not guarantee thread-safeness, then you shouldn't expect that from this method either.- Throws:
org.mule.runtime.api.store.ObjectStoreException- if the operation fails
-
open
void open() throws org.mule.runtime.api.store.ObjectStoreExceptionOpen the underlying store.- Throws:
org.mule.runtime.api.store.ObjectStoreException- if an exception occurred while opening the underlying store.
-
close
void close() throws org.mule.runtime.api.store.ObjectStoreExceptionClose the underlying store.- Throws:
org.mule.runtime.api.store.ObjectStoreException- if an exception occurred while closing the underlying store.
-
allKeys
- Returns:
- list containing all keys that this object store currently holds values for.
- Throws:
org.mule.runtime.api.store.ObjectStoreException- if an exception occurred while collecting the list of all keys.
-
retrieveAll
- Returns:
- All the key-value pairs that this object store currently holds
- Throws:
org.mule.runtime.api.store.ObjectStoreException- if an exception occurred while collecting the values
-