Package org.springframework.transaction.interceptor

Examples of org.springframework.transaction.interceptor.TransactionInterceptor$ThrowableHolder


  public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) {

    CustomAnnotationTransactionAttributeSource transactionAttributeSource = new CustomAnnotationTransactionAttributeSource();
    transactionAttributeSource.setRepositoryInformation(repositoryInformation);

    TransactionInterceptor transactionInterceptor = new TransactionInterceptor(null, transactionAttributeSource);
    transactionInterceptor.setTransactionManagerBeanName(transactionManagerName);
    transactionInterceptor.setBeanFactory(beanFactory);
    transactionInterceptor.afterPropertiesSet();

    factory.addAdvice(transactionInterceptor);
  }
View Full Code Here



  public void setUp() {
    this.ptm = new CallCountingTransactionManager();
    this.source = new AnnotationTransactionAttributeSource();
    this.ti = new TransactionInterceptor(this.ptm, this.source);
  }
View Full Code Here

 
  public void testSerializable() throws Exception {
    TestBean1 tb = new TestBean1();
    CallCountingTransactionManager ptm = new CallCountingTransactionManager();
    AnnotationTransactionAttributeSource tas = new AnnotationTransactionAttributeSource();
    TransactionInterceptor ti = new TransactionInterceptor(ptm, tas);

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    proxyFactory.addAdvice(ti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();
    assertEquals(1, ptm.commits);

    ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
    serializedProxy.getAge();
    Advised advised = (Advised) serializedProxy;
    TransactionInterceptor serializedTi = (TransactionInterceptor) advised.getAdvisors()[0].getAdvice();
    CallCountingTransactionManager serializedPtm =
        (CallCountingTransactionManager) serializedTi.getTransactionManager();
    assertEquals(2, serializedPtm.commits);
  }
View Full Code Here

                transactionManager = (PlatformTransactionManager) applicationContext.getBean(this.transactionManagerName);
              } else {
                throw new RuntimeException (String.format("transactionManager property not set and transactionPropertyName %s not found", this.transactionManagerName));
              }
            }
          transactionInterceptor = new TransactionInterceptor(transactionManager, new AnnotationTransactionAttributeSource());
        }
        this.addAdvice(this.transactionInterceptor);
        this.addAdvisor( new DaoMethodsIntroductionAdvisor() );

    }
View Full Code Here

  @ExternalBean
  public abstract PlatformTransactionManager transactionManager();

  @Bean(scope = DefaultScopes.SINGLETON)
  public TransactionInterceptor transactionInterceptor() throws Exception {
    TransactionInterceptor transactionInterceptor = new TransactionInterceptor(
        (PlatformTransactionManager) transactionManager(),
        new AnnotationTransactionAttributeSource());
    return transactionInterceptor;
  }
View Full Code Here

  }

  @Bean
  @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
  public TransactionInterceptor transactionInterceptor() {
    TransactionInterceptor interceptor = new TransactionInterceptor();
    interceptor.setTransactionAttributeSource(transactionAttributeSource());
    if (this.txManager != null) {
      interceptor.setTransactionManager(this.txManager);
    }
    return interceptor;
  }
View Full Code Here

      assertEquals("Should have 1 rolled back transaction", 1, ptm.rollbacks);
    }
  }
 
  public void testRollbackRules() {
    TransactionInterceptor txInterceptor = (TransactionInterceptor) context.getBean("txRollbackAdvice");
    TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
    TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
    assertTrue("should be configured to rollback on Exception",txAttr.rollbackOn(new Exception()));
   
    txAttr = txAttrSource.getTransactionAttribute(setAgeMethod, ITestBean.class);
    assertFalse("should not rollback on RuntimeException",txAttr.rollbackOn(new RuntimeException()));
View Full Code Here

  public final void afterPropertiesSet() {
    validate(daoInterface, transformers);
    final Class<? extends PersistentEntity<?>> realEntityType = getEntityType(daoInterface, entityType);
    addInterface(daoInterface);
    setTarget(createDao(realEntityType));
    addAdvice(new TransactionInterceptor(transactionManager, this));
    addAdvice(new FinderIntroductionInterceptor(transformers));
  }
View Full Code Here

  }

  @Bean
  @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
  public TransactionInterceptor transactionInterceptor() {
    TransactionInterceptor interceptor = new TransactionInterceptor();
    interceptor.setTransactionAttributeSource(transactionAttributeSource());
    if (this.txManager != null) {
      interceptor.setTransactionManager(this.txManager);
    }
    return interceptor;
  }
View Full Code Here

  @Test
  public void testSerializable() throws Exception {
    TestBean1 tb = new TestBean1();
    CallCountingTransactionManager ptm = new CallCountingTransactionManager();
    AnnotationTransactionAttributeSource tas = new AnnotationTransactionAttributeSource();
    TransactionInterceptor ti = new TransactionInterceptor(ptm, tas);

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setInterfaces(new Class[] {ITestBean.class});
    proxyFactory.addAdvice(ti);
    proxyFactory.setTarget(tb);
    ITestBean proxy = (ITestBean) proxyFactory.getProxy();
    proxy.getAge();
    assertEquals(1, ptm.commits);

    ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
    serializedProxy.getAge();
    Advised advised = (Advised) serializedProxy;
    TransactionInterceptor serializedTi = (TransactionInterceptor) advised.getAdvisors()[0].getAdvice();
    CallCountingTransactionManager serializedPtm =
        (CallCountingTransactionManager) serializedTi.getTransactionManager();
    assertEquals(2, serializedPtm.commits);
  }
View Full Code Here

TOP

Related Classes of org.springframework.transaction.interceptor.TransactionInterceptor$ThrowableHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.