« Early Christmas Presents... Early New Year's Resolution | Main | AJDT 1.2.0 M2 Released »

December 14, 2004

AspectJ at JavaPolis 2004

Yesterday was the first day of the JavaPolis 2004 University. I gave a three-hour session on "AspectJ in Action". (All the University session titles were of the form "XXX in Action"; "AspectJ in Action" also happens to be the title of Ramnivas' excellent book so I hope he forgives me - especially now I've given him a plug :) ).

They have a great setup here for JavaPolis - the conference takes place in a cinema complex with the sessions being held in the different screening rooms. That meant I got a great big room with a great big screen to project onto - perfect for showing off AJDT. The audience had to sit straight through for 2.5 hours with no break since a change in the conference start time ate up the morning coffee break. I tried to make the show as gripping as a Lord of the Rings film, but this was hard as the emotional content of the talk was fairly low and I wasn't fully able to exploit the surround sound system! Still, there was plenty of drama in the talk for me at least, since it was laced with live demos.

Highlight of the talk from my perspective was the live demonstration of Hibernate persistence using AspectJ - first time I've done that for an audience. I configured AJDT so that I could start mysqld as an external command straight off the Eclipse toolbar, and then set breakpoints in some around advice doing session management, some before advice doing session dependency injection, and a couple of DAO methods themselves. Then I launched the whole thing in the debugger and we stepped through it as we drove the DAOs through the UI. Everything worked perfectly - AJDT stopped in the around advice, we were able to step through it and then when we stepped over the "proceed()" call we immediately hit the breakpoint in the before advice (next in chain), and on stepping through that we went into the DAO method itself. We step returned back into the around advice to commit the transaction and return. The debugger really is a great teaching tool for illustrating AspectJ's dynamic join point model and helping people to understand the runtime flow of control of AspectJ applications. I think I will use this technique more often in future talks.

If you want to try this at home, a top tip for debugging around advice is to set the "no inline" option in the AspectJ compiler preferences page (advanced tab) - this causes AspectJ to generate much more "debugger friendly" code for around advice. Don't use this option in your ant builds though unless you really know that you want it for some reason since the generated code runs slower than inlined around advice does.

In the afternoon I got to go to the "Neal Gafter and Joshua Bloch" show (aka "Java 5 in Action"). The most striking thing for me was probably the title slide with the Google logo on it - reminding me that both of these guys have now left Sun and work for Google, amazing. Good to see that they're still able to come and give talks such as this though, and they promised to stay involved in the future development of Java through the JCP. (One of the AspectJ committers, Erik Hilsdale, is now a Google employee too - they really are a talent magnet at the moment). Their talk was a double-act tour through the new language features in Java 5. Nothing earth-shatteringly new (but then I have been crawling over the specs as part of the AspectJ 5 development so I'd hope not really), but the many repeated examples of code snippets did bring home two points very well: programs written in the Java 5 language really can be simpler and more concise; and the new language features are all very synergistic.

Posted by adrian at December 14, 2004 09:19 AM [permalink]

Comments

Adrian,

That Hibernate aspect sounds interesting. Have you got a link to it?
Cheers,
Joost

Posted by: Joost de Vries at December 19, 2004 06:32 PM

The example (and many others from the talk) were drawn from our book that's just about to hit the warehouses (Eclipse AspectJ). At the same time as it starts shipping, the book website will be updated to include downloads of all the examples in the book via an Eclipse update site. So, whilst I don't have a link for you right now, you should be able to get not just that one aspect but the whole setup from the Addison-Wesley site within the next month...

Posted by: Adrian at December 19, 2004 09:16 PM

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?