0

Regarding AspectJ and AOP in general:
What are the most used pointcut primitives?
Are there any statistics on this?

I think it could be execution and call, is that right?

Thanks.

Thorben
  • 953
  • 13
  • 28
  • I know this one is old, but still listed as unanswered. Would you please accept and upvote my answer if it seems appropriate? Thanks. – kriegaex Jun 09 '14 at 12:34

1 Answers1

1

Given the fact that in the Java-based AOP area method execution is the only pointcut supported by Spring AOP which in turn supports @AspectJ syntax for its pointcuts, I would guess that this is the most frequently used pointcut primitive overall. I cannot help you with the stats part, though.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Good points. I thought it would be interesting to know which pointcuts and/or advices are most frequent used, because you can optimize things. But the real reason was to find out how important the call pointcut is ;) – Thorben May 17 '13 at 09:34
  • 1
    Actually the `call` pointcut is quite important because in situations when you cannot easily weave the callee with `execution`, you can still weave the callers via `call`. So the two pointcuts are complimentary rather than redundant. I only use full-blown AspectJ because Spring AOP is just not powerful enough for me, too many compromises there AOP-wise. – kriegaex May 17 '13 at 14:00
  • Thanks. The difference between `call` and `execution` is clear. You need the `call` pointcut when you want to do/change something in the class or at the point you called a specific method. Also the `this` Object is another one than the one you get with `execution`. The only thing I don't know how often it comes to situations you need the call pointcut. – Thorben May 18 '13 at 13:31
  • 1
    Imagine you want to intercept executions of code in a 3rd party library or even in the JDK. So if you are in a situation in which you cannot or must not weave the lib/JDK, you kinda need to use `call` as a fall-back solution for `execution`. But you are right, this tells you something about *when*, not about *how often*. – kriegaex May 18 '13 at 13:57
  • I know it's a different question, but do you know some projects that use AspectJ? I want to show some real examples, but couldn't find anything about that. – Thorben May 20 '13 at 12:30
  • I am currently coaching some teams in a big telco project (Scrum, Kanban). One of my teams uses some AspectJ. Not heavily, but anyway. Actually this example is rather pointless though because prominent reference projects do not tell you if AspectJ is adequate for your purposes. IMHO AspectJ is so tremendously useful and reliable that I wish every Java developer knew how to use it. People are so afraid of anything non-mainstream, they walk like lemmings where the rest of the flock walks to. If only reference projects help you sell AspectJ in your project, poor you. – kriegaex May 20 '13 at 18:06
  • That's totally true. Fortunately I had a lecture where we discussed AspectJ, therefore we can hope for the future ;) – Thorben May 21 '13 at 08:26