org.jboss.cache.interceptors
Class PessimisticLockInterceptor

java.lang.Object
  extended by org.jboss.cache.commands.AbstractVisitor
      extended by org.jboss.cache.interceptors.base.CommandInterceptor
          extended by org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor
              extended by org.jboss.cache.interceptors.PessimisticLockInterceptor
All Implemented Interfaces:
Visitor, InterceptorMBean

public class PessimisticLockInterceptor
extends PostProcessingCommandInterceptor

An interceptor that handles locking. When a TX is associated, we register for TX completion and unlock the locks acquired within the scope of the TX. When no TX is present, we keep track of the locks acquired during the current method and unlock when the method returns.

Version:
$Id: PessimisticLockInterceptor.java 6000 2008-06-17 23:43:54Z manik.surtani@jboss.com $
Author:
Bela Ban

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
configuration, log, trace
 
Constructor Summary
PessimisticLockInterceptor()
           
 
Method Summary
 void doAfterCall(InvocationContext ctx, VisitableCommand command)
          Callback that is invoked after every handleXXX() method defined above.
protected  Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command)
           
protected  Object handleCommitCommand(InvocationContext ctx, CommitCommand command)
           
protected  Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command)
           
protected  Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command)
           
protected  Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command)
           
protected  Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command)
           
protected  Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command)
           
protected  Object handleMoveCommand(InvocationContext ctx, MoveCommand command)
           
protected  Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command)
           
protected  Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
           
protected  Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command)
           
protected  Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
           
protected  Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
           
protected  Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command)
           
protected  Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command)
           
 void injectDependencies(DataContainer dataContainer, LockManager lockManager, CommandsFactory commandsFactory)
           
 void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionEntry entry)
          Acquires write locks on the node and all child nodes, adding children to the list of removed nodes in the context.
 
Methods inherited from class org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor
handleCreateNodeCommand, handleExistsNodeCommand, handleGetDataMapCommand, handleGravitateDataCommand, handleInvalidateCommand, handleOptimisticPrepareCommand, visitClearDataCommand, visitCommitCommand, visitCreateNodeCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand, visitMoveCommand, visitOptimisticPrepareCommand, visitPrepareCommand, visitPutDataMapCommand, visitPutForExternalReadCommand, visitPutKeyValueCommand, visitRemoveKeyCommand, visitRemoveNodeCommand, visitRollbackCommand
 
Methods inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
dumpStatistics, getNext, getStatisticsEnabled, handleDefault, hasNext, invokeNextInterceptor, resetStatistics, setNext, setStatisticsEnabled
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
visitCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PessimisticLockInterceptor

public PessimisticLockInterceptor()
Method Detail

injectDependencies

public void injectDependencies(DataContainer dataContainer,
                               LockManager lockManager,
                               CommandsFactory commandsFactory)

handlePutDataMapCommand

protected Object handlePutDataMapCommand(InvocationContext ctx,
                                         PutDataMapCommand command)
                                  throws Throwable
Overrides:
handlePutDataMapCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handlePutKeyValueCommand

protected Object handlePutKeyValueCommand(InvocationContext ctx,
                                          PutKeyValueCommand command)
                                   throws Throwable
Overrides:
handlePutKeyValueCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handlePutForExternalReadCommand

protected Object handlePutForExternalReadCommand(InvocationContext ctx,
                                                 PutForExternalReadCommand command)
                                          throws Throwable
Overrides:
handlePutForExternalReadCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handlePrepareCommand

protected Object handlePrepareCommand(InvocationContext ctx,
                                      PrepareCommand command)
                               throws Throwable
Overrides:
handlePrepareCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleCommitCommand

protected Object handleCommitCommand(InvocationContext ctx,
                                     CommitCommand command)
                              throws Throwable
Overrides:
handleCommitCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleRollbackCommand

protected Object handleRollbackCommand(InvocationContext ctx,
                                       RollbackCommand command)
                                throws Throwable
Overrides:
handleRollbackCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleMoveCommand

protected Object handleMoveCommand(InvocationContext ctx,
                                   MoveCommand command)
                            throws Throwable
Overrides:
handleMoveCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleRemoveNodeCommand

protected Object handleRemoveNodeCommand(InvocationContext ctx,
                                         RemoveNodeCommand command)
                                  throws Throwable
Overrides:
handleRemoveNodeCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

lockAllForRemoval

public void lockAllForRemoval(NodeSPI node,
                              InvocationContext ctx,
                              TransactionEntry entry)
                       throws InterruptedException
Acquires write locks on the node and all child nodes, adding children to the list of removed nodes in the context.

Parameters:
node - node to inspect
ctx - invocation context
entry - transaction entry
Throws:
InterruptedException - in the event of interruption

handleRemoveKeyCommand

protected Object handleRemoveKeyCommand(InvocationContext ctx,
                                        RemoveKeyCommand command)
                                 throws Throwable
Overrides:
handleRemoveKeyCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleClearDataCommand

protected Object handleClearDataCommand(InvocationContext ctx,
                                        ClearDataCommand command)
                                 throws Throwable
Overrides:
handleClearDataCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleEvictFqnCommand

protected Object handleEvictFqnCommand(InvocationContext ctx,
                                       EvictCommand command)
                                throws Throwable
Overrides:
handleEvictFqnCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleGetKeyValueCommand

protected Object handleGetKeyValueCommand(InvocationContext ctx,
                                          GetKeyValueCommand command)
                                   throws Throwable
Overrides:
handleGetKeyValueCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleGetNodeCommand

protected Object handleGetNodeCommand(InvocationContext ctx,
                                      GetNodeCommand command)
                               throws Throwable
Overrides:
handleGetNodeCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleGetKeysCommand

protected Object handleGetKeysCommand(InvocationContext ctx,
                                      GetKeysCommand command)
                               throws Throwable
Overrides:
handleGetKeysCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

handleGetChildrenNamesCommand

protected Object handleGetChildrenNamesCommand(InvocationContext ctx,
                                               GetChildrenNamesCommand command)
                                        throws Throwable
Overrides:
handleGetChildrenNamesCommand in class PostProcessingCommandInterceptor
Throws:
Throwable

doAfterCall

public void doAfterCall(InvocationContext ctx,
                        VisitableCommand command)
Description copied from class: PostProcessingCommandInterceptor
Callback that is invoked after every handleXXX() method defined above.

Specified by:
doAfterCall in class PostProcessingCommandInterceptor
Parameters:
ctx - invocation context
command - command which was invoked


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.