Can you explain what AspectJ cFlow (P && Q) does with an example?

I am currently looking at the AspectJ documentation, and I do not quite understand their Pointcut composition . In particular, I don’t understand what it does cFlow(P && Q)when the advice with this pointcut is executed.

A PowerPoint presentation (for a course at the University of Utrecht) I found an explanation

cflow is a collection of join points emanating from a slice of points argument. This means that cflow (P) && cflow (Q) is the intersection of two collections, while cflow (P && Q) means that you first merge pointcuts P and Q, and all the connection points resulting from this are in this collection.

They list all the join points for cFlow(P) && cFlow(Q)( pointcut flowPAndflowQ() : cflow(execution(* Example.P(..))) && cflow(execution(* Example.Q(..))) && within(Example);), and for me it looks like an intersection of all the control points of the stream of individual statements - P ∩ Q, if you will (as they said):

Stream from P-execution (void Example.P ())
Stream from P-call (void Example.Q ())
Stream from P-execution (void Example.Q ())
Stream from Q-execution (void Example.Q ( ))
Stream from P && stream from Q-execution (void Example.Q ())

(Their example is similar to that in AspectJ docs, except for the absence of the println () statement.)

What I (still) do not understand is what cFlow(P && Q)will do.

" , P, , Q, , "? , println() AspectJ: System.out.println("should not occur"); , P Q (.. P + Q), () P ∩ Q, P ∪ Q?

" P, Q", ..   X() ?

public void P() { X(); }
public void Q() { X(); }
public void X() { /* all that is in the body of X() */ }

, AspectJ? (?)

, - .:)

+4
1

" , P, , Q, , "?

, , P Q, .

" P, Q", .. X() ?

" P, Q", . pointcut P : (void Example.P()), pointcut Q : execute (void Example.Q()). , . cflow, , . AspectJ pointcut " ".

, !

Power Point:

cflow (P & Q) , pointcuts P Q , ,

"" "".

Github, PowerPoint: https://github.com/medvedev1088/aspectj-cflow-composition-example

public class Example {
    public void P() {
        Q();
    }

    public void Q() {
    }

    public static void main(String[] args) {
        new Example().P();
    }
}

, :

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 :

A: execution(Example.P())
B: call(Example.Q())
C: execution(Example.Q())

:

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

, P && Q - , flowP && flowQ C.

pointcut: cflow (P() && publicMethods()) ( pointcut ). publicMethods() (public * * (..)). cflow (P() & Q()) .

+1

All Articles