2012-05-30 51 views
7

我有一個名爲@Invisible的自定義註釋。 現在我想匹配所有的調用一個沒有@Invisible註解的方法。我怎樣才能做到這一點? (註釋與式發展)如何匹配在AspectJ中沒有特定註釋的方法

我的第一次嘗試是:

@Pointcut("execution([email protected] * some.other.package.execute(..))") 

但是這似乎並沒有工作...

換句話說:如果該方法具有隱形註釋我想忽略它。否則,我想用我的意見執行一些代碼...

+1

你這個人之前對類中的任何其他建議嗎?換句話說,該課程是否已經被代理,可能會失去註釋? AFAIK語法本身起作用。 –

+3

嘗試類似'execution(* some.other.package.execute(..))&&!@annotation(my.package.Invisible)' –

+0

@ KonstantinV.Salikhov根據[註釋切入點筆記本](http:// www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html)你應該*能夠將它合併成一個單一的表達式,但它是值得一試的。 –

回答

7

嘗試像execution(* some.other.package.execute(..)) && [email protected](my.package.Invisible)

相關問題