[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Trace method calls with around advice
|
Martin,
If you value performance, which most
people do when tracing, then you will not use around advice. Entry/exit/exception
events generated by before/after returning/after throwing advice easily
be correlated offline. If you really need to do it online use a ThreadLocal
counter.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
Please respond to aspectj-users@xxxxxxxxxxx
Sent by:
aspectj-users-bounces@xxxxxxxxxxx
To:
AspectJ User List <aspectj-users@xxxxxxxxxxx>
cc:
Subject:
[aspectj-users]
Trace method calls with around advice
Hello!
I want to trace method calls using an around advice. It is important
that I can associate method calls and their return value and a thrown
exception, respectively. So, using before and after advices does not
meet my requirements (without using the stack information).
An advice like the following could do the job:
Object around() throws Exception: aCall() {
logger.trace("Before proceed: " +
thisJoinPoint);
int id = Manager.record(thisJoinPoint);
Object returned = null;
try {
returned = proceed();
} catch (Exception e) {
logger.trace("After proceed:
" + thisJoinPoint);
logger.trace("Threw an exception:
" + e);
Manager.recordException(id, e);
throw e;
}
logger.trace("After proceed: " +
thisJoinPoint);
logger.trace("Returned normally with "
+ returned);
Manager.record(id, returned);
return returned;
}
Unfortunately, that advice does not work. Using an RuntimeException will
not handle method with checked exceptions.
Is there any way to do this job using AspectJ?
Regards,
Martin
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users