User Tools

Site Tools


basics:ex1

Intro Ex1 Ex2 Ex3 Ex4 Ex5 Ex6 Ex7

The Basics: Exercise 1

Create an aspect named Basics with an auxiliary method output:

public aspect Basics {
 
  public void output(String tag, Object o) {
    System.out.println(tag + ": " + o);
  }
 
}

Next, add an advice to this aspect to prints a string just before the execution of the start() method. Use the following form for your advice:

before(): <pointcut> {
  output("ex1","About to start");
}
You can employ the primitive pointcut execution(Signature). The signature pattern should at least specify the return type, the method name and the arguments.

Rerun the application to see the output from your aspect.


Continue with Exercise 2.

basics/ex1.txt · Last modified: 2021/02/05 13:49 (external edit)