Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr.cache.document
Class WritableSessionCache

    java.lang.Object
      org.modeshape.jcr.cache.document.AbstractSessionCache
          org.modeshape.jcr.cache.document.WritableSessionCache

All Implemented Interfaces:
  DocumentCache, NodeCache, SessionCache

    @ThreadSafe
    public class WritableSessionCache

extends AbstractSessionCache

A writable `SessionCache` implementation capable of making transient changes and saving them.

Nested Class Summary

Nested classes/interfaces inherited from class org.modeshape.jcr.cache.document.AbstractSessionCache
`AbstractSessionCache.BasicSaveContext`

Nested classes/interfaces inherited from interface org.modeshape.jcr.cache.SessionCache
`SessionCache.PreSave, SessionCache.SaveContext`

Field Summary

Fields inherited from class org.modeshape.jcr.cache.document.AbstractSessionCache
`workspaceCache`

Constructor Summary
`WritableSessionCache(ExecutionContext context, WorkspaceCache workspaceCache, SessionEnvironment sessionContext)` Create a new SessionCache that can be used for making changes to the workspace.

Method Summary
`protected SessionNode` | `add(SessionNode newNode)`
`protected void` | `assertInSession(SessionNode node)`
`void` | `clear()` Clears all changes in the cache.
`void` | `clear(CachedNode node)` Clears all changes in the cache that are at or below the supplied node.
`protected void` | `clearModifiedState()`
`protected void` | `clearModifiedState(Iterable<NodeKey> savedNodesInOrder)`
`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.
`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.
`SessionNode` | `mutable(NodeKey key)` Get a mutable form of the node with the supplied key.
`protected ChangeSet` | `persistChanges(Iterable<NodeKey> changedNodesInOrder, SessionEnvironment.Monitor monitor)` Persist the changes within an already-established transaction.
`void` | `save()` Persist the changes within a transaction.
`void` | `save(CachedNode node, SessionCache other, SessionCache.PreSave preSaveOperation)` This method saves the changes made by both sessions within a single 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.
`String` | `toString()`

Methods inherited from class org.modeshape.jcr.cache.document.AbstractSessionCache
`addContextData, createNodeKey, createNodeKey, createNodeKeyWithIdentifier, createNodeKeyWithSource, generateIdentifier, getAllNodeKeys, getAllNodeKeysAtAndBelow, getContext, getNode, getNodeKeysAtAndBelow, getRootKey, getWorkspace, workspaceCache`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### WritableSessionCache

    public WritableSessionCache(ExecutionContext context,
                                WorkspaceCache workspaceCache,
                                SessionEnvironment sessionContext)

  Create a new SessionCache that can be used for making changes to the workspace.

  Parameters:
    `context` - the execution context; may not be null
    `workspaceCache` - the (shared) workspace cache; may not be null
    `sessionContext` - the context for the session; may not be null

Method Detail

### assertInSession

    protected final void assertInSession(SessionNode node)

### getNode

    public CachedNode getNode(NodeKey key)

  Description copied from interface: `NodeCache`
  Get the cached representation of the node with the supplied node key.

  Specified by:
    `getNode` in interface `NodeCache`
  Overrides:
    `getNode` in class `AbstractSessionCache`
  Parameters:
    `key` - the node key; may not be null
  Returns:
    the cached node, or null if there is no such node

### mutable

    public SessionNode mutable(NodeKey key)

  Description copied from interface: `SessionCache`
  Get a mutable form of the node with the supplied key. If this session already has a mutable node in its cache, that existing mutable node is returned; otherwise, a new mutable node is created and added to the session's cache.

  Specified by:
    `mutable` in interface `SessionCache`
  Specified by:
    `mutable` in class `AbstractSessionCache`
  Parameters:
    `key` - the key for the node; may not be null
  Returns:
    the mutable child node

### isReadOnly

    public boolean isReadOnly()

  Description copied from interface: `SessionCache`
  Returns whether this cache is readonly.

  Returns:
    true if this cache is readonly, or false otherwise

### clear

    public void clear()

  Description copied from interface: `NodeCache`
  Clears all changes in the cache.

### clear

    public void clear(CachedNode node)

  Description copied from interface: `SessionCache`
  Clears all changes in the cache that are at or below the supplied node.

  Parameters:
    `node` - the node at or below which all changes should be cleared; may not be null

### getChangedNodeKeys

    public Set<NodeKey> getChangedNodeKeys()

  Description copied from interface: `SessionCache`
  Returns a set with the `NodeKey`s of the transient nodes from this cache. Please note that there may be nodes which have been removed by another session.

  Returns:
    a `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.

### getChangedNodeKeysAtOrBelow

    public Set<NodeKey> getChangedNodeKeysAtOrBelow(CachedNode srcNode)

  Description copied from interface: `SessionCache`
  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

  Parameters:
    `srcNode` - a non-null `CachedNode` instance
  Returns:
    a Set of nodekeys, or an empty set if no nodes are found

### hasChanges

    public boolean hasChanges()

  Description copied from interface: `SessionCache`
  Determine whether this session has any transient, unsaved changes.

  Returns:
    true if there are unsaved changes, or false otherwise

### save

    public void save()

  Persist the changes within a transaction.

  Throws:
    `LockFailureException` - if a requested lock could not be made
    `DocumentAlreadyExistsException` - if this session attempts to create a document that has the same key as an existing document
    `DocumentNotFoundException` - if one of the modified documents was removed by another session

### save

    protected void save(SessionCache.PreSave preSaveOperation)

### clearState

    protected void clearState()

### clearState

    protected void clearState(Iterable<NodeKey> savedNodesInOrder)

### clearModifiedState

    protected void clearModifiedState()

### clearModifiedState

    protected void clearModifiedState(Iterable<NodeKey> savedNodesInOrder)

### save

    public void save(SessionCache other,
                     SessionCache.PreSave preSaveOperation)

  Description copied from interface: `SessionCache`
  Saves all changes made within this session and the supplied session, using a single transaction for both.

  Parameters:
    `other` - another session whose changes should be saved with this session's changes; may not be null
    `preSaveOperation` - the set of operations to run against the new and changed nodes prior to saving; may be null

### save

    public void save(CachedNode node,
                     SessionCache other,
                     SessionCache.PreSave preSaveOperation)

  This method saves the changes made by both sessions within a single transaction. Note that this must be used with caution, as this method attempts to get write locks on both sessions, meaning they cannot be concurrently used elsewhere (otherwise deadlocks might occur).

  Parameters:
    `other` - the other session
    `node` - the node at or below which all changes should be saved; may not be null
    `preSaveOperation` - the set of operations to run against the new and changed nodes prior to saving; may be null
  Throws:
    `LockFailureException` - if a requested lock could not be made
    `DocumentAlreadyExistsException` - if this session attempts to create a document that has the same key as an existing document
    `DocumentNotFoundException` - if one of the modified documents was removed by another session

### persistChanges

    protected ChangeSet persistChanges(Iterable<NodeKey> changedNodesInOrder,
                                       SessionEnvironment.Monitor monitor)

  Persist the changes within an already-established transaction.

  Parameters:
    `changedNodesInOrder` - the nodes that are to be persisted; may not be null
    `monitor` - the monitor for these changes; may be null if not needed
  Returns:
    the ChangeSet encapsulating the changes that were made
  Throws:
    `LockFailureException` - if a requested lock could not be made
    `DocumentAlreadyExistsException` - if this session attempts to create a document that has the same key as an existing document
    `DocumentNotFoundException` - if one of the modified documents was removed by another session

### add

    protected SessionNode add(SessionNode newNode)

### destroy

    public void destroy(NodeKey key)

  Description copied from interface: `SessionCache`
  Destroy the subgraph with the supplied node as the top node in the subgraph. This method should be called after the node is already `removed from its parent node`.

  Parameters:
    `key` - the key for the top node in the subgraph; may not be null

### isDestroyed

    public boolean isDestroyed(NodeKey key)

  Description copied from interface: `SessionCache`
  Return whether the node with the supplied key has been removed using this session but not yet persisted.

  Parameters:
    `key` - the for the node; may not be null
  Returns:
    true if the node was removed in this session, or false otherwise

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.