Monday, January 24, 2005

Spring pointcut on steroids

(imported from, read comments there)

Three months ago when we wrote the AWBench AOP benchmark suite, I had to hack some little Spring AOP aspect and pointcuts.

If you are familiar with Spring and know about AOP (AspectJ, AspectWerkz, JBoss etc), you know that Spring pointcuts are rather ... well sadly un-intuitives.
They might be for new users, but not anymore when you have very basic AOP knowlegde, and you are more and more !

I could not resist and integrating Spring with AspectWerkz pointcut (yes, once again for the third time, after the Spring container Jonas did and the extensible container we shipped.)

A Spring pointcut before the wedding with AspectWerkz - almost impossible to combine with other patterns unless you have your "Mastering Spring XML" in the pocket...

<bean id="theMethodExecutionGetTargetAndArgsAroundAdvisor1"
<property name="advice">
<ref local="theMethodExecutionGetTargetAndArgsAroundAdvice"/>
<property name="pattern">

Spring pointcut as a real pointcut thanks to the wedding with AspectWerkzPointcutAdvisor

<bean id="theMethodExecutionAfterThrowingAdvisor"
<property name="advice">
<ref local="theMethodExecutionAfterThrowingAdvice"/>
<property name="expression">
<value>execution(* *..*.afterThrowingRTE(..))</value>

Such a basic code source is there and should perhaps be reviewed by Spring guys for some of the API details.

The great news is that this will be part of a next release of Spring, and details will be handled by the AspectJ 5 engine instead. That was about time ;-)