org.modeshape.jcr.cache.document

## Class WorkspaceCache

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

- All Implemented Interfaces:
    CachedNodeSupplier, DocumentCache, NodeCache
  Direct Known Subclasses:
    TransactionalWorkspaceCache

      public class WorkspaceCache
      extends Object
      implements DocumentCache

  A `NodeCache` implementation that uses Infinispan's `SchematicDb` for storage, with each node represented as a single `Document`. The nodes in this cache represent the actual, unmodified values.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `WorkspaceCache.NonSystemChangeNotifier`
    `protected class` | `WorkspaceCache.SystemChangeNotifier`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Logger` | `LOGGER`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `WorkspaceCache(ExecutionContext context, String repositoryKey, String workspaceName, WorkspaceCache systemWorkspace, DocumentStore documentStore, DocumentTranslator translator, NodeKey rootKey, ConcurrentMap<NodeKey,CachedNode> cache, ChangeBus changeBus)`
    `protected` | `WorkspaceCache(WorkspaceCache original, ConcurrentMap<NodeKey,CachedNode> cache)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `changed(ChangeSet changes)` Signal that changes have been made to the persisted data.
    `protected void` | `checkNotClosed()`
    `void` | `clear()` Clears all changes in the cache.
    `protected void` | `evictChangedNodes(ChangeSet changes)`
    `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.
    `ChildReference` | `getChildReference(NodeKey parentKey, NodeKey childKey)`
    `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.
    `String` | `getProcessKey()`
    `String` | `getRepositoryKey()`
    `NodeKey` | `getRootKey()` Get the node key for the root node.
    `String` | `getWorkspaceKey()`
    `String` | `getWorkspaceName()`
    `boolean` | `isEmpty()` Checks if this ws cache is empty.
    `protected WorkspaceCache` | `persistedCache(Iterable<NodeKey> nodeKeys)` Returns a workspace cache which has the latest persisted information read from Infinispan for the given nodes.
    `void` | `setMinimumStringLengthForBinaryStorage(long largeValueSize)`
    `void` | `signalClosed()` Signal that this workspace cache has been fully closed.
    `void` | `signalClosing()` Signal that this workspace cache is to be closed, and it can start reclaiming resources.
    `void` | `signalDeleted()` Signal that the workspace for this workspace cache has been deleted/destroyed, so this cache is not needed anymore.
    `String` | `toString()`
    `NodeCache` | `unwrap()` Unwrap this instance.
    `WorkspaceCache` | `workspaceCache()`

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

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

- - ### Field Detail

    - #### LOGGER

          protected static final Logger LOGGER

  - ### Constructor Detail

    - #### WorkspaceCache

          public WorkspaceCache(ExecutionContext context,
                        String repositoryKey,
                        String workspaceName,
                        WorkspaceCache systemWorkspace,
                        DocumentStore documentStore,
                        DocumentTranslator translator,
                        NodeKey rootKey,
                        ConcurrentMap<NodeKey,CachedNode> cache,
                        ChangeBus changeBus)

    - #### WorkspaceCache

          protected WorkspaceCache(WorkspaceCache original,
                        ConcurrentMap<NodeKey,CachedNode> cache)

  - ### Method Detail

    - #### setMinimumStringLengthForBinaryStorage

          public void setMinimumStringLengthForBinaryStorage(long largeValueSize)

    - #### workspaceCache

          public final WorkspaceCache workspaceCache()

      Specified by:
        `workspaceCache` in interface `DocumentCache`

    - #### getProcessKey

          public final String getProcessKey()

    - #### getRepositoryKey

          public final String getRepositoryKey()

    - #### getWorkspaceKey

          public final String getWorkspaceKey()

    - #### getWorkspaceName

          public final String getWorkspaceName()

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

    - #### getNode

          public CachedNode getNode(NodeKey key)

      Description copied from interface: `CachedNodeSupplier`
      Get the cached representation of the node with the supplied node key.
      Specified by:
        `getNode` in interface `CachedNodeSupplier`
      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

    - #### getChildReference

          public ChildReference getChildReference(NodeKey parentKey,
                                         NodeKey childKey)

    - #### 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 void clear()

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

    - #### evictChangedNodes

          protected void evictChangedNodes(ChangeSet changes)

    - #### changed

          public void changed(ChangeSet changes)

      Signal that changes have been made to the persisted data. Related information in the cache is cleared, and this workspace's listener is notified of the changes.
      Parameters:
        `changes` - the changes to be made; may not be null

    - #### unwrap

          public NodeCache unwrap()

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

    - #### checkNotClosed

          protected final void checkNotClosed()

    - #### signalDeleted

          public void signalDeleted()

      Signal that the workspace for this workspace cache has been deleted/destroyed, so this cache is not needed anymore.

    - #### signalClosing

          public void signalClosing()

      Signal that this workspace cache is to be closed, and it can start reclaiming resources.

    - #### signalClosed

          public void signalClosed()

      Signal that this workspace cache has been fully closed.

    - #### isEmpty

          public boolean isEmpty()

      Checks if this ws cache is empty. An empty cache is considered when the only node key under root is the system key.
      Returns:
        `true` if the system key is the only key under root, `false` other wise.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### persistedCache

          protected WorkspaceCache persistedCache(Iterable<NodeKey> nodeKeys)

      Returns a workspace cache which has the latest persisted information read from Infinispan for the given nodes. After reading each node from Infinispan, that node will also be updated/inserted into *this* workspace cache.
      Parameters:
        `nodeKeys` - an `Iterable` of `NodeKey`; may not be null
      Returns:
        a workspace cache instance which only contains the latest persisted information for the requested nodes.

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