public interface SessionCache extends NodeCache
Modifier and Type | Interface and Description |
---|---|
static interface |
SessionCache.PreSave
The definition of a callback that can be implemented and passed to
save(SessionCache, PreSave) and
save(Set, SessionCache, PreSave) , allowing the caller to receive a hook where they can interrogate
each of the changed nodes and perform additional logic prior to the actual persisting of the changes. |
static interface |
SessionCache.SaveContext
The context of a save operation, created during each call to
save() and passed to the
PreSave#processBeforeLocking(MutableCachedNode, SaveContext) or
PreSave#processAfterLocking(MutableCachedNode, SaveContext)
invocations. |
Modifier and Type | Method and Description |
---|---|
void |
addContextData(String key,
String value)
Adds a [key,value] data pair for this cache's context
|
void |
checkForTransaction()
Check whether this session is running within a transaction.
|
void |
clear(CachedNode node)
Clears all changes in the cache that are at or below the supplied node.
|
NodeKey |
createNodeKey()
Create a new node key for the current source and workspace.
|
NodeKey |
createNodeKey(String sourceName,
String identifier)
Create a new node key for the current source and workspace.
|
NodeKey |
createNodeKeyWithIdentifier(String identifier)
Create a new node key for the current source and workspace.
|
NodeKey |
createNodeKeyWithSource(String sourceName)
Create a new node key for the current source and workspace.
|
void |
destroy(NodeKey key)
Destroy the subgraph with the supplied node as the top node in the subgraph.
|
Set<NodeKey> |
getChangedNodeKeys()
Returns a set with the
NodeKey s of the transient nodes from this cache. |
Set<NodeKey> |
getChangedNodeKeysAtOrBelow(CachedNode node)
Returns a set with the
NodeKey s of the transient nodes from this cache which are at or below the path of the given
node |
ExecutionContext |
getContext()
Get the context for this session.
|
Set<NodeKey> |
getNodeKeysAtAndBelow(NodeKey nodeKey)
Returns a set with the
NodeKey s of the existing nodes (persistent not transient & new) which are at and below the
path of the node with the given key. |
WorkspaceCache |
getWorkspace()
Get the cache the reflects the workspace content, without any of the transient, unsaved changes of this session.
|
boolean |
hasChanges()
Determine whether this session has any transient, unsaved changes.
|
boolean |
isDestroyed(NodeKey key)
Return whether the node with the supplied key has been removed using this session but not yet persisted.
|
boolean |
isReadOnly()
Returns whether this cache is readonly.
|
MutableCachedNode |
mutable(NodeKey key)
Get a mutable form of the node with the supplied key.
|
void |
save()
Saves all changes made within this session.
|
void |
save(SessionCache otherSession,
SessionCache.PreSave preSaveOperation)
Saves all changes made within this session and the supplied session, using a single transaction for both.
|
void |
save(Set<NodeKey> toBeSaved,
SessionCache otherSession,
SessionCache.PreSave preSaveOperation)
Saves all of this session's changes that were made at or below the specified path.
|
SessionCache |
unwrap()
Unwrap this instance.
|
clear, getAllNodeKeys, getAllNodeKeysAtAndBelow, getNode, getRootKey
getNode
ExecutionContext getContext()
void addContextData(String key, String value)
key
- the key for the context datavalue
- the value for the context datavoid save()
LockFailureException
- if a requested lock could not be madeDocumentAlreadyExistsException
- if this session attempts to create a document that has the same key as an existing
documentDocumentNotFoundException
- if one of the modified documents was removed by another sessionDocumentStoreException
- if there is a problem storing or retrieving a documentvoid save(Set<NodeKey> toBeSaved, SessionCache otherSession, SessionCache.PreSave preSaveOperation)
Item.save()
.toBeSaved
- the set of keys identifying the nodes whose changes should be saved; may not be nullotherSession
- another session whose changes should be saved with this session's changes; may not be nullpreSaveOperation
- the set of operations to run against the new and changed nodes prior to saving; may be nullLockFailureException
- if a requested lock could not be madeDocumentAlreadyExistsException
- if this session attempts to create a document that has the same key as an existing
documentDocumentNotFoundException
- if one of the modified documents was removed by another sessionDocumentStoreException
- if there is a problem storing or retrieving a documentvoid save(SessionCache otherSession, SessionCache.PreSave preSaveOperation)
otherSession
- another session whose changes should be saved with this session's changes; may not be nullpreSaveOperation
- the set of operations to run against the new and changed nodes prior to saving; may be nullLockFailureException
- if a requested lock could not be madeDocumentAlreadyExistsException
- if this session attempts to create a document that has the same key as an existing
documentDocumentNotFoundException
- if one of the modified documents was removed by another sessionDocumentStoreException
- if there is a problem storing or retrieving a documentboolean hasChanges()
Set<NodeKey> getChangedNodeKeys()
NodeKey
s of the transient nodes from this cache. Please note that there may be nodes which
have been removed by another session.Set
with the changed keys, or an empty set if
hasChanges()
is false. The returned set is a mutable copy of the
underlying set.Set<NodeKey> getChangedNodeKeysAtOrBelow(CachedNode node) throws NodeNotFoundException
NodeKey
s of the transient nodes from this cache which are at or below the path of the given
nodenode
- a non-null CachedNode
instanceNodeNotFoundException
- if any of changes registered in this cache refer to nodes that have been removed in the
meantime.Set<NodeKey> getNodeKeysAtAndBelow(NodeKey nodeKey)
NodeKey
s of the existing nodes (persistent not transient & new) which are at and below the
path of the node with the given key. Note that this method will attempt to load each nodenodeKey
- the key of node which will be considered the root nodevoid clear(CachedNode node)
node
- the node at or below which all changes should be cleared; may not be nullWorkspaceCache getWorkspace()
MutableCachedNode mutable(NodeKey key) throws NodeNotFoundException, UnsupportedOperationException
key
- the key for the node; may not be nullNodeNotFoundException
- if there is no existing node in the session cache or workspace cacheUnsupportedOperationException
- if this session is marked for read-only operationsvoid destroy(NodeKey key) throws NodeNotFoundException, UnsupportedOperationException
removed from its parent node
.key
- the key for the top node in the subgraph; may not be nullNodeNotFoundException
- if there is no existing node in the session cache or workspace cacheUnsupportedOperationException
- if this session is marked for read-only operationsboolean isDestroyed(NodeKey key)
key
- the for the node; may not be nullNodeKey createNodeKey()
NodeKey createNodeKeyWithIdentifier(String identifier)
identifier
- the unique identifier for the key; if null, a generated identifier will be usedboolean isReadOnly()
NodeKey createNodeKeyWithSource(String sourceName)
sourceName
- the name (not key) for the source; if null, the key for the current source is usedNodeKey createNodeKey(String sourceName, String identifier)
sourceName
- the name (not key) for the source; if null, the key for the current source is usedidentifier
- the unique identifier for the key; if null, a generated identifier will be usedvoid checkForTransaction()
SessionCache unwrap()
NodeCache
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.