|
From: Chris N. <ch...@si...> - 2003-12-07 10:51:24
|
Rod Johnson wrote: > I've just checked in a simple "cflow"-style method matcher pointcut, that > enables us to apply simple conditions such as "this call came from > com.my.web.MyController class", or perhaps a particular method of such a > class. > > It's 10-15 times slower to evaluate such a pointcut than a "normal" method > matcher, because it's necessary to construct a new Throwable to analyse > the stack trace (unless someone has a better idea!). There might be a better way if you restrict the cflow matching against classes you can proxy. For example, you could add an around advice to every method in com.my.web.MyController. The advice would increment a threadlocal before and decrement it after. To check if you're within the cflow you just see if the threadlocal value is greater than zero. This is probably more portable too since getStackTrace is 1.4 only (don't know if Spring requires 1.4), but then again ThreadLocals are pretty slow on anything below 1.4. Chris |