0

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?

Gazeciarz
  • 516
  • 1
  • 8
  • 22

1 Answers1

1

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)

Andy Clement
  • 2,510
  • 16
  • 11
  • Sorry, The "odd thing" was my fault during writing the question. Don't know why I wanted to escape *.. Thank You very much for solving my problem! It works perfectly fine. – Gazeciarz Aug 05 '15 at 07:54