Search in sources :

Example 1 with TransactionAttributeSource

use of org.springframework.transaction.interceptor.TransactionAttributeSource in project spring-framework by spring-projects.

the class TxNamespaceHandlerTests method rollbackRules.

@Test
public void rollbackRules() {
    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()));
}
Also used : TransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource) ITestBean(org.springframework.tests.sample.beans.ITestBean) TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) TransactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute) Test(org.junit.Test)

Example 2 with TransactionAttributeSource

use of org.springframework.transaction.interceptor.TransactionAttributeSource in project uPortal by Jasig.

the class DialectAwareTransactionInterceptor method getTransactionAttributeSource.

@Override
public TransactionAttributeSource getTransactionAttributeSource() {
    TransactionAttributeSource tas = this.wrappedTransactionAttributeSource;
    if (tas == null) {
        final TransactionAttributeSource transactionAttributeSource = super.getTransactionAttributeSource();
        if (this.dialects.isEmpty()) {
            return transactionAttributeSource;
        }
        tas = new TransactionAttributeSourceWrapper(this.dialects, transactionAttributeSource);
        this.wrappedTransactionAttributeSource = tas;
    }
    return tas;
}
Also used : TransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource)

Aggregations

TransactionAttributeSource (org.springframework.transaction.interceptor.TransactionAttributeSource)2 Test (org.junit.Test)1 ITestBean (org.springframework.tests.sample.beans.ITestBean)1 TransactionAttribute (org.springframework.transaction.interceptor.TransactionAttribute)1 TransactionInterceptor (org.springframework.transaction.interceptor.TransactionInterceptor)1