Home > Tech > Spring 1.2 Java 5 Based Transaction Annotations

Spring 1.2 Java 5 Based Transaction Annotations

Colin Sampaleanu posted an excellent article on Spring 1.2’s Java 5 Based Transaction Annotations, if you want to follow this approach but don?t want the DefaultAdvisorAutoProxyCreator to pick up every available Advisor in the context, here what you can do

<bean name=”defaultAdvisor”
class=”org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator”>
<property name=”usePrefix” value=”true”/>
</bean>
<bean name=”defaultAdvisor.transactionAttributeSourceAdvisor”
class=”org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor”>
<property name=”transactionInterceptor” ref=”transactionInterceptor”/>
</bean>
<bean id=”transactionInterceptor”
class=”org.springframework.transaction.interceptor.TransactionInterceptor”>
<property name=”transactionManager” ref=”transactionManager”/>
<property name=”transactionAttributeSource”>
<bean
class=”org.springframework.transaction.annotation.AnnotationTransactionAttributeSource”/>
</property>
</bean>

Create you DefaultAdvisorAutoProxyCreator as mentioned but give it a name (defaultAdvisor in this case) and set the usePrefix property to true.

Then in all the advisors that you want to be picked up, change there name to have ‘defaultAdvisor.’ prefix.

The usePrefix property tells the DefaultAdvisorAutoProxyCreator to apply only those Advisors that have a prefix of its own name.

Alternatively you can also use the AdvisorBeanNamePrefix to tell the DefaultAdvisorAutoProxyCreator what prefix to consider.

Categories: Tech
  1. Alexwebmaster
    March 3, 2009 at 5:20 am | #1

    Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

  1. No trackbacks yet.