Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
package testAOP;

public class HelloWorld2 {

     public static void main(String args[]) {
         HelloWorldHelloWorld2 world = new HelloWorldHelloWorld2();
         System.out.println(world.greet());
     }

     public String greet() {
         return "Hello World!";
     }
}

...

In the Around annotation we also bind the advice to a specific join point, in this case an anonymous one that picks out the HelloWorldHelloWorld2.greet() method.

For more information about the annotation and XML definition, pointcut patterns etc. see the online documentation.

...

However, you might have noticed that the definition (in the aspect annotation) is not generic but coupled to the HelloWorld HelloWorld2 application. We can easily loosen up this strong coupling and make the aspect completely reusable. For more information about that, read the next tutorial.