2013-01-25 31 views
1

是否有可能知道哪些方法在AspectJ中被切入點覆蓋?切入點覆蓋哪些方法?

對這個問題的背景是,我有一個涵蓋了所有方法(除了它自己)一個切入點:

pointcut traceMethods() : (execution(* *(..))&& !cflow(within(MethodTrace))); 

我希望能夠創建一個用於覆蓋每一個方法的方法的簽名名單一旦應用程序啓動,通過切入點這可能嗎?

pointcut traceMethods() : (execution(* *(..))&& !cflow(within(MethodTrace))); 

before() : traceMethods() 
{ 
    // Holds the signature the method intercepted by the pointcut traceMethods() 
    String s = thisJoinPointStaticPart.getSignature().toString(); 

    // do something with string 's' 
} 

更多關於它的信息here

+0

你解決了你的問題嗎? – dreamcrash

回答

0

如果我正確理解你的問題,你可以通過做一些像上面這樣做

的AspectJ提供了一個特殊的參考變量,thisJoinPoint,即 包含關於 建議使用的當前連接點的反射信息。 thisJoinPoint變量只能在 建議上下文中使用,就像這樣只能在 非靜態方法和變量初始值設定項的上下文中使用。在建議中,thisJoinPoint 是org.aspectj.lang.JoinPoint類型的對象