org.modeshape.jcr.cache.document

## Class AbstractSessionCache

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

- All Implemented Interfaces:
    DocumentCache, NodeCache, SessionCache
  Direct Known Subclasses:
    ReadOnlySessionCache, WritableSessionCache

      public abstract class AbstractSessionCache
      extends Object
      implements SessionCache, DocumentCache

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `AbstractSessionCache.BasicSaveContext`

    - ### Nested classes/interfaces inherited from interface org.modeshape.jcr.cache.SessionCache

      `SessionCache.PreSave, SessionCache.SaveContext`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractSessionCache(ExecutionContext context, WorkspaceCache sharedWorkspaceCache, SessionEnvironment sessionContext)`

  - ### Method Summary

    Methods
    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()` Signal that this session cache should check for an existing transaction and use the appropriate workspace cache.
    `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` | `completeTransaction()` Signal that the transaction that was active and in which this session participated has completed and that this session should no longer use a transaction-specific workspace cache.
    `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.
    `protected abstract void` | `doClear()`
    `protected abstract void` | `doClear(CachedNode node)`
    `protected String` | `generateIdentifier()`
    `Iterator<NodeKey>` | `getAllNodeKeys()` Get an iterator over all node keys within this cache.
    `Iterator<NodeKey>` | `getAllNodeKeysAtAndBelow(NodeKey startingKey)` Get an iterator over all keys for the supplied node and all its descendants.
    `ExecutionContext` | `getContext()` Get the context for this session.
    `CachedNode` | `getNode(ChildReference reference)` Get the cached representation of the node as represented by the supplied child reference.
    `CachedNode` | `getNode(NodeKey key)` Get the cached representation of the node with the supplied node key.
    `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.
    `NodeKey` | `getRootKey()` Get the node key for the root node.
    `NodeCache` | `getWorkspace()` Get the cache the reflects the workspace content, without any of the transient, unsaved changes of this session.
    `protected abstract Logger` | `logger()`
    `abstract SessionNode` | `mutable(NodeKey key)` Get a mutable form of the node with the supplied key.
    `SessionCache` | `unwrap()` Unwrap this instance.
    `WorkspaceCache` | `workspaceCache()`
    `protected String` | `workspaceName()`

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

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

    - ### Methods inherited from interface org.modeshape.jcr.cache.SessionCache

      `destroy, getChangedNodeKeys, getChangedNodeKeysAtOrBelow, hasChanges, isDestroyed, isReadOnly, save, save, save`

- - ### Constructor Detail

    - #### AbstractSessionCache

          protected AbstractSessionCache(ExecutionContext context,
                              WorkspaceCache sharedWorkspaceCache,
                              SessionEnvironment sessionContext)

  - ### Method Detail

    - #### logger

          protected abstract Logger logger()

    - #### checkForTransaction

          public void checkForTransaction()

      Signal that this session cache should check for an existing transaction and use the appropriate workspace cache. If there is a (new to this session) transaction, then this session will use a transaction-specific workspace cache (shared by other sessions participating in the same transaction), and upon completion of the transaction the session will switch back to the shared workspace cache.
      Specified by:
        `checkForTransaction` in interface `SessionCache`

    - #### completeTransaction

          protected void completeTransaction()

      Signal that the transaction that was active and in which this session participated has completed and that this session should no longer use a transaction-specific workspace cache.

    - #### unwrap

          public final SessionCache unwrap()

      Description copied from interface: `NodeCache`
      Unwrap this instance.
      Specified by:
        `unwrap` in interface `NodeCache`
      Specified by:
        `unwrap` in interface `SessionCache`
      Returns:
        the unwrapped SessionCache instance, or this object if there is no wrapper.

    - #### workspaceName

          protected final String workspaceName()

    - #### getContext

          public final ExecutionContext getContext()

      Description copied from interface: `SessionCache`
      Get the context for this session.
      Specified by:
        `getContext` in interface `SessionCache`
      Returns:
        the session's context; never null

    - #### workspaceCache

          public final WorkspaceCache workspaceCache()

      Specified by:
        `workspaceCache` in interface `DocumentCache`

    - #### addContextData

          public final void addContextData(String key,
                            String value)

      Description copied from interface: `SessionCache`
      Adds a [key,value] data pair for this cache's context
      Specified by:
        `addContextData` in interface `SessionCache`
      Parameters:
        `key` - the key for the context data
        `value` - the value for the context data

    - #### createNodeKey

          public NodeKey createNodeKey()

      Description copied from interface: `SessionCache`
      Create a new node key for the current source and workspace.
      Specified by:
        `createNodeKey` in interface `SessionCache`
      Returns:
        a new node key; never null

    - #### createNodeKeyWithIdentifier

          public NodeKey createNodeKeyWithIdentifier(String identifier)

      Description copied from interface: `SessionCache`
      Create a new node key for the current source and workspace.
      Specified by:
        `createNodeKeyWithIdentifier` in interface `SessionCache`
      Parameters:
        `identifier` - the unique identifier for the key; if null, a generated identifier will be used
      Returns:
        a new node key; never null

    - #### createNodeKeyWithSource

          public NodeKey createNodeKeyWithSource(String sourceName)

      Description copied from interface: `SessionCache`
      Create a new node key for the current source and workspace.
      Specified by:
        `createNodeKeyWithSource` in interface `SessionCache`
      Parameters:
        `sourceName` - the name (not key) for the source; if null, the key for the current source is used
      Returns:
        a new node key; never null

    - #### createNodeKey

          public NodeKey createNodeKey(String sourceName,
                              String identifier)

      Description copied from interface: `SessionCache`
      Create a new node key for the current source and workspace.
      Specified by:
        `createNodeKey` in interface `SessionCache`
      Parameters:
        `sourceName` - the name (not key) for the source; if null, the key for the current source is used
        `identifier` - the unique identifier for the key; if null, a generated identifier will be used
      Returns:
        a new node key; never null

    - #### generateIdentifier

          protected String generateIdentifier()

    - #### getRootKey

          public NodeKey getRootKey()

      Description copied from interface: `NodeCache`
      Get the node key for the root node.
      Specified by:
        `getRootKey` in interface `NodeCache`
      Returns:
        the root node's key; never null

    - #### getWorkspace

          public NodeCache getWorkspace()

      Description copied from interface: `SessionCache`
      Get the cache the reflects the workspace content, without any of the transient, unsaved changes of this session.
      Specified by:
        `getWorkspace` in interface `SessionCache`
      Returns:
        the workspace cache; never null

    - #### 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`
      Parameters:
        `key` - the node key; may not be null
      Returns:
        the cached node, or null if there is no such node

    - #### getNode

          public CachedNode getNode(ChildReference reference)

      Description copied from interface: `NodeCache`
      Get the cached representation of the node as represented by the supplied child reference. This is a convenience method that is equivalent to calling:

           getNode(reference.getKey());

      Specified by:
        `getNode` in interface `NodeCache`
      Parameters:
        `reference` - the child node reference; may not be null
      Returns:
        the cached node to which the reference points, or null if the child reference no longer points to a valid node

    - #### getNodeKeysAtAndBelow

          public Set<NodeKey> getNodeKeysAtAndBelow(NodeKey nodeKey)

      Description copied from interface: `SessionCache`
      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. Note that this method will attempt to load each node
      Specified by:
        `getNodeKeysAtAndBelow` in interface `SessionCache`
      Parameters:
        `nodeKey` - the key of node which will be considered the root node
      Returns:
        a Set of nodekeys or an empty set

    - #### mutable

          public abstract 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`
      Parameters:
        `key` - the key for the node; may not be null
      Returns:
        the mutable child node

    - #### getAllNodeKeys

          public Iterator<NodeKey> getAllNodeKeys()

      Description copied from interface: `NodeCache`
      Get an iterator over all node keys within this cache. The order of the keys is not defined.
      Specified by:
        `getAllNodeKeys` in interface `NodeCache`
      Returns:
        an iterator over all the cache's node keys; never null

    - #### getAllNodeKeysAtAndBelow

          public Iterator<NodeKey> getAllNodeKeysAtAndBelow(NodeKey startingKey)

      Description copied from interface: `NodeCache`
      Get an iterator over all keys for the supplied node and all its descendants. The order of the keys is not defined.
      Specified by:
        `getAllNodeKeysAtAndBelow` in interface `NodeCache`
      Parameters:
        `startingKey` - the key for the node to start; may not be null
      Returns:
        an iterator over all the cache's node keys; never null

    - #### clear

          public final void clear(CachedNode node)

      Description copied from interface: `SessionCache`
      Clears all changes in the cache that are at or below the supplied node.
      Specified by:
        `clear` in interface `SessionCache`
      Parameters:
        `node` - the node at or below which all changes should be cleared; may not be null

    - #### clear

          public final void clear()

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

    - #### doClear

          protected abstract void doClear(CachedNode node)

    - #### doClear

          protected abstract void doClear()

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