David_W (70) [Avatar] Offline
#1
Instead of hard-coding the call like
logger.log(Level.INFO, "Entering [ajia.domain.Order.addItem]"),
you could write a class TraceLoggingWithoutAOP that looks at the call stack (eg, using Thread.getStackTrace()). The Order class then would not need a Logger, and each method would then just need to be modified to call
TraceLoggingWithoutAOP.logEntry()
David_W (70) [Avatar] Offline
#2
Re: Alternative for 10.1.2
Ah. If I had read the next page, I would have seen your discussion on extracting the call stack.
David_W (70) [Avatar] Offline
#3
Re: Alternative for 10.1.2
So, does the comment about speed of accessing the call stack also apply to cflow and cflowbelow?
ramnivas (171) [Avatar] Offline
#4
Re: Alternative for 10.1.2
cflow() and cflowbelow() perform the runtime check using a ThreadLocal, which is set and unset around the join points matching the pointcut argument. So they don't need to get the full call stack and hence much more efficient (especially now that ThreadLocal access is quite efficient in JVMs)

-Ramnivas