org.modeshape.jcr.cache.document

## Class ReadOnlySessionCache

- java.lang.Object
- - org.modeshape.jcr.cache.document.AbstractSessionCache
  - - org.modeshape.jcr.cache.document.ReadOnlySessionCache

- All Implemented Interfaces:
    DocumentCache, NodeCache, SessionCache

      @ThreadSafe
      public class ReadOnlySessionCache
      extends AbstractSessionCache

  A read-only `SessionCache` implementation.

- - ### 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`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReadOnlySessionCache(ExecutionContext context, WorkspaceCache workspaceCache, SessionEnvironment sessionContext)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 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
    `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 Logger` | `logger()`
    `SessionNode` | `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.
    `String` | `toString()`

    - ### Methods inherited from class org.modeshape.jcr.cache.document.AbstractSessionCache

      `addContextData, checkForTransaction, clear, clear, completeTransaction, createNodeKey, createNodeKey, createNodeKeyWithIdentifier, createNodeKeyWithSource, generateIdentifier, getAllNodeKeys, getAllNodeKeysAtAndBelow, getContext, getNode, getNode, getNodeKeysAtAndBelow, getRootKey, getWorkspace, unwrap, workspaceCache, workspaceName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ReadOnlySessionCache

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

  - ### Method Detail

    - #### logger

          protected Logger logger()

      Specified by:
        `logger` in class `AbstractSessionCache`

    - #### 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

    - #### 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 node)

      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:
        `node` - a non-null `CachedNode` instance
      Returns:
        a Set of nodekeys, or an empty set if no nodes are found

    - #### doClear

          protected void doClear()

      Specified by:
        `doClear` in class `AbstractSessionCache`

    - #### doClear

          protected void doClear(CachedNode node)

      Specified by:
        `doClear` in class `AbstractSessionCache`

    - #### save

          public void save()

      Description copied from interface: `SessionCache`
      Saves all changes made within this session.

    - #### save

          public void save(SessionCache otherSession,
                  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:
        `otherSession` - 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(Set<NodeKey> toBeSaved,
                  SessionCache otherSession,
                  SessionCache.PreSave preSaveOperation)

      Description copied from interface: `SessionCache`
      Saves all of this session's changes that were made at or below the specified path. Note that this is not terribly efficient, but is done to implement the deprecated `Item.save()`.
      Parameters:
        `toBeSaved` - the set of keys identifying the nodes whose changes should be saved; may not be null
        `otherSession` - 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

    - #### 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

    - #### 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`

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