Fork me on GitHub

Thank you for visiting this blog. If you like what you read here, you can follow my new blog at www.nilswloka.com and read about my reasons for this "rebranding" here.

Live from SpringOne 2008 - Spring 2.5 on the way to 3.0

Posted on 06/11/08.

As all of you probably know of the nice new features that arrived with Spring 2.5, I'm going to concentrate on the "gems" I harvested from Jürgens presentation. As for the 3.0 stuff, I'm going to collect the various bits of information that seem to pop up in various talks and write about it once I find the time to put all the pieces of the puzzle together...

One of the main themes in Spring 2.5 has been the progression towards Java 5 and JEE 5 programming models (e.g. by means of annotation driven configuration options and support for JEE annotations). The other apparent trend was the advent of load-time weaving as alternative to the traditionally proxy-based AOP model in earlier Spring releases. As Jürgen explained the major features that have been introduces in this context, he mentioned a couple of not so obvious facts about Spring 2.5 that I'd like to relay to you:

Registering custom annotations for component scan

You can write your own stereotype annotations (yes, completely independent from the Spring annotations) and make the container automatically pick up your annotated components by supplying filters to the ClassPathBeanDefinitionScanner responsible for determining valid candidates. See the documentation) for details. This sounds great for implementing domain-driven design principles by providing intention revealing annotations.

OpenJPA save point support

Spring's OpenJpaVendorAdapter exposes OpenJPA's extended EntityManager implementation. As Spring's JpaTransactionManager has support for JDBC 3.0 savepoints, this eventually allows you to use OpenJPA's save point semantics. I'll make sure to give this a try and blog about how it works.

LTW mode for <tx:annotation-driven>

All of you know about the annotation driven transaction demarcation, which is usually done by the application context scanning your classes for @Transactional and wrap them in Proxies. While this usually works great, there is, as various forum threads suggest, some amount of confusion regarding the limits of dynamic proxies, mainly when transaction propagation doesn't work as expected with "class-internal" method calls. As I just learned, you can alleviate that problem by enabling load-time weaving via an agent or the custom classloader implementations that are bundled with Spring and configuring the transaction support with an additional attribute like shown here (ommiting the loadtime weaving configuration itself):

<tx:annotation-driven mode="aspectj"/>

Neat, isn't it? Methods annotated with @Transactional will be augmented during load-time afterwards, no more proxies are needed.

Well, that's it for now, I'm off to listen to Mark Fisher's talk about Spring Integration.

blog comments powered by Disqus