org.modeshape.jcr.cache

## Interface SessionCache.PreSave

- All Known Implementing Classes:
    JcrSession.JcrPreSave
  Enclosing interface:
    SessionCache

      public static interface SessionCache.PreSave

  The definition of a callback that can be implemented and passed to `SessionCache.save(SessionCache, PreSave)` and `SessionCache.save(Set, 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. Note that implementations are free to make additional modifications to the supplied nodes, and even create additional nodes or change persistent but unchanged nodes, as long as these operations are done within the same calling thread.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `process(MutableCachedNode modifiedOrNewNode, SessionCache.SaveContext context)` Process the supplied node prior to saving the changes.
    `void` | `processAfterLocking(MutableCachedNode modifiedNode, SessionCache.SaveContext context, NodeCache persistentNodeCache)` Process the supplied existing node prior to saving the changes but only after the entry corresponding to the key of the node has been locked in Infinispan.

- - ### Method Detail

    - #### process

          void process(MutableCachedNode modifiedOrNewNode,
                     SessionCache.SaveContext context)
                       throws Exception

      Process the supplied node prior to saving the changes. This allows implementations to use the changes to automatically adjust this node or other content.
      Parameters:
        `modifiedOrNewNode` - the mutable node that was changed in this session; never null
        `context` - the context of the save operation; never null
      Throws:
        `Exception` - if there is a problem during the processing

    - #### processAfterLocking

          void processAfterLocking(MutableCachedNode modifiedNode,
                                 SessionCache.SaveContext context,
                                 NodeCache persistentNodeCache)
                                   throws Exception

      Process the supplied existing node prior to saving the changes but only after the entry corresponding to the key of the node has been locked in Infinispan. Note that locking in Infinispan does not occur always, but only if the `LockingMode.PESSIMISTIC` flag is enabled. This method should be implemented as optimal as possible and should only be needed in multi-threaded scenarios where concurrent modifications may break consistency.
      Parameters:
        `modifiedNode` - the mutable node that was changed in this session; never null
        `context` - the context of the save operation; never null
        `persistentNodeCache` - the node cache from which the persistent representation of the nodes can be obtained; never null
      Throws:
        `Exception` - if there is a problem during the processing

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