My association with AOP and AspectJ has now lasted more than a decade. I still remember my initial experience with AspectJ around 1998 and more serious exploration in 2002. It felt like a breath of fresh air that finally addressed some of the shortcomings of object-oriented programming. My initial experimentation led me to write an article series in JavaWorld in 2002 and the first edition of this book in 2003. After writing the book, I gave talks at many conferences about facets of AOP and AspectJ, and how to use them with the Spring Framework commonly referred to as Spring. Over the last few years, as a Spring committer, I have been trying to improve Spring-AspectJ integration. While doing this, I have been actively using these technologies on many projects. This book is a reflection of my experience with the technologies, understanding the best ways to explain them, and finding pragmatic ways to adopt them.
A lot has changed since the publication of the first edition of this book. Back then, AspectJ was a new language, Spring had just come out, and alternative languages on the Java platform were far fewer. Now, AspectJ is a 10-year-old language, Spring is the de facto lightweight framework for developing enterprise software, and new languages on the Java platforms are numerous.
Yet some things haven’t changed. Software complexity is still increasing at breakneck speed. Our ability to cope with complexity remains essentially unaltered. As a result, our search for better ways to reduce implementation complexity also remains unchanged. These factors make AOP implemented using AspectJ an important tool in an enterprise Java developer’s toolbox.
The changes to AspectJ have been dramatic. It now includes two syntax possibilities: the traditional syntax and the annotation-based @AspectJ syntax, which lowers the barrier to begin using AspectJ. It supports many weaving possibilities, including load-time weaving, making the use of AspectJ for applications such as monitoring and tracing a simple experience. To top it off, Spring has adopted AspectJ’s programming model as its AOP solution. This caused the Spring community to be drawn to the power of AOP with AspectJ as the preferred programming model.
Below the surface, significant changes have also taken place. SpringSource (now part of VMWare) is sponsoring AspectJ development. Due to the complexity involved on the compiler and tools front, projects such as AspectJ require serious attention. Full-time development afforded by SpringSource support has been crucial in recent years.
And so, it was time to write a new edition of AspectJ in Action. My initial thought was that I would update most chapters with new AspectJ features and update a few examples. I estimated the overall effort would take six months. Boy, was my estimate off the mark! It took more than three years to update and re-update the book. There were many reasons (besides being busy at my day job). AspectJ kept improving over the last three years. The ecosystem surrounding Spring changed dramatically. Through my consulting experience, my understanding of the problems that AOP is trying to solve and its adoption in the real world changed, as well. Therefore, many examples from the first edition wouldn’t work any more, even if I gave them a facelift. Like the first edition, I wanted this book to be of immediate practical value. Therefore, I decided to rewrite many of the chapters and most of the examples. I’m glad that I took that path.
I humbly hope that you’ll appreciate my effort, like this book, and use it in your applications.