Creating an aspect
In this section you will create a new aspect and add a pointcut and
some advice.
- In the Package Explorer view, select the helloworld package. From the package's
context menu, select New > Aspect.
- Make sure that Hello World appears in the Source Folder
field and that helloworld appears in the Package
field. In the Name field, type World.
- Click Finish to create the new aspect.
- The new file is opened in the editor. It contains the new aspect,
the constructor and comments.
- Change the body of the aspect to the following:
public aspect World {
pointcut greeting() : execution(* Hello.sayHello(..));
after() returning() : greeting() {
System.out.println(" World!");
}
}
- Save the file.
AspectJ editor
Creating AspectJ elements