User Tools

Site Tools


basics:ex1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

basics:ex1 [2007/02/23 16:58]
bdefrain
basics:ex1 [2021/02/05 13:49]
Line 1: Line 1:
-====== The Basics: Exercise 1 ====== 
  
-Create an aspect named ''Basics'' with an auxiliary method ''output'': 
- 
-<code aspectj> 
-public aspect Basics { 
- 
-  public void output(String tag, Object o) { 
-    System.out.println(tag + ": " + o); 
-  } 
- 
-} 
-</code> 
- 
-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: 
- 
-<code aspectj> 
-before(): <pointcut> { 
-  output("ex1","About to start"); 
-} 
-</code> 
- 
-<note tip> 
-You can employ the primitive pointcut ''execution(//Signature//)''. The signature pattern should at least specify the return type, the method name and the arguments. 
-</note> 
- 
-Rerun the application to see the output from your aspect. 
- 
----- 
- 
-Continue with [[basics:ex2|Exercise 2]]. 
basics/ex1.txt ยท Last modified: 2021/02/05 13:49 (external edit)