Interface ObjectStore<T extends Serializable>

Type Parameters:
T - the generic type of the objects to be stored

@MinMuleVersion("4.5.0") public interface ObjectStore<T extends Serializable>
A generic object key value store
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    Removes all items of this store without disposing it, meaning that after performing a clear(), you should still be able perform other operations.
    void
    Close the underlying store.
    boolean
    Check whether this store already contains a value for the given key
    boolean
     
    void
    Open the underlying store.
    Remove the object with the given key
    * Retrieve the object stored under the given key
     
    void
    store(String key, T value)
    Store the given Object.
  • Method Details

    • contains

      boolean contains(String key) throws org.mule.runtime.api.store.ObjectStoreException
      Check whether this store already contains a value for the given key
      Parameters:
      key - the identifier of the object to check
      Returns:
      true if the key is stored or false no value was stored for the key.
      Throws:
      org.mule.runtime.api.store.ObjectStoreException - if the given key is null.
      org.mule.runtime.api.store.ObjectStoreNotAvailableException - if any implementation-specific error occured, e.g. when the store is not available
    • store

      void store(String key, T value) throws org.mule.runtime.api.store.ObjectStoreException
      Store the given Object.
      Parameters:
      key - the identifier for value
      value - the Object to store with key
      Throws:
      org.mule.runtime.api.store.ObjectStoreException - if the given key cannot be stored or is null.
      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

      T retrieve(String key) throws org.mule.runtime.api.store.ObjectStoreException
      * Retrieve the object stored under the given key
      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 is null.
      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

      T remove(String key) throws org.mule.runtime.api.store.ObjectStoreException
      Remove the object with the given key
      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 is null or 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.
    • isPersistent

      boolean isPersistent()
      Returns:
      Whether this store is persistent or not
    • clear

      void clear() throws org.mule.runtime.api.store.ObjectStoreException
      Removes 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.ObjectStoreException
      Open 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.ObjectStoreException
      Close the underlying store.
      Throws:
      org.mule.runtime.api.store.ObjectStoreException - if an exception occurred while closing the underlying store.
    • allKeys

      List<String> allKeys() throws org.mule.runtime.api.store.ObjectStoreException
      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

      Map<String,T> retrieveAll() throws org.mule.runtime.api.store.ObjectStoreException
      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