Sunday, August 18, 2013

PerfSpy 4 -- PerfSpyAspectDemo

This Aspect would like to see how an Animal does its tricks. This Aspect has to be versatile: it can spy on a Dolphin, and if configured, spy on a Panda or other animals.


It extends from AbstractPerfSpyAspect and implements the two abstract PointCut:

@Aspect
public class PerfSpyDemoAsepct extends AbstractPerfSpyAspect {
       
        @Pointcut("execution(* com.yourcompany.zoo..*.*(..) )")
        public void withinCflowOps() {
        }

        @Pointcut("cflow(execution(*  com.yourcompany.zoo.animal.Animal.playTricks(..)  ) )")
        public void cflowOps() {
        }

}
cflowOps(): @Pointcut("cflow(execution(*  com.yourcompany.zoo.animal.Animal.playTricks(..)  ) )")
Capture what happens inside the execution of Animal.playTricks. Notice, here the superclass Animal is being spied on.

withinCflowOps():@Pointcut("execution(* com.yourcompany.zoo..*.*(..) )")
Capture all method invocations from classes inside com.yourcompany.zoo packages.

No comments:

Post a Comment