org.jboss.cache.interceptors
Class OptimisticValidatorInterceptor

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

public class OptimisticValidatorInterceptor
extends OptimisticInterceptor

Validates the data in the TransactionWorkspace against data in the underlying data structure (versions only) and then applies changes to the underlying data structure. This is only triggered when commit, rollback or prepare method calls are encountered. Other method calls are directly passed up the interceptor chain, untouched. Note that prepare/commit/rollbacks are not passed up the interceptor chain after being processed.

When preparting, this interceptor does nothing more than validate versions. The validation scheme used is based on the DataVersion implementation used. DataVersion.newerThan(org.jboss.cache.optimistic.DataVersion) is used to determine whether the version of one instance is newer than the version of another. It is up to the DataVersion implementation to deal with attempting to compare incompatible version types (and potentially throwing DataVersioningExceptions.

Upon successful commit, changes in the workspace are applied to the underlying data structure in the cache.

On rollback clears the nodes in the workspace and leaves the underlying data structure untouched.

Author:
Manik Surtani (manik@jboss.org), Steve Woodcock (stevew@jofti.com)

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.OptimisticInterceptor
txManager, txTable
 
Fields inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
configuration, log, trace
 
Constructor Summary
OptimisticValidatorInterceptor()
           
 
Method Summary
 void initialize(DataContainer dataContainer)
           
 Object visitCommitCommand(InvocationContext ctx, CommitCommand command)
          Visits a CommitCommand.
 Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command)
          Visits a OptimisticPrepareCommand.
 Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command)
          Visits a RollbackCommand.
 
Methods inherited from class org.jboss.cache.interceptors.OptimisticInterceptor
getGlobalTransaction, getTransactionWorkspace, greedyGetFqns, lockAndCreateWorkspaceNode, undeleteWorkspaceNode, undeleteWorkspaceNode
 
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, visitCreateNodeCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand, visitMoveCommand, visitPrepareCommand, visitPutDataMapCommand, visitPutKeyValueCommand, visitRemoveDataCommand, visitRemoveKeyCommand, visitRemoveNodeCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptimisticValidatorInterceptor

public OptimisticValidatorInterceptor()
Method Detail

initialize

public void initialize(DataContainer dataContainer)

visitOptimisticPrepareCommand

public Object visitOptimisticPrepareCommand(InvocationContext ctx,
                                            OptimisticPrepareCommand command)
                                     throws Throwable
Description copied from interface: Visitor
Visits a OptimisticPrepareCommand.

Specified by:
visitOptimisticPrepareCommand in interface Visitor
Overrides:
visitOptimisticPrepareCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitCommitCommand

public Object visitCommitCommand(InvocationContext ctx,
                                 CommitCommand command)
                          throws Throwable
Description copied from interface: Visitor
Visits a CommitCommand.

Specified by:
visitCommitCommand in interface Visitor
Overrides:
visitCommitCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRollbackCommand

public Object visitRollbackCommand(InvocationContext ctx,
                                   RollbackCommand command)
                            throws Throwable
Description copied from interface: Visitor
Visits a RollbackCommand.

Specified by:
visitRollbackCommand in interface Visitor
Overrides:
visitRollbackCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.


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