• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Joinpoint and Pointcut

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramnivas,
On a lighter note I have one more question. Directly or indirectly I am using AOP for quite some time in my Spring app. But theoretical when it comes to distinguish between various terminologies aspect, advice, pointcut, joinpoint; I get confused.

Is there any easy way to remember it?


Regards,
Paras
 
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can think of
- aspect as a class-like concept.
- advice as an automatically called method
These two are usually understood easily.

Join point and pointcut concept take a bit longer. One way to think:
- Join points are like rows in database--they just exists much the same way methods just exists.
- Pointcuts are like SQL statements--they select join points just as SQL selects rows.

I hope this helps.

-Ramnivas
 
Paras Jain
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ramnivas. Yes it definitely helps.

Just to make sure my understanding is clear. Let's take example of logging aspect. I want to log before all methods starting with 'test'. (Hypothetically, not sure whether you can do based on method pattern)

Aspect - It's like calling logging framework, the Process of logging
Advice - I am advising the AOP to call log methods on logging framework, like a method

Joinpoints - are actually beginning of methods, AOP intercepts at this point to do some other stuff. i.e. beginning of methods testA(), testB(), testC(), somethingElseD(), somethingElseE()
Point cuts - Pointcut selects those joinpoints based on your aop settings, i.e. out of all the methods select testA(), testB() and testC() and intercept only those.

Is that correct?


Regards,
Paras
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When teaching this I use the terms

A JoinPoint is any Method in your app's code that you wrote whether you were using AOP or not.
An advice is code you want to run when that JoinPoint method is being called, without adding the code directly into your app's method.
An Aspect is the class that holds the advice code.

A Pointcut is telling AOP which Joinpoints you want your advice code to run with/on.

Mark
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aspect: an aspect, a feature
Join point: a point that aspects can join.
Advice: an aspect joins at a point and advices somebody at that point, the latter action is called ... "advice".
Pointcut: draw line to cut points, aspect will advice somebody at the cut points

Hope this helps.
 
Ramnivas Laddad
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark already clarified, but I will add a bit more...

Paras Jain wrote:
Aspect - It's like calling logging framework, the Process of logging


More like aspects is a programming element that hold all other AOP programming elements -- pointcuts, advice etc.


Advice - I am advising the AOP to call log methods on logging framework, like a method


Advice is extra code that you want to invoke when you reach points selected by your pointcut

 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic