1 16 17 package org.springframework.aop.interceptor; 18 19 import org.aopalliance.intercept.MethodInvocation; 20 import org.apache.commons.logging.Log; 21 22 36 public class SimpleTraceInterceptor extends AbstractTraceInterceptor { 37 38 41 public SimpleTraceInterceptor() { 42 } 43 44 50 public SimpleTraceInterceptor(boolean useDynamicLogger) { 51 setUseDynamicLogger(useDynamicLogger); 52 } 53 54 55 protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable { 56 String invocationDescription = getInvocationDescription(invocation); 57 logger.trace("Entering " + invocationDescription); 58 try { 59 Object rval = invocation.proceed(); 60 logger.trace("Exiting " + invocationDescription); 61 return rval; 62 } 63 catch (Throwable ex) { 64 logger.trace("Exception thrown in " + invocationDescription, ex); 65 throw ex; 66 } 67 } 68 69 74 protected String getInvocationDescription(MethodInvocation invocation) { 75 return "method '" + invocation.getMethod().getName() + "' of class [" + 76 invocation.getThis().getClass().getName() + "]"; 77 } 78 79 } 80 | Popular Tags |