Java Reference
In-Depth Information
The ability to define custom AOP interceptors can be extremely useful and elimi-
nates the need to write the code by hand or use a code generator.
12.4.2
Configuring the AOP interceptor
The TransactionRetryInterceptor must be configured to intercept calls to trans-
actional classes such as RestaurantNotificationService or RestaurantNotifica-
tionTransactionScripts . Furthermore, it must be applied to the POJO class
before the TransactionInterceptor so that it is not executed as part of the trans-
action. In this example, we configured a Spring BeanNameAutoProxyCreator to
wrap the RestaurantNotificationService with a TransactionRetryInterceptor
and then a TransactionInterceptor :
<beans>
<bean id="transactionProxyCreator"
class="org.springframework.aop.framework.autoproxy.
bbbbbb BeanNameAutoProxyCreator">
<property name="beanNames">
<idref name="DomainRestaurantNotificationService"/>
</property>
<property name="interceptorNames">
bbbb <list>
bbbb <idref name="TransactionRetryInterceptor"/>
bbbb <idref name="TransactionInterceptor"/>
bbbb </list>
</property>
</bean>
<bean id="DomainRestaurantNotificationService"
class="net.chrisrichardson.foodToGo.restaurantNotificationService.
bbbbbb b
impl.DomainRestaurantNotificationService">
</bean>
<bean id="TransactionRetryInterceptor"
class="net.chrisrichardson.foodToGo.util.
bbbbbb b
TransactionRetryInterceptor">
<property name="maxRetryCount"><value>5</value></property>
</bean>
<bean id="TransactionInterceptor"
class="org.springframework.transaction.interceptor.
bbbbbb b
TransactionInterceptor">
</bean>
</beans>
 
Search WWH ::




Custom Search