[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] general tracing aspect
|
Hello all,
I have a bunch of classes each with its own static instance of a log4j
logger. This instances all have the same name 'logger'. I want to add
enter-leave tracing to each of the methods of all classes but would be
interested in making this with a single aspect. However I'm having trouble
with the sintax to refer to the logger in my advice, without using the class
name -which would defeat the purpose. I cannot use type patterns in advice,
rigth ? Can anyone provide any hints ? Using aspectJ, a sintatically wrong
expression of my needs would be:
package my.package;
privileged aspect TraceEnterLeave
{
pointcut method(): within(my.package..*) && execution(* *(..));
before(): method()
{
(my.package..*).logger.enter(thisJoinPointStaticPart.getSignature().getName(
) ,
thisJoinPoint.getArgs());
}
after() returning(Object o): method()
{
(my.package..*).logger.leave(thisJoinPointStaticPart.getSignature().getName(
), o);
}
}
A related question would be how to migrate the static logger declaration in
each class to that tracing aspect ? Could I use a type pattern to get the
class name to instatiate each logger ?
Thanks in advance.
Nuno