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”
<property name=”usePrefix” value=”true”/>
<bean name=”defaultAdvisor.transactionAttributeSourceAdvisor”
<property name=”transactionInterceptor” ref=”transactionInterceptor”/>
<bean id=”transactionInterceptor”
<property name=”transactionManager” ref=”transactionManager”/>
<property name=”transactionAttributeSource”>

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.

One thought on “Spring 1.2 Java 5 Based Transaction Annotations

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s