Chapter 7. Diving into the @AspectJ syntax
This chapter covers
- Mapping pointcuts
- Mapping dynamic and static crosscutting
- Understanding the limitations of the syntax
One-size-fits-all usually fits nothing! Over the last few years, the AspectJ community realized that a single syntax style and one weaving model didn’t meet all the needs of real-world AOP usage. AspectJ responded to the real world’s needs by offering pragmatic choices for syntax and weaving models. With the new choices, using AspectJ is easier than ever before. In this chapter, we’ll examine a major alternative to the traditional syntax. The next chapter will deal with weaving models.
Until now in this book, we’ve focused on the traditional syntax, which excels in its power, expressiveness, and compactness. But using it requires a leap of faith, due to the need to use a different compiler and other tools (mainly an IDE) that can understand such syntax. For a pragmatic adoption, we need a smoother path and reduced dependency on specialized tools. The @AspectJ (often pronounced as “at AspectJ”) syntax offers the option of compiling source code with a plain Java compiler and makes it easier to work with any Java IDE. If you’re in a situation where you can’t afford to make an outright switch to the AspectJ compiler, the @AspectJ syntax offers you a compelling alternative.