1 16 17 package org.springframework.remoting.support; 18 19 import java.lang.reflect.Method ; 20 21 import org.aopalliance.intercept.MethodInterceptor; 22 import org.aopalliance.intercept.MethodInvocation; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 import org.springframework.util.ClassUtils; 27 28 46 public class RemoteInvocationTraceInterceptor implements MethodInterceptor { 47 48 protected static final Log logger = LogFactory.getLog(RemoteInvocationTraceInterceptor.class); 49 50 private final String exporterName; 51 52 53 58 public RemoteInvocationTraceInterceptor(String protocolName) { 59 this.exporterName = protocolName; 60 } 61 62 63 public Object invoke(MethodInvocation invocation) throws Throwable { 64 Method method = invocation.getMethod(); 65 if (logger.isDebugEnabled()) { 66 logger.debug("Incoming " + this.exporterName + " remote call: " + 67 ClassUtils.getQualifiedMethodName(method)); 68 } 69 try { 70 Object retVal = invocation.proceed(); 71 if (logger.isDebugEnabled()) { 72 logger.debug("Finished processing of " + this.exporterName + " remote call: " + 73 ClassUtils.getQualifiedMethodName(method)); 74 } 75 return retVal; 76 } 77 catch (Throwable ex) { 78 if (ex instanceof RuntimeException || ex instanceof Error ) { 79 if (logger.isWarnEnabled()) { 80 logger.warn("Processing of " + this.exporterName + " remote call resulted in fatal exception: " + 81 ClassUtils.getQualifiedMethodName(method), ex); 82 } 83 } 84 else { 85 if (logger.isInfoEnabled()) { 86 logger.info("Processing of " + this.exporterName + " remote call resulted in exception: " + 87 ClassUtils.getQualifiedMethodName(method), ex); 88 } 89 } 90 throw ex; 91 } 92 } 93 94 } 95 | Popular Tags |