java能过吗_java – 你能通过例子解释AspectJ的cFlow(P u00...
Does it mean “get all join points that are in P, then add all join
points that are in Q, then match on anything that flows from any of
them”?
不,這意味著獲得P和Q中的所有連接點(diǎn),因此它是交叉點(diǎn).
Or does it mean “get all join points in P that are also in Q”, i.e.
all flow points within X() below?
是的,“獲得P中的所有連接點(diǎn)也在Q中”,其余部分則為“否”.原因是切入點(diǎn)P定義了一個(gè)連接點(diǎn):execution(void Example.P()),而切入點(diǎn)Q定義了一個(gè)連接點(diǎn):execution(void Example.Q()).因?yàn)檫@些連接點(diǎn)不同,所以它們的交集是空集.從空集中獲取的cflow也是一個(gè)空集.這就是為什么在AspectJ文檔中,這個(gè)切入點(diǎn)標(biāo)記為“不應(yīng)該發(fā)生”.
希望這可以幫助!
這是Power Point演示文稿中的一個(gè)誤導(dǎo)性引用:
cflow(P && Q) means that you first combine the pointcuts P and Q, and
all the join points flowing from that are in this collection
“combine”一詞應(yīng)改為“intersect”.
public class Example {
public void P() {
Q();
}
public void Q() {
}
public static void main(String[] args) {
new Example().P();
}
}
如果你運(yùn)行它,輸出應(yīng)該是這樣的:
pointcut: P join point: execution(Example.P())
pointcut: flowP join point: execution(Example.P())
pointcut: flowP join point: call(Example.Q())
pointcut: Q join point: execution(Example.Q())
pointcut: flowP join point: execution(Example.Q())
pointcut: flowQ join point: execution(Example.Q())
pointcut: flowPAndflowQ join point: execution(Example.Q())
這表明只有3個(gè)連接點(diǎn):
A: execution(Example.P())
B: call(Example.Q())
C: execution(Example.Q())
切入點(diǎn):
pointcut P includes only A
pointcut Q includes only C
pointcut flowP includes A, B and C
pointcut flowQ includes only C
pointcut flowPAndflowQ includes only C
我們現(xiàn)在可以看到P&& flow是一個(gè)空集,而flowP&& flowQ包括C.
我還包括了額外的切入點(diǎn):cflow(P()&& publicMethods())(這個(gè)切入點(diǎn)的建議在代碼中被注釋掉了). publicMethods()是執(zhí)行(public * *(..)).與cflow(P()&& Q())不同,它不會(huì)導(dǎo)致空集.
總結(jié)
以上是生活随笔為你收集整理的java能过吗_java – 你能通过例子解释AspectJ的cFlow(P u00...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 修改TFS与本地源代码映射路径
- 下一篇: commons-fileupload、s