1 7 package org.jboss.tutorial.interceptor.bean; 8 9 import javax.ejb.AroundInvoke; 10 import javax.ejb.InvocationContext; 11 12 public class TracingInterceptor { 13 14 @AroundInvoke 15 public Object log(InvocationContext ctx) throws Exception 16 { 17 System.out.println("*** TracingInterceptor intercepting"); 18 long start = System.currentTimeMillis(); 19 try 20 { 21 return ctx.proceed(); 22 } 23 catch(Exception e) 24 { 25 throw e; 26 } 27 finally 28 { 29 long time = System.currentTimeMillis() - start; 30 String method = ctx.getBean().getClass().getName() + "." + ctx.getMethod().getName() + "()"; 31 System.out.println("*** TracingInterceptor invocation of " + method + " took " + time + "ms"); 32 } 33 } 34 } 35 | Popular Tags |