org.jboss.cache.interceptors
Class TxInterceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
      extended by org.jboss.cache.interceptors.BaseTransactionalContextInterceptor
          extended by org.jboss.cache.interceptors.TxInterceptor
All Implemented Interfaces:
InterceptorMBean, TxInterceptorMBean

public class TxInterceptor
extends BaseTransactionalContextInterceptor
implements TxInterceptorMBean

This interceptor is the new default at the head of all interceptor chains, and makes transactional attributes available to all interceptors in the chain. This interceptor is also responsible for registering for synchronisation on transaction completion.

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

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.BaseTransactionalContextInterceptor
txManager, txTable
 
Fields inherited from class org.jboss.cache.interceptors.Interceptor
cache, configuration, last, log, next
 
Constructor Summary
TxInterceptor()
           
 
Method Summary
 Map<String,Object> dumpStatistics()
          This implementation returns an empty Map.
 long getCommits()
          Returns the number of transaction commits
 long getPrepares()
          Returns the number of transaction prepares
 long getRollbacks()
          Returns the number of transaction rollbacks
 Object invoke(InvocationContext ctx)
           
 void resetStatistics()
          This implementation is a no-op.
protected  void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications, boolean onePhaseCommit)
          creates a commit() MethodCall and feeds it to handleCommitRollback();
protected  Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List modifications)
          Handles a local prepare - invoked by the sync handler.
protected  void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications)
          creates a rollback() MethodCall and feeds it to handleCommitRollback();
 
Methods inherited from class org.jboss.cache.interceptors.BaseTransactionalContextInterceptor
copyInvocationScopeOptionsToTxScope, isRollingBack, setCache, setTransactionalContext
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
getLast, getNext, getStatisticsEnabled, isActive, isOnePhaseCommitPrepareMehod, isPreparing, isValid, setLast, setNext, setStatisticsEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Constructor Detail

TxInterceptor

public TxInterceptor()
Method Detail

invoke

public Object invoke(InvocationContext ctx)
              throws Throwable
Overrides:
invoke in class Interceptor
Throws:
Throwable

getPrepares

public long getPrepares()
Description copied from interface: TxInterceptorMBean
Returns the number of transaction prepares

Specified by:
getPrepares in interface TxInterceptorMBean
Returns:
the number of prepares

getCommits

public long getCommits()
Description copied from interface: TxInterceptorMBean
Returns the number of transaction commits

Specified by:
getCommits in interface TxInterceptorMBean
Returns:
the number of commits

getRollbacks

public long getRollbacks()
Description copied from interface: TxInterceptorMBean
Returns the number of transaction rollbacks

Specified by:
getRollbacks in interface TxInterceptorMBean
Returns:
the number of rollbacks

resetStatistics

public void resetStatistics()
Description copied from class: Interceptor
This implementation is a no-op. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
resetStatistics in interface InterceptorMBean
Overrides:
resetStatistics in class Interceptor

dumpStatistics

public Map<String,Object> dumpStatistics()
Description copied from class: Interceptor
This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
dumpStatistics in interface InterceptorMBean
Overrides:
dumpStatistics in class Interceptor
Returns:
a map containing statistics

runCommitPhase

protected void runCommitPhase(InvocationContext ctx,
                              GlobalTransaction gtx,
                              Transaction tx,
                              List modifications,
                              boolean onePhaseCommit)
creates a commit() MethodCall and feeds it to handleCommitRollback();

Parameters:
gtx -

runRollbackPhase

protected void runRollbackPhase(InvocationContext ctx,
                                GlobalTransaction gtx,
                                Transaction tx,
                                List modifications)
creates a rollback() MethodCall and feeds it to handleCommitRollback();

Parameters:
gtx -

runPreparePhase

protected Object runPreparePhase(InvocationContext ctx,
                                 GlobalTransaction gtx,
                                 List modifications)
                          throws Throwable
Handles a local prepare - invoked by the sync handler. Tests if the current tx matches the gtx passed in to the method call and passes the prepare() call up the chain.

Returns:
Throws:
Throwable


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