Monday, November 1, 2010
AspectJ in Action
This book is divided into three parts. If you are new to AOP and AspectJ, you
should first read part 1 followed by at least a couple of chapters in part 2. Within
part 3, you can read chapters in any sequence. If you find that one of the sections
specifically addresses your current problem, start using the techniques I present,
learn from the experience, and go from there. You can also choose to study all
the other chapters and apply hybrid techniques to suit your current needs.
Most chapters in parts 2 and 3 follow a pattern of presenting a conventional
solution followed by an AspectJ solution that implements the identical functionality.
This pattern provides better understanding of the problem domain, and
comparing the two solutions shows the effectiveness of AspectJ.
Part 1 introduces the aspect-oriented programming methodology and the
Chapter 1 introduces the problems aspect-oriented programming aims to
address and explains how it handles them. We discuss the concern decomposition
of a system, the classification of concerns, and issues with current implementations
of crosscutting concerns. We then show how AOP helps modularize
Chapter 2 introduces the AspectJ programming language. We discuss the various
language concepts and constructs. The join point model presented in this
chapter is the most fundamental concept in AspectJ. We finish the chapter by
briefly showing the IDE support for AspectJ.
Chapter 3 gets into the details of the AspectJ language by examining the
concepts of pointcuts, advice, the introduction mechanism, and so forth.
This chapter provides you with enough information to start writing simple
Chapter 4 shows the advanced concepts in AspectJ that you need to understand
before you start writing nontrivial AspectJ programs.
Part 2 examines the real-world application of AspectJ using simple constructs.
Chapter 5 introduces logging and monitoring using AspectJ. We show how
AspectJ includes logging in a system without touching any of its core modules.
You’ll also see the ease with which you can switch between different logging APIs.
Chapter 6 shows how to enforce system wide contracts through policy-enforcement
aspects. We offer a few simple examples that serve as building blocks. Then we
describe an implementation of a UI application and EJB policy enforcement.
Chapter 7 examines how AspectJ can modularize the optimization concerns of
pooling and caching. We study a generic template and utilize it to address the
concrete challenges of JDBC connection and thread pooling. We finish the chapter
with a caching example.
Part 3 examines the advanced application of AspectJ. You must have a good
understanding of AspectJ before reading this part of the book.
Chapter 8 introduces a few brand-new AspectJ patterns. We also show a few
idioms to avoid certain common pitfalls. Some of these patterns are original con
tributions from the author. This chapter is required reading before you tackle
any of the remaining chapters in part 3, because all of the chapters use one or
more of the patterns we present.
Chapter 9 addresses the modularization of thread safety using AspectJ. We
specifically address two problems: the thread safety of Swing applications and
the read-write lock pattern.
Chapter 10 examines the use of AspectJ for authentication and authorization.
We utilize JAAS to implement the underlying authentication and authorization
functionality and use AspectJ to achieve modularization.
Chapter 11 explains how AspectJ can separate the transaction concern from
the core concern. We examine a JDBC-based as well as a JTA-based transaction.
Chapter 12 shows a novel application of AspectJ—we utilize it to modularize
business rule implementations. We discuss AspectJ-based solutions that use plain
Java as well as a rule engine (Jess) that evaluates the business rules.
Chapter 13 rounds out the book by showing a pragmatic approach to adopting
The two appendices explain, in detail, how to use the AspectJ compiler and
AspectJ/Ant integration. In “Resources,” you will find a wealth of information,
both text and online, related to AspectJ.
Another Java Books
Another Software Engineering Books