Introduction

Aspect-oriented programming helps programmers in the separation of (cross-cutting) concerns to improve the overall architecture of an application by making it more modular and removing duplicate code.

Tuesday, May 4th, 2004 at 6:19 pm

AOP: Control-Flow Based Pointcuts

If you wanna catch join points that occur within the control flow of another join point you need control-flow based pointcuts. There do only exist two control-flow based pointcuts: cflow(Pointcut) and cflowbelow(Pointcut). The cflow(Pointcut) pointcut will capture all joint points that occur within the specified pointcut, including the join points matching the pointcut itself. Whereas the cflowbelow(Pointcut) pointcut will only capture the join points that occur within the join points matching the specified pointcut.

Example:
cflow(call(* MyClass.myMethod(..))
This pointcut would capture all join points that occur inside any myMethod() method in MyClass that is called, including the call to myMethod() itself.

cflowbelow(call(* MyClass.myMethod(..))
If you’d change cflow to cflowbelow the call to myMethod() would not be captured.