2011-04-12 27 views

回答

3

您可以嘗試使用特殊變量thisEnclosingJoinPointStaticPart來保存封閉的JoinPoint的靜態部分。

提到here(實施例)和here(文檔)

或者,如果使用基於註解AspectJ中,通過以下通知方法的參數,例如:

@Before("call(/* your pointcut definition */)") 
public void myCall(JoinPoint.EnclosingStaticPart thisEnclosingJoinPointStaticPart) 
{ 
    // ... 
} 

提到here

+0

如何從@AspectJ語法獲取此信息? – user496949 2011-04-12 06:24:47

+0

傳遞給advice方法的參數:'JoinPoint.EnclosingStaticPart thisEnclosingJoinPointStaticPart'(取自[here](http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-pcadvice.html)) – janhink 2011-04-12 06:28:21

+0

更新了回答 – janhink 2011-04-12 06:34:52

0
@Aspect 
public class LoggingAspect { 

    @Before(value = "execution(public * findAll())") 
    public void beforeAdvice(JoinPoint pp){ 
     System.out.println("before advice called ....get calling method Signature"+pp.getSignature()); 
     System.out.println("before advice called ....get calling method name"+pp.getSignature().getName()); 
    } 

}