I am having trouble with building aspectJ expression. I would like to run my advice when any of "QueryUtil" method is invoked from class "Report".
For example: if we invoke QueryUtil.*() inside of Report.*() -> Advice is executed. If we invoke QueryUtil.*() from AnyOtherClass.* -> Advice is not executed.
I was thinking of cflow expression but still did not find a way to write it. I was thinking of something like this:
<pointcut name="scope"
expression="( cflow(call(* ext.demo.Report.\*(..))) && execution(* ext.demo.QueryUtil.*(..)))"/>
Could anyone help me with that?
The only odd thing in your pointcut is the rogue '\' I see ahead of the * in the cflow pointcut component. I'd also suggest using execution() if you can rather than call() (there are typically lots of call sites to instrument but only one execution site).
cflow(execution(* ext.demo.Report.*(..))) && execution(* ext.demo.QueryUtil.*(..))
If it isn't behaving for you then break it down to work out which piece is at fault. Does execution(* ext.demo.QueryUtil.*(..))
match everything you expect? Does execution(* ext.demo.Report.*(..))
match everything you expect? (I'd use -showWeaveInfo
to check)