One year ago, when [tag]Rod Johnson[/tag] addressed Irish Java developers in [tag]Cork[/tag], he gave us a scoop. [tag]Interface21[/tag] (the company behind the [tag]Springframework[/tag]) had just acquired [tag]Adrian Colyer[/tag] (the brains behind AspectJ, the main implementation of [tag]AOP[/tag] in Java). It was an intriguing piece of news that seemed to open up a lot of new avenues for the way in which Spring could be used, though of course it was hard to visualize exactly what the outcome of this collaboration would be. Yesterday afternoon, twelve months on, Adrian himself came to Cork to show us exactly what they’ve been doing, and to hand us another scoop.
The timing was perfect. Adrian talked for an hour during which time the countdown to the official [tag]Spring 2.0[/tag] launch hit zero. Adrian reckoned, based on what he knew his Interface21 colleagues to be doing at that moment, that he was the first to be able to make the announcement in person to the Java development community. Spring 2.0 has a lot of new and exciting features, some of which we’ve already discussed on this blog, but in large part it represents the fruit of Adrian’s collaboration. His presentation storyboarded the way in which he expects AOP to be used in a Spring context. By the end of the talk, it was clear what had just happened: Spring had acquired an entire extra dimension.
When describing [tag]Spring[/tag] in the past, I have always said that it was made of two parts: The underlying Dependency Injection substrate, and the gamut of service abstractions that can be embedded into this substrate. Now there is a third dimension which unlocks the simplifying power of Spring: AOP. Spring is able to interpret the [tag]AspectJ[/tag] Pointcut syntax and apply most kinds of advice using its own Proxy-based mechanisms (i.e. without weaving with AspectJ’s compiler). This is emphatically not simply another service abstraction bolted on to the DI container. It is a new mechanism within Spring which uses the power of pointcuts to:
- Greatly simplify the Spring configuration required to perform interception
- Move the level of abstraction behind this interception up a notch to the architectural point of view
As Adrian put it, it allows us to use the abstract vocabulary of architecture in the implementation. We can identify the architectural layers of our code with pointcuts, and apply high-level rules to these layers using advice. I particularly like this approach as it blurs the lines further between architect and developer: The architects can (must!) express themselves in the implementation, and the developers can see, understand and manipulate these architectural ideas directly in the code.
A very attractive feature of Spring 2.0’s approach to AOP is it’s use of [tag]Java Annotations[/tag]. Adrian coined the term “annophobe” to describe those with an irrational fear of annotations. I’m more of an “annognostic” – I just don’t know much about this side of Java 5 yet. But having seen them in action yesterday, I’ll be hitting the books immediately. By annotating normal java classes and methods as aspects, pointcuts, advice etc, the developer is free to let those annotations be interpreted by Spring or by AspectJ – or both. This is too efficient to ignore, so anyone who intends to use Spring AOP will need to deal with any annophobia issues – and make a case for developing and deploying on the Java 5 platform.
Adrian’s talk was part of [tag]it@cork[/tag]’s Java conference, and he shared the platfrom with Sun’s [tag]Simon Ritter[/tag]. The volume of interesting, useful and well-presented information from both speakers was such that it will take more than one blog entry to cover it, but I would like to thank both Simon and Adrian for bringing their world-class perspectives on their fields to Cork’s development community. The event itself was exceptionally well organized – I have rarely seen such a punctual and smoothly run operation – so a big thank you to Catherine Wall and Deirdre Lacey of it@cork.
Watch this space for more blogs on this event.
– brendan lawlor –