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 Summary
Modifier and TypeMethodDescription<T extends ObjectStore<? extends Serializable>>
TcreateObjectStore(String name, ObjectStoreSettings settings) Creates and returns a newObjectStore, configured according to the state of thesettingsobject.voiddisposeStore(String name) Clears the object store of the givennameand releases all resources associated to it, including memory, storage, etc.<T extends ObjectStore<? extends Serializable>>
TgetObjectStore(String name) Returns anObjectStorepreviously defined through thecreateObjectStore(String, ObjectStoreSettings)method.<T extends ObjectStore<? extends Serializable>>
TgetOrCreateObjectStore(String name, ObjectStoreSettings settings) Returns theObjectStoreofnameif it has already been defined.
-
Method Details
-
getObjectStore
Returns anObjectStorepreviously defined through thecreateObjectStore(String, ObjectStoreSettings)method.If the
namedoesn't match with a store previously created through that method, or if the matching store was disposed throughdisposeStore(String), then this method will throwNoSuchElementException.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 newObjectStore, configured according to the state of thesettingsobject.If is
getObjectStore(String)after this method with an equivalentname, 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
namefor which an ObjectStore has already been created, it will throwIllegalArgumentException, if thesettingsof the two objects differ.- Type Parameters:
T- the generic type of the items in the store- Parameters:
name- the name of the object storesettings- 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 theObjectStoreofnameif it has already been defined. Otherwise, it delegates intocreateObjectStore(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 storesettings- the object store configuration- Returns:
- an
ObjectStore
-
disposeStore
Clears the object store of the givennameand 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 aNoSuchElementExceptionwill be thrown.- Parameters:
name- the name of theObjectStoreto be disposed.- Throws:
org.mule.runtime.api.store.ObjectStoreException
-