FileDocCategorySizeDatePackage
TestTxInterceptor.javaAPI DocExample1343Mon Apr 25 11:54:22 BST 2005com.springbook.interceptors

TestTxInterceptor

public class TestTxInterceptor extends Object implements MethodInterceptor

Fields Summary
private org.springframework.transaction.PlatformTransactionManager
platformTransactionManager
Constructors Summary
Methods Summary
public org.springframework.transaction.PlatformTransactionManagergetPlatformTransactionManager()

      return platformTransactionManager;
   
public java.lang.Objectinvoke(org.aopalliance.intercept.MethodInvocation methodInvocation)

      DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
      def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
      TransactionStatus status = platformTransactionManager.getTransaction(def);
      Object results = null;
      try {
         results = methodInvocation.proceed();
      } finally {
         platformTransactionManager.rollback(status);
      }
      return results;

   
public voidsetPlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager platformTransactionManager)

      this.platformTransactionManager = platformTransactionManager;