Wednesday, December 19, 2012

Aspectj - trace method exection caller context details

http://mathewjhall.wordpress.com/2011/03/31/tracing-java-method-execution-with-aspectj/
:
Signature sig = thisJoinPointStaticPart.getSignature();
  String line =""+ thisJoinPointStaticPart.getSourceLocation().getLine();
  String sourceName = thisJoinPointStaticPart.getSourceLocation().getWithinType().getCanonicalName();
  Logger.getLogger("Tracing").log(
                Level.INFO, 
                "Call from "
                 +  sourceName
                    +" line " +
                    line
                    +" to " +sig.getDeclaringTypeName() + "." + sig.getName()
  );

No comments:

Post a Comment