FileDocCategorySizeDatePackage
TxPropagationInterceptor.javaAPI DocJBoss 4.2.12672Fri Jul 13 21:02:30 BST 2007org.jboss.aspects.tx

TxPropagationInterceptor

public class TxPropagationInterceptor extends Object implements org.jboss.aop.advice.Interceptor
Comment
author
Bill Burke
version
$Revision: 57186 $

Fields Summary
private TransactionManager
tm
Constructors Summary
public TxPropagationInterceptor(TransactionManager tm)

      this.tm = tm;
   
public TxPropagationInterceptor()

      tm = TransactionManagerLocator.getInstance().locate();
   
Methods Summary
public java.lang.StringgetName()

      return "TxPropagationInterceptor";
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      Object tpc = invocation.getMetaData(ClientTxPropagationInterceptor.TRANSACTION_PROPAGATION_CONTEXT, ClientTxPropagationInterceptor.TRANSACTION_PROPAGATION_CONTEXT);
      if (tpc != null)
      {
         Transaction tx = tm.getTransaction();
         if (tx != null) throw new RuntimeException("cannot import a transaction context when a transaction is already associated with the thread");
         Transaction importedTx = TransactionPropagationContextUtil.getTPCImporter().importTransactionPropagationContext(tpc);
         tm.resume(importedTx);
         try
         {
            return invocation.invokeNext();
         }
         finally
         {
            tm.suspend();
         }
      }
      else
      {
         return invocation.invokeNext();
      }