O'Reilly logo

Eclipse AspectJ: Aspect-Oriented Programming with AspectJ and the Eclipse AspectJ Development Tools by Matthew Webster, George Harley, Andy Clement, Adrian Colyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Using the AspectJ API

Chapter 7, Section 7.3.1, discussed the use of the special variables thisJoinPoint, thisJoinPointStaticPart, and thisEnclosingJoinPoint StaticPart inside advice bodies. In this chapter, we explore the API provided by AspectJ’s runtime library (aspectjrt.jar), and show how you can make full use of these variables.

Listing 10.1 shows a very simple application, MyApp, which we will use as the basis of the exploration.

Example 10.1. MyApp

 package business; public class MyApp { private String mostRecentCmd; private void repeat() { repeat(1); } private void repeat(int attempts) { if (this.mostRecentCmd != null) { doSomething(mostRecentCmd, attempts); } else { System.out.println("Nothing to repeat."); } } private void ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required