FastAOP framework: The pointcut language

An aspect class is a simple Java class annotated with an @Aspect annotation and implementing an interface with be-fore(..), after(..), and getPointcuts() methods. Unlike in AspectJ where pointcuts are defined as language constructs, in FastAOP a developer has to define pointcuts programmatically using a builder pattern. The general usage is:

  IPointcut pointcut = Pointcut.classPattern("package..*")..build your expression .compile();

Lets start with a first example:

Pointcut.classPattern("javax.ejb.SessionBean+").
                .or("org.fastaop..*AbstractBean")
                .or("org.fastaop..*Bean*")
                .method("*").andNot("*SessionContext").andNot("create")
                .andNot("destroy").andNot("create").andNot("ejb*").compile();

This pointcut matches all methods in all classes implementing the 'javax.ejb.SessionBean' interface or in the ‘org.fastaop’ ending with 'AbstractBean' or 'Bean', but not the ejb live cycle methods like get-, setSessionContext (ending with SessionContext), destroy, create, ejb (stringWith).

Pointcut.classPattern("com.fastaop..*")
                .annotatedWith("javax.ejb.Session")
                .compile();

This pointcut matches all methods in all classes in the 'org.fastaop' package or below annotated with the javax.ejb.Session annotation. You can pass a string if this annotation is not in your classpath. If the annotation is in the classpath the following expression can be used:

Pointcut.classPattern("com.fastaop..*")
                .annotatedWith(javax.ejb.Session.class)
                .compile();

This pointcut matches all methods in all classes in the 'org.fastaop' package or below annotated with the javax.ejb.Session annotation at the class level, means all method will be matched if the class is annotated.

Pointcut.classPattern("com.siemens.fastaop..*")
                .method("*").annotatedWith(javax.ejb.EJB.class).compile();

This pointcut matches all methods in all classes in the 'org.fastaop' package or below annotated with the javax.ejb.EJB to the method level.