我想使用aspectj来剖析一个库。我的计划是为了纪念那些需要分析与注释方法:使用aspectj来剖析所选方法
@Profiled("logicalUnitOfWork")
然后还要将火之前和之后的方法,将使用logicalUnitOfWork
突出异形内容的一个方面。
所以,我的切入点看起来像这样。请注意,我没有这里的注释参数;这就是事情之一,我不知道该怎么做:
pointcut profiled() : execution(@Profiled * *());
before() : profiled() {
// : the profiled logical name is in this variable:
String logicalEventType;
Profiler.startEvent (logicalEventType);
}
after() returning : profiled() {
// : the profiled logical name is in this variable:
String logicalEventType;
Profiler.endEvent (logicalEventType);
}
被分析会这样被定义的方法:
@Profiled("someAction")
public void doAction (args...) {}
总之,我怎么能得到@Profiled
的价值注释到方面?我不需要根据该值限制发生哪些分析,我只是需要它对建议可见。另外,我是否需要将注释的保留设置为运行时才能运行,或者我是否可以保留类级保留?
也有一定的帮助,但最好我想有注解的类只保留文件。 AspectJ编织发生在那一点,所以我希望它能够获得价值。 – 2009-02-15 16:29:04