public class FileDb extends Object implements SchematicDb
SchematicDb
implementation which uses H2's MV Store to store data in memory or on disk.Modifier and Type | Method and Description |
---|---|
EditableDocument |
editContent(String key,
boolean createIfMissing)
Get an editor for the content of the given entry with the supplied key.
|
Document |
get(String key)
Get the document with the supplied key.
|
String |
id()
Returns a unique identifier for this schematic DB.
|
protected static FileDb |
inMemory(boolean compress) |
List<String> |
keys()
Returns a set over all the keys present in the DB.
|
List<SchematicEntry> |
load(Collection<String> keys)
Loads a set of documents from the DB returning the corresponding schematic entries.
|
protected static FileDb |
onDisk(boolean compress,
String path) |
void |
put(String key,
SchematicEntry entry)
Stores the supplied schematic entry under the given key.
|
SchematicEntry |
putIfAbsent(String key,
Document content)
Store the supplied content at the given key.
|
boolean |
remove(String key)
Remove the existing document at the given key.
|
void |
removeAll()
Removes all the entries from this DB.
|
void |
start()
Announces that the repository is about to start using this DB.
|
void |
stop()
Announces that the repository is shutting down and will stop using this DB.
|
protected org.h2.mvstore.db.TransactionStore.TransactionMap<String,Document> |
transactionalContent(boolean failIfMissing) |
void |
txCommitted(String id)
Called by ModeShape once an existing transaction has been successfully committed.
|
void |
txRolledback(String id)
Called to indicate tha a transaction has been rolled back.
|
void |
txStarted(String id)
Called by ModeShape once a ModeShape transaction has been created.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
containsKey, getEntry, put, putEntry
protected static FileDb inMemory(boolean compress)
public String id()
SchematicDb
Implementations should make sure that the provided id is unique per storage instance.
In other words, if two SchematicDb
instances of the same type store data in two different places, they should
return a different id.
id
in interface SchematicDb
String
, never null
public List<String> keys()
SchematicDb
If this method is called within an existing transaction, it should take into account the transient transactional context (i.e. any local but not yet committed changes)
keys
in interface SchematicDb
List
instance, never null
public Document get(String key)
SchematicDb
SchematicEntry
document if one exists.
If this method is called within an existing transaction, it should take into account the transient transactional context (i.e. any local but not yet committed changes)
get
in interface SchematicDb
key
- the key or identifier for the documentpublic List<SchematicEntry> load(Collection<String> keys)
SchematicDb
If this method is called within an existing transaction, it should not take into account the transient transactional context (i.e. any local but not yet committed changes) and should always return the latest persisted information.
load
in interface SchematicDb
keys
- an Collection
of keys; never null
List
of entries
; never null
public void put(String key, SchematicEntry entry)
SchematicDb
put
in interface SchematicDb
key
- a schematic entry id, never null
entry
- a SchematicEntry
instance, never null
public EditableDocument editContent(String key, boolean createIfMissing)
SchematicDb
editContent
in interface SchematicDb
key
- the key or identifier for the documentcreateIfMissing
- true if a new entry should be created and added to the database if an existing entry does not existpublic SchematicEntry putIfAbsent(String key, Document content)
SchematicDb
Depending on the actual implementation, this may or may not be thread-safe. ModeShape never assumes this is thread-safe when calling it.
putIfAbsent
in interface SchematicDb
key
- the key or identifier for the contentcontent
- the content that is to be storedpublic boolean remove(String key)
SchematicDb
remove
in interface SchematicDb
key
- the key or identifier for the documenttrue
if the removal was successful, false
otherwisepublic void removeAll()
SchematicDb
removeAll
in interface SchematicDb
public void start()
Lifecycle
public void stop()
Lifecycle
public void txStarted(String id)
TransactionListener
txStarted
in interface TransactionListener
id
- the tx id; never nullpublic void txCommitted(String id)
TransactionListener
txCommitted
in interface TransactionListener
id
- the tx id; never nullpublic void txRolledback(String id)
TransactionListener
txRolledback
in interface TransactionListener
id
- the tx id; never nullCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.