use of org.springframework.integration.transaction.TransactionHandleMessageAdvice in project spring-integration by spring-projects.
the class IntegrationNamespaceUtils method configureTransactionAttributes.
/**
* Parse a "transactional" element and configure a {@link TransactionInterceptor}
* or {@link TransactionHandleMessageAdvice}
* with "transactionManager" and other "transactionDefinition" properties.
* For example, this advisor will be applied on the Polling Task proxy.
* @param txElement The transactional element.
* @param handleMessageAdvice flag if to use {@link TransactionHandleMessageAdvice}
* or regular {@link TransactionInterceptor}
* @return The bean definition.
* @see AbstractPollingEndpoint
*/
public static BeanDefinition configureTransactionAttributes(Element txElement, boolean handleMessageAdvice) {
BeanDefinition txDefinition = configureTransactionDefinition(txElement);
BeanDefinitionBuilder attributeSourceBuilder = BeanDefinitionBuilder.genericBeanDefinition(MatchAlwaysTransactionAttributeSource.class);
attributeSourceBuilder.addPropertyValue("transactionAttribute", txDefinition);
BeanDefinitionBuilder txInterceptorBuilder = BeanDefinitionBuilder.genericBeanDefinition(handleMessageAdvice ? TransactionHandleMessageAdvice.class : TransactionInterceptor.class);
txInterceptorBuilder.addPropertyReference("transactionManager", txElement.getAttribute("transaction-manager"));
txInterceptorBuilder.addPropertyValue("transactionAttributeSource", attributeSourceBuilder.getBeanDefinition());
return txInterceptorBuilder.getBeanDefinition();
}
Aggregations