public class RelationalDb extends Object implements SchematicDb
SchematicDb implementation which stores data in Relational databases.| Modifier | Constructor and Description |
|---|---|
protected |
RelationalDb(Document configDoc) |
| Modifier and Type | Method and Description |
|---|---|
protected RelationalDbConfig |
config() |
protected Connection |
connectionForActiveTx() |
boolean |
containsKey(String key)
Determine whether the database contains an entry with the supplied key.
|
protected DataSourceManager |
dsManager() |
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.
|
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 Connection |
newConnection(boolean autoCommit,
boolean readonly) |
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.
|
protected void |
releaseConnectionForActiveTx() |
boolean |
remove(String key)
Remove the existing document at the given key.
|
void |
removeAll()
Removes all the entries from this DB.
|
protected <R> R |
runWithConnection(org.modeshape.persistence.relational.RelationalDb.SQLFunction<R> function,
boolean readonly) |
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.
|
String |
toString() |
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, wait, wait, waitgetEntry, put, putEntryprotected RelationalDb(Document configDoc)
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 void start()
Lifecyclepublic void stop()
Lifecyclepublic 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 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 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 boolean containsKey(String key)
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)
containsKey in interface SchematicDbkey - the key or identifier for the documentpublic 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 nullprotected <R> R runWithConnection(org.modeshape.persistence.relational.RelationalDb.SQLFunction<R> function,
boolean readonly)
protected Connection connectionForActiveTx()
protected RelationalDbConfig config()
protected DataSourceManager dsManager()
protected void releaseConnectionForActiveTx()
protected Connection newConnection(boolean autoCommit, boolean readonly)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.