public class LocalDocumentStore extends Object implements DocumentStore
DocumentStore which always uses the local cache to store/retrieve data and which provides some
additional methods for exposing local cache information.| Modifier and Type | Class and Description |
|---|---|
protected static class |
LocalDocumentStore.DistributedOperation |
static class |
LocalDocumentStore.DocumentOperation
An operation upon a persisted document.
|
static class |
LocalDocumentStore.DocumentOperationResults |
| Constructor and Description |
|---|
LocalDocumentStore(SchematicDb database)
Creates a new local store with the given database
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(String key)
Determine whether the database contains an entry with the supplied key.
|
String |
createExternalProjection(String projectedNodeKey,
String sourceName,
String externalPath,
String alias)
Creates an external projection from the federated node with the given key, towards the external node from the given path,
from a source.
|
SchematicEntry |
get(String key)
Get the entry with the supplied key.
|
Document |
getChildReference(String parentKey,
String childKey)
Returns a document representing a single child reference from the supplied parent to the supplied child.
|
Document |
getChildrenBlock(String key)
Returns a document representing a block of children, that has the given key.
|
ExternalBinaryValue |
getExternalBinary(String sourceName,
String id)
Retrieves a binary value which has the given id and which is not stored by ModeShape.
|
String |
getLocalSourceKey()
Returns the value of the local repository source key.
|
org.infinispan.Cache<String,SchematicEntry> |
localCache()
Returns the local Infinispan cache.
|
LocalDocumentStore |
localStore()
Returns a local store instance which will use the local Infinispan cache to store/retrieve information.
|
String |
newDocumentKey(String parentKey,
Name documentName,
Name documentPrimaryType)
Generates a new key which will be assigned to a new child document when it is being added to its parent.
|
LocalDocumentStore.DocumentOperationResults |
performOnEachDocument(LocalDocumentStore.DocumentOperation operation)
Perform the supplied operation on each stored document that is accessible within this process.
|
boolean |
prepareDocumentsForUpdate(Collection<String> keys)
Prepare to update all of the documents with the given keys.
|
void |
put(Document entryDocument)
Store the supplied document in the local db
|
void |
put(String key,
Document document)
Store the supplied document and metadata at the given key.
|
SchematicEntry |
putIfAbsent(String key,
Document document)
Store the supplied document and metadata at the given key.
|
boolean |
remove(String key)
Remove the existing document at the given key.
|
void |
replace(String key,
Document document)
Replace the existing document and metadata at the given key with the document that is supplied.
|
void |
setLocalSourceKey(String sourceKey)
Sets the value of the local repository source key.
|
SchematicEntry |
storeDocument(String key,
Document document)
Store the supplied document at the given key.
|
TransactionManager |
transactionManager()
Returns a transaction manager instance which can be used to manage transactions for this document store.
|
void |
updateDocument(String key,
Document document,
SessionNode sessionNode)
Updates the content of the document at the given key with the given document.
|
boolean |
updatesRequirePreparing()
Return whether
DocumentStore.prepareDocumentsForUpdate(Collection) should be called before updating the documents. |
XAResource |
xaResource()
Returns a resource used in distributed transactions
|
public LocalDocumentStore(SchematicDb database)
database - a SchematicDb instance which must be non-null.public boolean containsKey(String key)
DocumentStorecontainsKey in interface DocumentStorekey - the key or identifier for the documentpublic SchematicEntry get(String key)
DocumentStoreget in interface DocumentStorekey - the key or identifier for the documentpublic SchematicEntry storeDocument(String key, Document document)
DocumentStorestoreDocument in interface DocumentStorekey - the key or identifier for the documentdocument - the document that is to be storedpublic void updateDocument(String key, Document document, SessionNode sessionNode)
DocumentStoreupdateDocument in interface DocumentStorekey - the key or identifier for the documentdocument - the content with which the existing document should be updatedsessionNode - the SessionNode instance which contains the changes that caused the updatepublic String newDocumentKey(String parentKey, Name documentName, Name documentPrimaryType)
DocumentStorenewDocumentKey in interface DocumentStoreparentKey - a non-null String, the key of the existing parentdocumentName - non-null Name, the name of the new child document.documentPrimaryType - non-null Name, the name of the primary type of the new child documentString which will be assigned as key to the new child, or null indicating that no preferred key
is to be used. If this is the case, the repository will assign a random key.public SchematicEntry putIfAbsent(String key, Document document)
key - the key or identifier for the documentdocument - the document that is to be storedSchematicDb.putIfAbsent(String, org.infinispan.schematic.document.Document,
org.infinispan.schematic.document.Document)public void put(String key, Document document)
key - the key or identifier for the documentdocument - the document that is to be storedSchematicDb.put(String, org.infinispan.schematic.document.Document, org.infinispan.schematic.document.Document)public void put(Document entryDocument)
entryDocument - the document that contains the metadata document, content document, and keypublic void replace(String key, Document document)
key - the key or identifier for the documentdocument - the new document that is to replace the existing document (or binary content) the replacementpublic boolean remove(String key)
DocumentStoreremove in interface DocumentStorekey - the key or identifier for the documentpublic boolean prepareDocumentsForUpdate(Collection<String> keys)
DocumentStoreprepareDocumentsForUpdate in interface DocumentStorekeys - the set of keys identifying the documents that are to be updated via
DocumentStore.updateDocument(String, Document, SessionNode) or via DocumentStore.get(String) followed by
SchematicEntry.editDocumentContent().public boolean updatesRequirePreparing()
DocumentStoreDocumentStore.prepareDocumentsForUpdate(Collection) should be called before updating the documents.updatesRequirePreparing in interface DocumentStoreDocumentStore.prepareDocumentsForUpdate(Collection) should be called, or false otherwisepublic LocalDocumentStore localStore()
DocumentStorelocalStore in interface DocumentStoreLocalDocumentStore instance.public TransactionManager transactionManager()
DocumentStoretransactionManager in interface DocumentStoreTransactionManager instance, never null.public XAResource xaResource()
DocumentStorexaResource in interface DocumentStoreinstance or nullpublic void setLocalSourceKey(String sourceKey)
DocumentStoresetLocalSourceKey in interface DocumentStoresourceKey - a non-null stringpublic String getLocalSourceKey()
DocumentStoregetLocalSourceKey in interface DocumentStorenon-null stringpublic String createExternalProjection(String projectedNodeKey, String sourceName, String externalPath, String alias)
DocumentStorecreateExternalProjection in interface DocumentStoreprojectedNodeKey - a non-null string, the key of the federated node which will contain the projectionsourceName - a non-null string, the name of an external source.externalPath - a non-null string, representing a path towards a node from the sourcealias - a non-null string, representing the alias given to the projection.non-null string representing the node key of the external node located at externalPath.public Document getChildrenBlock(String key)
DocumentStoregetChildrenBlock in interface DocumentStorekey - a non-null String the key of the blockDocument with children and possibly a pointer to the next block, or null if there isn't a
block with such a key.public Document getChildReference(String parentKey, String childKey)
DocumentStoregetChildReference in interface DocumentStoreparentKey - the key for the parentchildKey - the key for the childpublic org.infinispan.Cache<String,SchematicEntry> localCache()
non-null Cache instance.public ExternalBinaryValue getExternalBinary(String sourceName, String id)
DocumentStoregetExternalBinary in interface DocumentStoresourceName - a non-null String; the name of an external sourceid - a non-null String; the id of an external binary valueExternalBinaryValue implementation or nullpublic LocalDocumentStore.DocumentOperationResults performOnEachDocument(LocalDocumentStore.DocumentOperation operation) throws InterruptedException, ExecutionException
Generally, this method executes the operation upon all documents. If there is an error processing a single document, that document is skipped and the execution will continue with the next document(s). However, if there is an exception with the transactions or another system failure, this method will terminate with an exception.
operation - the operation to be performedInterruptedException - if the process is interruptedExecutionException - if there is an error while getting executing the operationCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.