public interface ObjectStoreManager
ObjectStore
instances.
Any component in need to use an ObjectStore
should created 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.
The reason why this manager operates in this way is to allow other services to override the default object store
implementations. A Core Extension can use the CustomizationService
to override those base stores using
the BASE_IN_MEMORY_OBJECT_STORE_KEY
and BASE_PERSISTENT_OBJECT_STORE_KEY
keys. In addition to that,
this manager also has the concept of a default partition, which is the one for general use, for cases in which there's
no actual need to define a particular store. The default partition is unbounded and persistent.
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.
Modifier and Type | Field and Description |
---|---|
static String |
BASE_IN_MEMORY_OBJECT_STORE_KEY
The key of the base in memory object store.
|
static String |
BASE_PERSISTENT_OBJECT_STORE_KEY
The key of the base persistent object store.
|
static String |
DEFAULT_PARTITION_NAME
The name of the default partition
|
Modifier and Type | Method and Description |
---|---|
<T extends ObjectStore<? extends Serializable>> |
createObjectStore(String name,
ObjectStoreSettings settings)
Creates and returns a new
ObjectStore , configured according to the state of the settings object. |
void |
disposeStore(String name)
Clears the object store of the given
name and releases all resources associated to it, including memory,
storage, etc. |
default <T extends ObjectStore<? extends Serializable>> |
getDefaultPartition()
Returns the default partition, which is unbounded and persistent
|
<T extends ObjectStore<? extends Serializable>> |
getObjectStore(String name)
Returns an
ObjectStore previously defined through the createObjectStore(String, ObjectStoreSettings)
method. |
<T extends ObjectStore<? extends Serializable>> |
getOrCreateObjectStore(String name,
ObjectStoreSettings settings)
Returns the
ObjectStore of name if it has already been defined. |
static final String BASE_IN_MEMORY_OBJECT_STORE_KEY
static final String BASE_PERSISTENT_OBJECT_STORE_KEY
static final String DEFAULT_PARTITION_NAME
<T extends ObjectStore<? extends Serializable>> T getObjectStore(String name)
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.
T
- the generic type of the items in the storename
- the name of the object storeObjectStore
NoSuchElementException
- if the store doesn't exist or has been disposed<T extends ObjectStore<? extends Serializable>> T createObjectStore(String name, ObjectStoreSettings settings)
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.
T
- the generic type of the items in the storename
- the name of the object storesettings
- the object store configurationObjectStore
IllegalArgumentException
- if the store already exists<T extends ObjectStore<? extends Serializable>> T getOrCreateObjectStore(String name, ObjectStoreSettings settings)
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
T
- the generic type of the items in the storename
- the name of the object storesettings
- the object store configurationObjectStore
default <T extends ObjectStore<? extends Serializable>> T getDefaultPartition()
T
- the generic type of the items in the storeObjectStore
void disposeStore(String name) throws ObjectStoreException
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.
name
- the name of the ObjectStore
to be disposed.ObjectStoreException
Copyright © 2018. All rights reserved.