org.jboss.cache.interceptors
Class OptimisticValidatorInterceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
      extended by org.jboss.cache.interceptors.MethodDispacherInterceptor
          extended by org.jboss.cache.interceptors.OptimisticInterceptor
              extended by org.jboss.cache.interceptors.OptimisticValidatorInterceptor
All Implemented Interfaces:
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.Interceptor
cache, configuration, last, log, next, trace
 
Constructor Summary
OptimisticValidatorInterceptor()
           
 
Method Summary
protected  Object handleCommitMethod(InvocationContext ctx, GlobalTransaction globalTransaction)
          Handles CacheImpl.commit(org.jboss.cache.transaction.GlobalTransaction)
protected  Object handleOptimisticPrepareMethod(InvocationContext ctx, GlobalTransaction gtx, List modifications, Map data, org.jgroups.Address address, boolean onePhaseCommit)
          Handles CacheImpl.optimisticPrepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, java.util.Map, org.jgroups.Address, boolean)
protected  Object handleRollbackMethod(InvocationContext ctx, GlobalTransaction globalTransaction)
          Handles CacheImpl.rollback(org.jboss.cache.transaction.GlobalTransaction)
 void setCache(CacheSPI cache)
           
 
Methods inherited from class org.jboss.cache.interceptors.OptimisticInterceptor
getGlobalTransaction, getTransactionWorkspace, greedyGetFqns, lockAndCreateWorkspaceNode, undeleteWorkspaceNode, undeleteWorkspaceNode
 
Methods inherited from class org.jboss.cache.interceptors.MethodDispacherInterceptor
handleAddChildMethod, handleBlockChannelMethod, handleDataGravitationCleanupMethod, handleEvictMethod, handleEvictVersionedNodeMethod, handleExistsMethod, handleGetDataMapMethod, handleGetChildrenNamesMethod, handleGetKeysMethod, handleGetKeyValueMethod, handleGetNodeMethod, handleLockMethod, handleMoveMethod, handlePrepareMethod, handlePrintMethod, handlePutDataEraseMethod, handlePutDataEraseVersionedMethod, handlePutDataMethod, handlePutDataVersionedMethod, handlePutForExternalReadMethod, handlePutForExternalReadVersionedMethod, handlePutKeyValueMethod, handlePutKeyValueVersionedMethod, handleReleaseAllLocksMethod, handleRemoveDataMethod, handleRemoveDataVersionedMethod, handleRemoveKeyMethod, handleRemoveKeyVersionedMethod, handleRemoveNodeMethod, handleRemoveNodeVersionedMethod, handleUnblockChannelMethod, invoke, skipMethodCall
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
assertTransactionValid, dumpStatistics, getLast, getNext, getStatisticsEnabled, initLogger, isActive, isPreparing, isValid, nextInterceptor, peekNode, resetStatistics, setLast, setNext, setStatisticsEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OptimisticValidatorInterceptor

public OptimisticValidatorInterceptor()
Method Detail

setCache

public void setCache(CacheSPI cache)
Overrides:
setCache in class Interceptor

handleOptimisticPrepareMethod

protected Object handleOptimisticPrepareMethod(InvocationContext ctx,
                                               GlobalTransaction gtx,
                                               List modifications,
                                               Map data,
                                               org.jgroups.Address address,
                                               boolean onePhaseCommit)
                                        throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.optimisticPrepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, java.util.Map, org.jgroups.Address, boolean)

Overrides:
handleOptimisticPrepareMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleCommitMethod

protected Object handleCommitMethod(InvocationContext ctx,
                                    GlobalTransaction globalTransaction)
                             throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.commit(org.jboss.cache.transaction.GlobalTransaction)

Overrides:
handleCommitMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRollbackMethod

protected Object handleRollbackMethod(InvocationContext ctx,
                                      GlobalTransaction globalTransaction)
                               throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.rollback(org.jboss.cache.transaction.GlobalTransaction)

Overrides:
handleRollbackMethod in class MethodDispacherInterceptor
Throws:
Throwable


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