import org.apache.log4j.Logger;public aspect Trace { protected static Logger loggerTracing = Logger.getLogger("Tracing"); pointcut trace(): (execution(public * pacote1..*(..)) || execution(public * pacote2..*(..)) || execution(public * pacote3..*(..))); before(): trace() { String metodo = thisJoinPoint.getSignature().getName(); if(!metodo.startsWith("get") && !metodo.startsWith("set") && !metodo.startsWith("is")) loggerTracing.debug("Entrou: " + metodo); } after() returning(): trace() { String metodo = thisJoinPoint.getSignature().getName(); if(!metodo.startsWith("get") && !metodo.startsWith("set") && !metodo.startsWith("is")) loggerTracing.debug("Saiu: " + metodo); }}
Saturday, September 4, 2010
Um esqueleto de Aspecto para Tracing
Um Aspecto simples para tracing, tirando os métodos get/set/is.
Labels:
java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment