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, waitcontainsKey, getEntry, lockForWriting, put, putEntrylockForWritingprotected 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 SchematicDbString, never nullpublic List<String> keys()
SchematicDbIf 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 SchematicDbList instance, never nullpublic Document get(String key)
SchematicDbSchematicEntry 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 SchematicDbkey - the key or identifier for the documentpublic List<SchematicEntry> load(Collection<String> keys)
SchematicDbIf 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) and either use that (if it exists) or the persisted information.
load in interface SchematicDbkeys - an Collection of keys; never nullList of entries; never nullpublic void put(String key, SchematicEntry entry)
SchematicDbput in interface SchematicDbkey - a schematic entry id, never nullentry - a SchematicEntry instance, never nullpublic EditableDocument editContent(String key, boolean createIfMissing)
SchematicDbeditContent in interface SchematicDbkey - 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)
SchematicDbDepending 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 SchematicDbkey - the key or identifier for the contentcontent - the content that is to be storedpublic boolean remove(String key)
SchematicDbremove in interface SchematicDbkey - the key or identifier for the documenttrue if the removal was successful, false otherwisepublic void removeAll()
SchematicDbremoveAll in interface SchematicDbpublic void start()
Lifecyclepublic void stop()
Lifecyclepublic void txStarted(String id)
TransactionListenertxStarted in interface TransactionListenerid - the tx id; never nullpublic void txCommitted(String id)
TransactionListenertxCommitted in interface TransactionListenerid - the tx id; never nullpublic void txRolledback(String id)
TransactionListenertxRolledback in interface TransactionListenerid - the tx id; never nullCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.