Professional Documents
Culture Documents
Aim: Theory:: Experiment No.: 6
Aim: Theory:: Experiment No.: 6
: 6
Steps:
1. The package figures we have already installed in our Eclipse IDE for previous experiment,
and here also we are going to use Point.java class for our experiment.
FieldInAspectJ.aj File
package com.aop.gbu;
import java.io.PrintStream;
public aspect FieldInAspectJ {
// Field in AspectJ.
PrintStream logStream = System.err;
pointcut move() : call(* figures.Point.move(int,int)) && within(FieldInAspectJTest);
before () : move() {
logStream.println("Before Point move");
}
}
FieldInAspectJTest.java file
package com.aop.gbu;
import figures.Point;
public class FieldInAspectJTest {
public static void main(String[] args) {
Point point = new Point(10, 200);
System.err.println("---- (1) ----");
System.err.println("---- (2) ----");
point.move(10, 10);
System.err.println("---- (3) ----");
}
}
Output: