1 16 17 package org.springframework.aop.aspectj; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.aspectj.bridge.AbortException; 22 import org.aspectj.bridge.IMessage; 23 import org.aspectj.bridge.IMessage.Kind; 24 import org.aspectj.bridge.IMessageHandler; 25 26 40 public class AspectJWeaverMessageHandler implements IMessageHandler { 41 42 private static final String AJ_ID = "[AspectJ] "; 43 44 private static final Log logger = LogFactory.getLog("AspectJ Weaver"); 45 46 47 public boolean handleMessage(IMessage message) throws AbortException { 48 Kind messageKind = message.getKind(); 49 50 if (logger.isDebugEnabled() || logger.isTraceEnabled()) { 51 if (messageKind == IMessage.DEBUG) { 52 logger.debug(makeMessageFor(message)); 53 return true; 54 } 55 } 56 57 if (logger.isInfoEnabled()) { 58 if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) { 59 logger.info(makeMessageFor(message)); 60 return true; 61 } 62 } 63 64 if (logger.isWarnEnabled()) { 65 if (messageKind == IMessage.WARNING) { 66 logger.warn(makeMessageFor(message)); 67 return true; 68 } 69 } 70 71 if (logger.isErrorEnabled()) { 72 if (messageKind == IMessage.ERROR) { 73 logger.error(makeMessageFor(message)); 74 return true; 75 } 76 } 77 78 if (logger.isFatalEnabled()) { 79 if (messageKind == IMessage.ABORT) { 80 logger.fatal(makeMessageFor(message)); 81 return true; 82 } 83 } 84 85 return false; 86 } 87 88 private String makeMessageFor(IMessage aMessage) { 89 return AJ_ID + aMessage.getMessage(); 90 } 91 92 public boolean isIgnoring(Kind messageKind) { 93 return false; 95 } 96 97 public void dontIgnore(Kind messageKind) { 98 } 100 101 public void ignore(Kind kind) { 102 } 104 105 } 106 | Popular Tags |