AspectJ in Action

AspectJ in Action: Practical Aspect-Oriented Programming

This book, which has been labeled as the most useful guide to AOP/AspectJ, explains the AOP methodology and the AspectJ language. This book shows modularizing system-wide concerns such as logging, policy enforcement, resource pooling, caching, thread-safety, authentication and authorization, transaction processing, and business rule by synergistically combining AspectJ with technologies such as log4j, JAAS, JTA, JDBC, Swing, and Jess.

Book information

A software system is the realization of a set of concerns. One of the central premises of object-oriented programming is that each concern should be implemented as a separate module. However, there are certain system-wide concerns, such as logging, security, performance, and so forth, that often need to be addressed in many, if not all of the modules. Consequently, the code to handle these system-wide concerns may be mixed in with the core logic of a huge number of modules, resulting in lower productivity, poor quality, and systems that are hard to evolve. Aspect-oriented programming (AOP) overcomes these problems by modularizing the system-wide concerns.

AspectJ enables AOP programming in Java by adding a few new language constructs. By using Java as the base language and creating a final system that is compatible with Java byte code specification, AspectJ passes on all the benefits of Java. The use of Java as the base language also makes AspectJ a relatively easy language to learn.

The book is divided into three parts. The first part introduces AOP and AspectJ and will be helpful to developers wanting to learn or advance their knowledge of AspectJ. The second and third parts present examples of everyday situations in which you can use simple and easy AspectJ solutions to implement common system requirements such as logging, policy enforcement, resource pooling, business rules, thread-safety, authentication and authorization, as well as transaction management.

What's inside:

What the readers say about AspectJ in Action

"There are already several books about AspectJ--one of its major advantages....My favorite is AspectJ in Action..."
-- Rod Johnson (Spring framework co-founder) in J2EE Development without EJB
" of the clearest expositions of AOP and its benefits that I have seen...It is obvious that a lot of care and attention has gone into the preparation of the material. I particularly liked the very clear illustrations and annotated code examples. These chapters can be followed by someone completely new to AspectJ, but also contain nuggets of information for the more experienced AspectJ programmer too, with good sections on aspect association and precedence for example....For the more experienced AspectJ programmer, a real treasure in this part of the book is the patterns introduced in chapter 8 and then employed in the remaining examples...these patterns have already made their way into my everyday vocabulary when working with AspectJ. All of the examples in the book are anchored in the technologies used on real-world projects such as log4j, JAAS, JTA, Ant and so on... This is the book I recommend when people ask me for a good way to learn about AOP and AspectJ."
-- Adrian Colyer (AspectJ project lead) in The Computer Journal
" of the few technical books that has blown my hair back -- ramnivas laddad has outdone himself with this book. ...i walked away feeling as though i had actually grown as a developer. ...the book also builds quite well. the progression of the text is extremely logical and culminates in the last three chapters with an in-depth example of practically how the various aop techniques can be applied. i was in need of convincing before considering embracing aop, but no longer. ...i would recommend this book to anyone considering embracing aop -- you will not need any more convincing after reading this book."
-- Alex Winston at
" far the best programming related book I read for a long time. Especially, I enjoyed the structure of the book, which gives someone who has no clue about AOP an idea what it is all about. The examples are great and there are no logical gaps...suitable for the beginner and expert, covers all AOP relevant topics and drills further down on advanced AOP techniques."
"...a wonderful job of introducing the new AOP other book succeeded to present the challenges of AOP so well...a very good resource for both people starting to learn AOP and AspectJ and experienced AOP programmers who wish to deepen their knowledge in this new area."
"I would highly recommend AspectJ in Action for anyone who is interested in AOP.... I liked the practical angle, and you could tell that Ramnivas has really used AOP/AspectJ on his projects."
-- Dion Almaer at
"...I would recommend going with AspectJ in will get the most bang for your buck from Ramnivas' work...The subject-oriented approach in this book lends itself well to future reuse."
"AspectJ in Action by Ramnivas Laddad looks like a very clear and complete treatment of aspects.... filled with very good diagrams... This book will definitely help."
"...AJIA was exactly what I needed...Fantastic use of diagrams, figures, and annotated code. They solidly add to understanding the content...I found the book to really be excellent from all viewpoints for getting into the subject matter from many angles and diving down very deep into it."
-- Mike Spille at
"... provides you out-of-box working codes to attack real world problems. The design patterns introduced in the book are most helpful. They let you feel the power of AOP. The book content are well organized and easy to understand.... "I can only show you the door. You have to walk through it." --From Matrix.The author surely did that."
"explains how to transform a pure Java based solution to a cleaner, more structured AspectJ solution. The reader can see that the AspectJ solution is more elegant and can always understand how Ramnivas came to his solutions."
"...The author succeeds brilliantly in gradually building your understanding of AOP, then AspectJ's own semantics, and then the coding possibilities these offer. The writing is clear and accessible, the content expertly graduated. ... Even though I have now read it through, this book will serve as my first point of reference for the patterns I need as I venture into the world of AOP. My thanks to the author for a superb book."
"You know, it's one of these books about technologies you always thought too "ivory tower", too bloated and complex to use and suddenly discover that heeeey this is nice and may prove useful."