@ThreadSafe public class WritableSessionCache extends AbstractSessionCache
SessionCache
implementation capable of making transient changes and saving them.AbstractSessionCache.BasicSaveContext
SessionCache.PreSave, SessionCache.SaveContext
Constructor and Description |
---|
WritableSessionCache(ExecutionContext context,
WorkspaceCache workspaceCache,
TransactionalWorkspaceCaches txWorkspaceCaches,
RepositoryEnvironment repositoryEnvironment)
Create a new SessionCache that can be used for making changes to the workspace.
|
Modifier and Type | Method and Description |
---|---|
protected SessionNode |
add(SessionNode newNode) |
protected void |
addBinaryReference(NodeKey nodeKey,
BinaryKey... binaryKeys) |
protected void |
assertInSession(SessionNode node) |
void |
checkForTransaction()
Signal that this session cache should check for an existing transaction and use the appropriate workspace cache.
|
protected void |
clearState() |
protected void |
clearState(Iterable<NodeKey> savedNodesInOrder) |
void |
destroy(NodeKey key)
Destroy the subgraph with the supplied node as the top node in the subgraph.
|
protected void |
doClear() |
protected void |
doClear(CachedNode node) |
Set<NodeKey> |
getChangedNodeKeys()
Returns a set with the
NodeKey s of the transient nodes from this cache. |
Set<NodeKey> |
getChangedNodeKeysAtOrBelow(CachedNode srcNode)
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 |
CachedNode |
getNode(NodeKey key)
Get the cached representation of the node with the supplied node key.
|
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.
|
protected void |
logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder,
Map<NodeKey,SessionNode> firstNodes,
Iterable<NodeKey> secondNodesInOrder,
Map<NodeKey,SessionNode> secondNodes) |
protected Logger |
logger() |
SessionNode |
mutable(NodeKey key)
Get a mutable form of the node with the supplied key.
|
protected NodeTypes |
nodeTypes() |
protected ChangeSet |
persistChanges(Iterable<NodeKey> changedNodesInOrder)
Persist the changes within an already-established transaction.
|
void |
save()
Persist the changes within a transaction.
|
protected void |
save(SessionCache.PreSave preSaveOperation) |
void |
save(SessionCache other,
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 other,
SessionCache.PreSave preSaveOperation)
This method saves the changes made by both sessions within a single transaction.
|
String |
toString() |
addContextData, clear, clear, createNodeKey, createNodeKey, createNodeKeyWithIdentifier, createNodeKeyWithSource, generateIdentifier, getAllNodeKeys, getAllNodeKeysAtAndBelow, getContext, getNode, getNodeKeysAtAndBelow, getRootKey, getWorkspace, unwrap, workspaceCache, workspaceName
protected static final Logger LOGGER
public WritableSessionCache(ExecutionContext context, WorkspaceCache workspaceCache, TransactionalWorkspaceCaches txWorkspaceCaches, RepositoryEnvironment repositoryEnvironment)
context
- the execution context; may not be nullworkspaceCache
- the (shared) workspace cache; may not be nulltxWorkspaceCaches
- a TransactionalWorkspaceCaches
instance, never null
repositoryEnvironment
- the context for the session; may not be nullprotected final void assertInSession(SessionNode node)
protected NodeTypes nodeTypes()
protected Logger logger()
logger
in class AbstractSessionCache
public CachedNode getNode(NodeKey key)
CachedNodeSupplier
getNode
in interface CachedNodeSupplier
getNode
in class AbstractSessionCache
key
- the node key; may not be nullpublic SessionNode mutable(NodeKey key)
SessionCache
mutable
in interface SessionCache
mutable
in class AbstractSessionCache
key
- the key for the node; may not be nullpublic boolean isReadOnly()
SessionCache
protected void doClear()
doClear
in class AbstractSessionCache
protected void doClear(CachedNode node)
doClear
in class AbstractSessionCache
public Set<NodeKey> getChangedNodeKeys()
SessionCache
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
SessionCache.hasChanges()
is false. The returned set is a mutable copy of the
underlying set.public Set<NodeKey> getChangedNodeKeysAtOrBelow(CachedNode srcNode)
SessionCache
NodeKey
s of the transient nodes from this cache which are at or below the path of the given
nodesrcNode
- a non-null CachedNode
instancepublic boolean hasChanges()
SessionCache
public void checkForTransaction()
protected final void logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder, Map<NodeKey,SessionNode> firstNodes, Iterable<NodeKey> secondNodesInOrder, Map<NodeKey,SessionNode> secondNodes)
public void 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 sessionprotected void save(SessionCache.PreSave preSaveOperation)
protected void clearState()
public void save(SessionCache other, SessionCache.PreSave preSaveOperation)
SessionCache
other
- 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 nullpublic void save(Set<NodeKey> toBeSaved, SessionCache other, SessionCache.PreSave preSaveOperation)
toBeSaved
- the set of keys identifying the nodes whose changes should be saved; may not be nullother
- the other sessionpreSaveOperation
- the pre-save operationLockFailureException
- 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 documentprotected ChangeSet persistChanges(Iterable<NodeKey> changedNodesInOrder)
changedNodesInOrder
- the nodes that are to be persisted; may not 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 sessionprotected SessionNode add(SessionNode newNode)
public void destroy(NodeKey key)
SessionCache
removed from its parent node
.key
- the key for the top node in the subgraph; may not be nullpublic boolean isDestroyed(NodeKey key)
SessionCache
key
- the for the node; may not be nullCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.