User Tools

Site Tools


basics:ex2

Intro Ex1 Ex2 Ex3 Ex4 Ex5 Ex6 Ex7

The Basics: Exercise 2

Add another advice to the Basics aspect to print out a message immediately before the execution of all methods of Application whose name starts with the letters “st”.

Inside the signature pattern, you can use the wildcard * to match any type or identifier (or any type or identifier with a certain beginning). As part of the argument list, you can use .. to match any number of arguments.

Since the advice applies to different methods, print the signature of the join point in the advice body using the following snippet:

output("ex2",thisJoinPoint.getSignature());
Inside an advice, the reserved variable thisJoinPoint provides access to runtime information about the join point. It is of type JoinPoint.

Rerun the application and verify that the aspect outputs a signature for methods start and stop.


Continue with Exercise 3.

basics/ex2.txt · Last modified: 2021/02/05 13:49 by 127.0.0.1