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

## org.modeshape.jcr.cache
Interface SessionCache

All Superinterfaces:
  NodeCache

All Known Implementing Classes:
  AbstractSessionCache, ReadOnlySessionCache, WritableSessionCache

    public interface SessionCache

extends NodeCache

Nested Class Summary
`static interface` | `SessionCache.PreSave` The definition of a callback that can be implemented and passed to `save(SessionCache, PreSave)` and `save(CachedNode, SessionCache, PreSave)`, allowing the caller to recieve a hook where they can interrogate each of the changed nodes and perform additional logic prior to the actual persisting of the changes.
`static interface` | `SessionCache.SaveContext` The context of a save operation, created during each call to `save()` and passed to the `PreSave#process(MutableCachedNode, SaveContext)` invocations.

Method Summary
`void` | `addContextData(String key, String value)` Adds a [key,value] data pair for this cache's context
`void` | `clear(CachedNode node)` Clears all changes in the cache that are at or below the supplied node.
`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.
`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 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
`ExecutionContext` | `getContext()` Get the context for this session.
`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.
`NodeCache` | `getWorkspace()` Get the cache the reflects the workspace content, without any of the transient, unsaved changes of this session.
`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.
`MutableCachedNode` | `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(CachedNode node, SessionCache otherSession, SessionCache.PreSave preSaveOperation)` Saves all of this session's changes that were made at or below the specified path.
`void` | `save(SessionCache otherSession, SessionCache.PreSave preSaveOperation)` Saves all changes made within this session and the supplied session, using a single transaction for both.

Methods inherited from interface org.modeshape.jcr.cache.NodeCache
`clear, getNode, getNode, getRootKey`

Method Detail

### getContext

    ExecutionContext getContext()

  Get the context for this session.

  Returns:
    the session's context; never null

### addContextData

    void addContextData(String key,
                        String value)

  Adds a [key,value] data pair for this cache's context

  Parameters:
    `key` - the key for the context data
    `value` - the value for the context data

### save

    void save()

  Saves all changes made within this session.

  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

    void save(CachedNode node,
              SessionCache otherSession,
              SessionCache.PreSave preSaveOperation)

  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:
    `node` - the node at or below which all 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
  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

    void save(SessionCache otherSession,
              SessionCache.PreSave preSaveOperation)

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

### hasChanges

    boolean hasChanges()

  Determine whether this session has any transient, unsaved changes.

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

### getChangedNodeKeys

    Set<NodeKey> getChangedNodeKeys()

  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 `hasChanges()` is false. The returned set is a mutable copy of the underlying set.

### getChangedNodeKeysAtOrBelow

    Set<NodeKey> getChangedNodeKeysAtOrBelow(CachedNode node)
                                             throws NodeNotFoundException

  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
  Throws:
    `NodeNotFoundException` - if any of changes registered in this cache refer to nodes that have been removed in the meantime.

### getNodeKeysAtAndBelow

    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. Note that this method will attempt to load each node

  Parameters:
    `nodeKey` - the key of node which will be considered the root node
  Returns:
    a Set of nodekeys or an empty set

### clear

    void clear(CachedNode node)

  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

### getWorkspace

    NodeCache getWorkspace()

  Get the cache the reflects the workspace content, without any of the transient, unsaved changes of this session.

  Returns:
    the workspace cache; never null

### mutable

    MutableCachedNode mutable(NodeKey key)
                              throws NodeNotFoundException,
                                     UnsupportedOperationException

  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.

  Parameters:
    `key` - the key for the node; may not be null
  Returns:
    the mutable child node
  Throws:
    `NodeNotFoundException` - if there is no existing node in the session cache or workspace cache
    `UnsupportedOperationException` - if this session is marked for read-only operations

### destroy

    void destroy(NodeKey key)
                 throws NodeNotFoundException,
                        UnsupportedOperationException

  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
  Throws:
    `NodeNotFoundException` - if there is no existing node in the session cache or workspace cache
    `UnsupportedOperationException` - if this session is marked for read-only operations

### isDestroyed

    boolean isDestroyed(NodeKey key)

  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

### createNodeKey

    NodeKey createNodeKey()

  Create a new node key for the current source and workspace.

  Returns:
    a new node key; never null

### createNodeKeyWithIdentifier

    NodeKey createNodeKeyWithIdentifier(String identifier)

  Create a new node key for the current source and workspace.

  Parameters:
    `identifier` - the unique identifier for the key; if null, a generated identifier will be used
  Returns:
    a new node key; never null

### isReadOnly

    boolean isReadOnly()

  Returns whether this cache is readonly.

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

### createNodeKeyWithSource

    NodeKey createNodeKeyWithSource(String sourceName)

  Create a new node key for the current source and workspace.

  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

    NodeKey createNodeKey(String sourceName,
                          String identifier)

  Create a new node key for the current source and workspace.

  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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
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.