Interface ObjectStoreManager


@MinMuleVersion("4.5.0") public interface ObjectStoreManager
Creates and manages ObjectStore instances.

Any component in need to use an ObjectStore should create it through an implementation of this interface.

This manager works under the concept of "Base Object Stores". This means that all created Object Stores are actually partitions on these base stores. This manager is in charge of creating and handling such partitions and exposing them as stand alone stores. There're two base object stores, one for the in memory ones and another for the transient ones.

All ObjectStore instances created through an instance of this interface, should also be destroyed through the same instance using the disposeStore(String) method. This does not mean that all stores should necessarily be disposed. If you want that store to endure through time, then you should not dispose it.

Implementations are required to be thread-safe.

Since:
1.0
  • Method Details

    • getObjectStore

      <T extends ObjectStore<? extends Serializable>> T getObjectStore(String name)
      Returns an ObjectStore previously defined through the createObjectStore(String, ObjectStoreSettings) method.

      If the name doesn't match with a store previously created through that method, or if the matching store was disposed through disposeStore(String), then this method will throw NoSuchElementException.

      The returned store has to be already open. Invokers should not have to call ObjectStore.open() on the returned instance.

      Otherwise, invoking this method several times using equivalent names will always result in the same instance being returned.

      Type Parameters:
      T - the generic type of the items in the store
      Parameters:
      name - the name of the object store
      Returns:
      an ObjectStore
      Throws:
      NoSuchElementException - if the store doesn't exist or has been disposed
    • createObjectStore

      <T extends ObjectStore<? extends Serializable>> T createObjectStore(String name, ObjectStoreSettings settings)
      Creates and returns a new ObjectStore, configured according to the state of the settings object.

      If is getObjectStore(String) after this method with an equivalent name, it will return the same instance as this method.

      The returned store has to be already open. Invokers should not have to call ObjectStore.open() on the returned instance.

      If this method is invoked with a name for which an ObjectStore has already been created, it will throw IllegalArgumentException, if the settings of the two objects differ.

      Type Parameters:
      T - the generic type of the items in the store
      Parameters:
      name - the name of the object store
      settings - the object store configuration
      Returns:
      a new ObjectStore
      Throws:
      IllegalArgumentException - if the store already exists
    • getOrCreateObjectStore

      <T extends ObjectStore<? extends Serializable>> T getOrCreateObjectStore(String name, ObjectStoreSettings settings)
      Returns the ObjectStore of name if it has already been defined. Otherwise, it delegates into createObjectStore(String, ObjectStoreSettings) to create it.

      Notice that if the store does actually exist, then the returned store might not actually match the provided settings

      Type Parameters:
      T - the generic type of the items in the store
      Parameters:
      name - the name of the object store
      settings - the object store configuration
      Returns:
      an ObjectStore
    • disposeStore

      void disposeStore(String name) throws org.mule.runtime.api.store.ObjectStoreException
      Clears the object store of the given name and releases all resources associated to it, including memory, storage, etc.

      The referenced store needs to have been created through the createObjectStore(String, ObjectStoreSettings) method or a NoSuchElementException will be thrown.

      Parameters:
      name - the name of the ObjectStore to be disposed.
      Throws:
      org.mule.runtime.api.store.ObjectStoreException