// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package traditional;

import org.aspectj.lang.ProceedingJoinPoint;

// aspect
aspect Trace2 {
    // pointcut:
    //   public visibility, any return type, class traditional.IntMath, any method name, any arguments
    //   public visibility, any return type, class traditional.DoubleMath, any method name, any arguments
    pointcut mathtrace() : call(public * traditional.IntMath.*(..)) || call(public * traditional.DoubleMath.*(..));
    // advice:
    //    around
    Object around() : mathtrace() {
        System.out.println("AOP> Enter " + thisJoinPoint.getSignature());
        Object res = null;
        try {
            res = proceed();
        } catch(Throwable e) {
             throw (RuntimeException)e;
        }
        System.out.println("AOP> Exit " + thisJoinPoint.getSignature());
        return res;
    }
}
