public interface GenericDataStoreDAO
Data access object that can be used by other component to store arbitrary (small amounts of) data.
Once initialized, this DAO publishes a
GenericDataStoreDAOInitializedEvent
in the application context, which
can be used by other beans that need to use this DAO.
Modifier and Type | Interface and Description |
---|---|
static class |
GenericDataStoreDAO.DataItem
Value object representing a single data item.
|
Modifier and Type | Method and Description |
---|---|
ListenableFuture<Pair<Boolean,String>> |
createItem(UUID componentId,
String key,
String value)
Create a data item for the specified component and key if no such item
exists yet.
|
ListenableFuture<Void> |
createOrUpdateItem(UUID componentId,
String key,
String value)
Creates a data item or updates it if an item with the specified key
already exists for the specified component.
|
ListenableFuture<Void> |
deleteAllItems(UUID componentId)
Removes all data items for the specified component.
|
ListenableFuture<Void> |
deleteItem(UUID componentId,
String key)
Removes the item with the specified key from collection of data items for
the specified component.
|
ListenableFuture<? extends Iterable<? extends GenericDataStoreDAO.DataItem>> |
getAllItems(UUID componentId)
Returns all data items for the specified component.
|
ListenableFuture<? extends GenericDataStoreDAO.DataItem> |
getItem(UUID componentId,
String key)
Returns the data item with the specified key for the specified component.
|
boolean |
isInitialized()
Tells whether this DAO has finished initialization and is ready to be
used.
|
ListenableFuture<Pair<Boolean,String>> |
updateItem(UUID componentId,
String key,
String oldValue,
String newValue)
Updates the data item with the specified key and component.
|
ListenableFuture<Pair<Boolean,String>> createItem(UUID componentId, String key, String value)
createOrUpdateItem(UUID, String, String)
, so code should prefer
the latter method unless it has to ensure that it does not overwrite an
existing value. The operation is performed in an asynchronous way so that
it will not block for network communication. The result of the operation
can be checked through the returned future.componentId
- ID of the component for which the data item should be created.key
- key identifying the data item within the component.value
- value of the data item.true
, the item was created, if false
,
an item with the specified key already existed for the specified
component. In this case, the string is the value of the existing
item. In case of failure, the future's get()
method
will throw an exception.ListenableFuture<Void> createOrUpdateItem(UUID componentId, String key, String value)
createItem(UUID, String, String)
and
updateItem(UUID, String, String, String)
. The operation is
performed in an asynchronous way so that it will not block for network
communication. The result of the operation can be checked through the
returned future.componentId
- ID of the component for which the data item should be created
or updated.key
- key identifying the data item within the component.value
- value of the data item.get()
method will throw an exception.ListenableFuture<Void> deleteAllItems(UUID componentId)
componentId
- ID of the component for which all data items should be
removed.get()
method will throw an exception.ListenableFuture<Void> deleteItem(UUID componentId, String key)
componentId
- ID of the component that owns the data item.key
- key identifying the data item within the component.get()
method will throw an exception.ListenableFuture<? extends Iterable<? extends GenericDataStoreDAO.DataItem>> getAllItems(UUID componentId)
Returns all data items for the specified component. The operation is performed in an asynchronous way so that it will not block for network communication. The result of the operation can be checked through the returned future.
The iterable returned by the future is only safe for iterating once. Subsequent requests to create an iterator might result in the new iterator only returning the elements that have not been returned by a previously created iterator yet. Besides, the iterator might block while iterating, waiting for additional elements to arrive from the network.
componentId
- ID of the component for which all data items should be
retrieved.get()
method will throw an exception.ListenableFuture<? extends GenericDataStoreDAO.DataItem> getItem(UUID componentId, String key)
componentId
- ID of the component that owns the data item.key
- key identifying the data item within the component.get
method returns null
. In
case of failure, the future's get()
method will
throw an exception.boolean isInitialized()
true
, operations might
still fail because of transient problems.true
if this DAO has been initialized and is ready
to be used, false
if initialization has not
completed yet.ListenableFuture<Pair<Boolean,String>> updateItem(UUID componentId, String key, String oldValue, String newValue)
oldValue
. This type of atomic operation incurs an additional
overhead. Code that does not mind overwriting a different value should
prefer the createOrUpdateItem(UUID, String, String)
method. The
operation is performed in an asynchronous way so that it will not block
for network communication. The result of the operation can be checked
through the returned future.componentId
- ID of the component that owns the data item.key
- key identifying the data item within the component.oldValue
- old value of the data item that must be matched for the update
operation to proceed.newValue
- new value that the data item shall be updated with if the old
value matches.true
, the item was updated, if false
,
the item's value did not match the specified
oldValue
or the item did not exist. If the flag is
false
, the string is the current value of the
existing item or null
if no item with the specified
component ID and key exists. In case of failure, the future's
get()
method will throw an exception.Copyright © 2011–2017 aquenos GmbH. All rights reserved.