Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting multiple transaction attribute sources [SPR-1735] #6432

spring-issuemaster opened this issue Feb 21, 2006 · 1 comment

Supporting multiple transaction attribute sources [SPR-1735] #6432

spring-issuemaster opened this issue Feb 21, 2006 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Feb 21, 2006

Sabarish Sasidharan opened SPR-1735 and commented

The BeanNameAutoProxyCreator supports a single transaction attribute source. I just came across a scenario wherein our project would find it easier if multiple transaction attribute sources are supported. This way we can have generic definitions for get*, set* etc in a NameMatchTxSource and then override when there is a need using a MethodMapTxSource.

I was not able to find this functionality. If it is not available already then instead of modifying the BeanNameAutoProxyCreator, i think it would be easier to add a TransactionAttributeSource implementation that maintains a list of references to other transaction attribute sources defined in the spring config file. This impl when requested for a transaction attribute def could then consult each of these references in the list's default order and return the first non null transaction attribute definition it gets.

A simple implementation is pasted below.

public class TransactionAttributeSourceList implements
TransactionAttributeSource {

private List transactionSources;

 * @see org.springframework.transaction.interceptor.TransactionAttributeSource#getTransactionAttribute(java.lang.reflect.Method, java.lang.Class)
public TransactionAttribute getTransactionAttribute(Method arg0, Class arg1) {
    /* First get from method based source */
    TransactionAttribute txAttr = null;
    for (int i = 0; i < transactionSources.size(); i++) {
        txAttr = (TransactionAttributeSource(transactionSources.get(i)).getTransactionAttribute(arg0, arg1);
        if (txAttr != null) {
            return txAttr;
    return null;

public List getTransactionSources() {
    return transactionSources;
public void setTransactionSources(List transactionSources) {
    this.transactionSources = transactionSources;


No further details from SPR-1735


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 6, 2006

Juergen Hoeller commented

Thanks for the suggestion! I've added a CompositeTransactionAttributeSource for programmatic use, and a "setTransactionAttributeSources(TransactionAttributeSource[])" method to TransactionAspectSupport (inherited by TransactionInterceptor).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.