Introduction

Java is an object-oriented programming language developed by Sun Microsystems that has proven itself in numerous projects. The Java Platform is hardware and operating system independent and comes in three editions: Micro Edition for PDAs and cell phones; Standard Edition for computer programs; and Enterprise Edition for distributed, transactional, and portable applications.

Friday, April 16th, 2004 at 12:45 pm

AOP: Pointcuts

I covered the basics of AOP in my previous articles “AOP - Aspect Oriented Programming” and “AOP: Terms and AspectJ”. If you haven’t read them yet I’d suggest you to do this now. Otherwise just go on reading.
As I mentioned earlier pointcuts capture or identify join points. Named poincuts have the following syntax:

Syntax:
[access-specifier] pointcut pointcut-name([arguments]) : pointcut-type(signature)

Example:
public pointcut myPointcut() : execution(public void MyClass.myMethod())

You do use them in an advice as follows:

before() : myPointcut() {

}

Anonymous pointcuts are directly declared behind the “:”. It would then look like this:

before() : execution(public void MyClass.myMethod()) {

}

Well, that’s it for now. Easy, isn’t it? I will cover wildcards in my next article about AOP. And I hope that at the latest then you will recognize that AOP is a lot of fun. :)