`Tracer.java`
`01 package trail.interceptor; 02 03 import javax.ejb.*; 04 05 06 public class Tracer { 07 08 @AroundInvoke 09 public Object log (InvocationContext ctx) 10 throws Exception { 11 12 InterceptorCalculator cal = (InterceptorCalculator) ctx.getBean(); 13 String className = ctx.getBean().getClass().getName(); 14 String methodName = ctx.getMethod().getName(); 15 String target = className + "." + methodName + "()"; 16 17 long start = System.currentTimeMillis(); 18 System.out.println ("Invoking " + target); 19 cal.setTrace(cal.getTrace() + "<br/>" + 20 "Invoking " + target); 21 try { 22 return ctx.proceed(); 23 } catch(Exception e) { 24 throw e; 25 } finally { 26 System.out.println("Exiting " + target); 27 cal.setTrace(cal.getTrace() + "<br/>" + 28 "Exiting " + target); 29 long time = System.currentTimeMillis() - start; 30 System.out.println("This method takes " + 31 time + "ms to execute"); 32 cal.setTrace(cal.getTrace() + "<br/>" + 33 "This method takes " + 34 time + "ms to execute"); 35 } 36 } 37 38 }`