I'm wondering if there is an easy way to find all methods that match a particular pointcut. For example, I'd like something that can return a list of Methods or JoinPoints so I can get the class name and method name. For example:
The specifics:Code:List<JoinPoint> jps = AopUtils.findMatchingJoinPoints(MyAspect.class)
I want to make it easy to expose JMX statistics on some of my public controller handler methods. For example:
To do this, I want to create a some simple @Before advice that keeps a counter of each time the login() method is invoked and then expose that counter over JMX.Code:@Controller LoginController { @RequestMapping("/login") @JmxTracked public String login(HttpServletRequest pReq) {...}
Code:@Aspect public class JmxTrackingAspect { @Before(@annotation(com.mycompany.JmxTracked)) public void incrementCount() {...} }I know how to write the Aspect for this. However, I need help writing my special MBeanExporter that finds every method that matches the pointcut because I want to create one instance of my counter MBean for each method. This way I can eagerly create all of the MBeans at startup so that the advice can always know the MBean is created and available.Code:/** This is will be exposed with one instance for each @JmxTracked method */ public class Counter { public int getInvokationCount(); }
Is there a way to find all of the methods that match a particular pointcut? I would like to find them all at startup and create the MBeans.
Thanks for any tips or pointers.


Reply With Quote