Search in sources :

Example 1 with MatchAlwaysTransactionAttributeSource

use of org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource in project spring-integration by spring-projects.

the class DelayerParserTests method transactionalSubElement.

// INT-2649
@Test
public void transactionalSubElement() throws Exception {
    Object endpoint = context.getBean("delayerWithTransactional");
    DelayHandler delayHandler = TestUtils.getPropertyValue(endpoint, "handler", DelayHandler.class);
    List<?> adviceChain = TestUtils.getPropertyValue(delayHandler, "delayedAdviceChain", List.class);
    assertEquals(1, adviceChain.size());
    Object advice = adviceChain.get(0);
    assertTrue(advice instanceof TransactionInterceptor);
    TransactionAttributeSource transactionAttributeSource = ((TransactionInterceptor) advice).getTransactionAttributeSource();
    assertTrue(transactionAttributeSource instanceof MatchAlwaysTransactionAttributeSource);
    Method method = MessageHandler.class.getMethod("handleMessage", Message.class);
    TransactionDefinition definition = transactionAttributeSource.getTransactionAttribute(method, null);
    assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, definition.getPropagationBehavior());
    assertEquals(TransactionDefinition.ISOLATION_DEFAULT, definition.getIsolationLevel());
    assertEquals(TransactionDefinition.TIMEOUT_DEFAULT, definition.getTimeout());
    assertFalse(definition.isReadOnly());
}
Also used : NameMatchTransactionAttributeSource(org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource) TransactionAttributeSource(org.springframework.transaction.interceptor.TransactionAttributeSource) MatchAlwaysTransactionAttributeSource(org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource) TransactionDefinition(org.springframework.transaction.TransactionDefinition) DelayHandler(org.springframework.integration.handler.DelayHandler) TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) Method(java.lang.reflect.Method) MatchAlwaysTransactionAttributeSource(org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource) Test(org.junit.Test)

Example 2 with MatchAlwaysTransactionAttributeSource

use of org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource in project spring-integration by spring-projects.

the class TransactionInterceptorBuilder method transactionAttribute.

public final TransactionInterceptorBuilder transactionAttribute(TransactionAttribute transactionAttribute) {
    MatchAlwaysTransactionAttributeSource txAttributeSource = new MatchAlwaysTransactionAttributeSource();
    txAttributeSource.setTransactionAttribute(transactionAttribute);
    this.transactionInterceptor.setTransactionAttributeSource(txAttributeSource);
    return this;
}
Also used : MatchAlwaysTransactionAttributeSource(org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource)

Aggregations

MatchAlwaysTransactionAttributeSource (org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource)2 Method (java.lang.reflect.Method)1 Test (org.junit.Test)1 DelayHandler (org.springframework.integration.handler.DelayHandler)1 TransactionDefinition (org.springframework.transaction.TransactionDefinition)1 NameMatchTransactionAttributeSource (org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource)1 TransactionAttributeSource (org.springframework.transaction.interceptor.TransactionAttributeSource)1 TransactionInterceptor (org.springframework.transaction.interceptor.TransactionInterceptor)1