Before Advice in Spring 2.0

Ben Hale

As most of you know, one of the big improvements in Spring 2.0 is the addition of the AspectJ pointcut language and better integration with AspectJ in general. While I think everyone believes that this will be a great benefit in the long run, it has led to some issues. We've found that there are certain behaviors that Spring AOP has always done, that AspectJ has never done.

One of the big issues that cropped up was the behavior of Before advice. If you've used Spring AOP in Spring 1.x you probably know that Spring allows you to change argument values before they are passed to the target method. What you may not know is that AspectJ has never allowed this behavior.

What does this mean to you, the user? Well it depends on what you plan to do in the future. We've decided that if you are continuing to use the AOP Alliance interfaces for your AOP, you'll continue to get the same semantics that you've always gotten; nothing will have changed. If you use the AspectJ pointcut language in the future you'll get accurate AspectJ semantics. If you want to use AspectJ's pointcut language but still want to make changes to argument values, it is possible but you'll need to obey AspectJ's semantics and use Around advice instead of Before advice.

So in the end, we've still managed to meet our goal of drop-in replacement, while adhering to AspectJ semantics where appropriate.



P.S. This post serves as an obituary for the late great 'Penc Smith'. If you've taken the Core Spring training from Interface21 you'll know what I'm talking about. If not, come see me at The Spring Experience or No Fluff Just Stuff and I'll tell you the story over a pint.
 

2 responses


My dear Ben

This post serves as an obituary for the late great 'Penc Smith'.

Flabbergasted is the only reaction that I can admit to having upon reading those words this morning; indeed, I almost choked quite to death on my morning repast (toast spread with a most delicious gooseberry-and-burrdock preserve from Mrs. Warbuton's 'Ye Olde Farme Shoppe' down in Chipping Sodbury - it is really quite excellent; I can certainly send you a few jars if you like, just let me know).

For the record, I have most certainly not departed this most mortal of coils, thanks in most part to darling Bunty's celerious application of the Heimlich maneuver. With regard to the evident semantic differences between Spring AOP and AspectJ before advice, I trust that said differences will be documented in the Spring reference documentation?

I remain, as ever, your most humble - if slightly miffed - servant
Penc

P.S. If you want some of Mrs. Warbuton's 'Grande Gooseberry And Burrdock Preserve', please do send me your postal address forthwith.


As a very important distinction, it will be documented if it is not already ;)

Leave a Reply

Quote selected text

loading Posting your comment.


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser