org.jboss.cache.interceptors
Class TxInterceptor

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

public class TxInterceptor
extends Interceptor
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
protected  javax.transaction.TransactionManager txManager
           
protected  TransactionTable txTable
           
 
Constructor Summary
TxInterceptor()
           
 
Method Summary
 java.util.Map dumpStatistics()
          Returns a map of the cache interceptor's statistics Map elements consist of {String name, Object value} entries
protected  GlobalTransaction findGlobalTransaction(java.lang.Object[] params)
           
 long getCommits()
          Returns the number of transaction commits
 long getPrepares()
          Returns the number of transaction prepares
 long getRollbacks()
          Returns the number of transaction rollbacks
 java.lang.Object invoke(org.jgroups.blocks.MethodCall m)
           
 void resetStatistics()
          Resets an interceptor's cache statistics
protected  void runCommitPhase(GlobalTransaction gtx, javax.transaction.Transaction tx, java.util.List modifications, boolean onePhaseCommit)
          creates a commit() MethodCall and feeds it to handleCommitRollback();
protected  java.lang.Object runPreparePhase(GlobalTransaction gtx, java.util.List modifications)
          Handles a local prepare - invoked by the sync handler.
protected  void runRollbackPhase(GlobalTransaction gtx, javax.transaction.Transaction tx, java.util.List modifications)
          creates a rollback() MethodCall and feeds it to handleCommitRollback();
 void setCache(TreeCache cache)
           
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
getInvocationContext, getNext, getStatisticsEnabled, isActive, isOnePhaseCommitPrepareMehod, isPreparing, isTransactionLifecycleMethod, isValid, setInvocationContext, setNext, setStatisticsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Field Detail

txManager

protected javax.transaction.TransactionManager txManager

txTable

protected TransactionTable txTable
Constructor Detail

TxInterceptor

public TxInterceptor()
Method Detail

setCache

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

invoke

public java.lang.Object invoke(org.jgroups.blocks.MethodCall m)
                        throws java.lang.Throwable
Overrides:
invoke in class Interceptor
Throws:
java.lang.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 interface: InterceptorMBean
Resets an interceptor's cache statistics

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

dumpStatistics

public java.util.Map dumpStatistics()
Description copied from interface: InterceptorMBean
Returns a map of the cache interceptor's statistics Map elements consist of {String name, Object value} entries

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

findGlobalTransaction

protected GlobalTransaction findGlobalTransaction(java.lang.Object[] params)

runCommitPhase

protected void runCommitPhase(GlobalTransaction gtx,
                              javax.transaction.Transaction tx,
                              java.util.List modifications,
                              boolean onePhaseCommit)
creates a commit() MethodCall and feeds it to handleCommitRollback();

Parameters:
gtx -

runRollbackPhase

protected void runRollbackPhase(GlobalTransaction gtx,
                                javax.transaction.Transaction tx,
                                java.util.List modifications)
creates a rollback() MethodCall and feeds it to handleCommitRollback();

Parameters:
gtx -

runPreparePhase

protected java.lang.Object runPreparePhase(GlobalTransaction gtx,
                                           java.util.List modifications)
                                    throws java.lang.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:
java.lang.Throwable


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.